From: Han-Wen Nienhuys Date: Mon, 22 Mar 2004 15:17:52 +0000 (+0000) Subject: (Changing context X-Git-Tag: release/2.1.34~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ec1e29ed2e01731c54ed720d28dc98d0267e7955;p=lilypond.git (Changing context default settings): new node. (Defining new contexts): new node. --- diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely index 2e9840019e..eeb2359543 100644 --- a/Documentation/user/changing-defaults.itely +++ b/Documentation/user/changing-defaults.itely @@ -267,7 +267,8 @@ Translation @arrow{} Context. * Changing context properties on the fly :: * Modifying context plug-ins:: * Layout tunings within contexts:: -* Defining context defaults :: +* Changing context default settings:: +* Defining new contexts:: * Which properties to change:: @end menu @@ -669,7 +670,7 @@ The adjustments of the previous chapters can also be entered separate from the music, in the @code{\paper} block, @example - \paper { + \paper @{ @dots{} \context @{ \StaffContext @@ -713,6 +714,11 @@ will also work. +@refbugs + +It is not possible to collect changes in a variable, and apply them to +one @code{\context} definition by referencing that variable. + @node Defining new contexts @subsection Defining new contexts @@ -732,7 +738,7 @@ to indicate improvisation in Jazz pieces, \name ImproVoice \type "Engraver_group_engraver" \consists "Note_heads_engraver" - \consists "Text_script_engraver" + \consists "Text_engraver" \consists Pitch_squash_engraver squashedPosition = #0 \override NoteHead #'style = #'slash @@ -741,12 +747,12 @@ to indicate improvisation in Jazz pieces, } \context { \StaffContext \accepts "ImproVoice" - } + }} \score { \notes \relative c'' { - a4 d8 bes8 \new ImproVoice { c4^"ad lib" 4 + a4 d8 bes8 \new ImproVoice { c4^"ad lib" c4 c^"undress" c c_"while playing :)" } a1 - } + }} @end lilypond @@ -754,11 +760,11 @@ These settings are again done within a @code{\context} block inside a @code{\paper} block, @example - \paper { - \context { + \paper @{ + \context @{ @dots{} - } - } + @} + @} @end example In the following discussion, the example input shown should go on the @@ -783,7 +789,7 @@ The context will print notes, and instructive texts @verbatim \consists Note_heads_engraver - \consists Text_script_engraver + \consists Text_engraver @end verbatim but only on the center line, @@ -830,8 +836,8 @@ Put together, we get } @end verbatim -Contexts form hierarchies. We want to hang the @consists{ImproVoice} -under @consists{Staff}, just like normal @code{Voice}s. Therefore, we +Contexts form hierarchies. We want to hang the @context{ImproVoice} +under @context{Staff}, just like normal @code{Voice}s. Therefore, we modify the @code{Staff} definition with the @code{\accepts} command,@footnote{The opposite of @code{\accepts} is @code{\denies}, which is sometimes when reusing existing context definitions. } @@ -846,8 +852,6 @@ which is sometimes when reusing existing context definitions. } @end verbatim -@example - @node Which properties to change @@ -1670,8 +1674,6 @@ This manual: @ref{Selecting font sizes}. @menu * Line breaking:: * Page layout:: -* Defining contexts:: -* Defining new contexts:: @end menu @node Line breaking @@ -1809,112 +1811,6 @@ reliably choose page breaks in longer pieces. -@node Defining contexts -@subsection Defining contexts - -@cindex context definition -@cindex translator definition - -The most common way to create a new context definition is by extending -an existing one. An existing context from the paper block is copied -by referencing a context identifier: - -@example -\paper @{ - \context @{ - @var{context-identifier} - @} -@} -@end example - -@noindent -Every predefined context has a standard identifier. For example, the -@code{Staff} context can be referred to as @code{\StaffContext}. - -The context can then be modified by setting or changing properties, -e.g. -@example -\context @{ - \StaffContext - Stem \set #'thickness = #2.0 - defaultBarType = #"||" -@} -@end example -These assignments happen before interpretation starts, so a property -command will override any predefined settings. - -@cindex engraver - -@refbugs - -It is not possible to collect multiple property assignments in a -variable, and apply to one @code{\context} definition by -referencing that variable. - - - -@node Defining new contexts -@subsection Defining new contexts - - -It is also possible to define new contexts from scratch. To do this, -you must define give the new context a name. In the following -example, a very simple Staff context is created: one that will put -note heads on a staff symbol. - -@example -\context @{ - \type "Engraver_group_engraver" - \name "SimpleStaff" - \alias "Staff" - \consists "Staff_symbol_engraver" - \consists "Note_head_engraver" - \consistsend "Axis_group_engraver" -@} -@end example - -@noindent -The argument of @code{\type} is the name for a special engraver that -handles cooperation between simple engravers such as -@code{Note_head_engraver} and @code{Staff_symbol_engraver}. This -should always be @code{Engraver_group_engraver} (unless you are -defining a Score context from scratch, in which case -@code{Score_engraver} must be used). - -The complete list of context modifiers is the following: -@itemize @bullet -@item @code{\alias} @var{alternate-name}: -This specifies a different name. In the above example, -@code{\set Staff.X = Y} will also work on @code{SimpleStaff}s. - -@item @code{\consistsend} @var{engravername}: -Analogous to @code{\consists}, but makes sure that -@var{engravername} is always added to the end of the list of -engravers. - -Engravers that group context objects into axis groups or alignments -need to be at the end of the list. @code{\consistsend} insures that -engravers stay at the end even if a user adds or removes engravers. - -@item @code{\accepts} @var{contextname}: -This context can contains @var{contextname} contexts. The first -@code{\accepts} is created as a default context when events (e.g. notes -or rests) are encountered. - -@item @code{\denies}: -The opposite of @code{\accepts}. - -@item @code{\name} @var{contextname}: -This sets the type name of the context, e.g. @code{Staff}, -@code{Voice}. If the name is not specified, the translator will not -do anything. -@end itemize - -@c EOF - - - - @node Output details @section Output details diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 93b3ccdda3..80b446534b 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -144,7 +144,8 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) } announce_grob (p_ref_, SCM_EOL); - if (p_ref_ == break_item_) + if (to_boolean (get_property ("createSpacing")) + && p_ref_ == break_item_) { Item *it = make_item ("StaffSpacing"); current_spacings_.staff_spacing_ = it; @@ -225,8 +226,8 @@ Separating_line_group_engraver::stop_translation_timestep () ENTER_DESCRIPTION (Separating_line_group_engraver, /* descr */ "Generates objects for computing spacing parameters.", -/* creats*/ "SeparationItem SeparatingGroupSpanner", +/* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing", /* accepts */ "", /* acks */ "item-interface", -/* reads */ "", +/* reads */ "createSpacing", /* write */ "breakableSeparationItem"); diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index e87234978e..09e1ab073c 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -21,7 +21,7 @@ */ class Text_engraver : public Engraver { - Link_array reqs_; + Link_array evs_; Link_array texts_; public: TRANSLATOR_DECLARATIONS (Text_engraver); @@ -37,7 +37,7 @@ Text_engraver::try_music (Music *m) { if (m->is_mus_type ("text-script-event")) { - reqs_.push (m); + evs_.push (m); return true; } return false; @@ -79,9 +79,9 @@ Text_engraver::process_acknowledged_grobs () { if (texts_.size ()) return; - for (int i=0; i < reqs_.size (); i++) + for (int i=0; i < evs_.size (); i++) { - Music * r = reqs_[i]; + Music * r = evs_[i]; // URG: Text vs TextScript Item *text = make_item ("TextScript"); @@ -123,7 +123,7 @@ Text_engraver::stop_translation_timestep () typeset_grob (ti); } texts_.clear (); - reqs_.clear (); + evs_.clear (); } diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 05fe54c186..3dec9753f1 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -47,7 +47,7 @@ extraVerticalExtent = ##f verticalExtent = ##f localKeySignature = #'() - + createSpacing = ##t % explicitly set instrument, so we don't get % weird effects when doing instrument names for % piano staves diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index c041e85cfe..b9894df096 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -143,6 +143,7 @@ symbol go, measured in half staff spaces from the center of the staff.") (connectArpeggios ,boolean? " If set, connect arpeggios across piano staff.") (createKeyOnClefChange ,boolean? "Print a key signature whenever the clef is changed.") + (createSpacing ,boolean? "Create StaffSpacing objects? Should be set for staves.") (crescendoText ,markup? "Text to print at start of non-hairpin crescendo, i.e.: @samp{cresc.}") (crescendoSpanner ,symbol? "Type of spanner to be used for crescendi. One of: @samp{hairpin}, @samp{line}, @samp{dashed-line}, diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 683f28fc65..c987c97b0a 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -189,15 +189,16 @@ . ( (breakable . #t) (stacking-dir . 1) - (break-align-orders . #((instrument-name left-edge ambitus breathing-sign - clef key-signature staff-bar + (break-align-orders . #(; end-of-line: + (instrument-name left-edge ambitus breathing-sign + clef staff-bar key-signature time-signature custos) (instrument-name left-edge ambitus breathing-sign clef staff-bar key-signature staff time-signature custos) (instrument-name left-edge ambitus breathing-sign - clef staff-bar key-signature + clef key-signature staff-bar time-signature custos) ))