From b4ee6cee22686157744f382b2fdc4279f147f310 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 6 Jan 2004 23:34:27 +0000 Subject: [PATCH] * input/test/slur-shape.ly (x): remove file. * lily/translator-group.cc (apply_property_operations): new function. --- ChangeLog | 18 ++ Documentation/topdocs/NEWS.texi | 14 ++ input/regression/between-systems.ly | 21 +- input/regression/clefs.ly | 12 +- input/regression/staff-tweak.ly | 28 +-- input/test/slur-shape.ly | 52 ----- input/test/staff-lines.ly | 12 +- input/test/staff-size.ly | 46 ++-- lily/auto-change-iterator.cc | 2 +- lily/change-iterator.cc | 2 +- lily/context-specced-music-iterator.cc | 3 +- lily/include/translator-def.hh | 6 +- lily/include/translator-group.hh | 6 +- lily/my-lily-lexer.cc | 1 + lily/parser.yy | 286 ++++++++++++------------- lily/part-combine-music-iterator.cc | 8 +- lily/score-engraver.cc | 2 +- lily/score-performer.cc | 2 +- lily/simultaneous-music-iterator.cc | 2 +- lily/translator-def.cc | 44 +--- lily/translator-group.cc | 45 +++- scm/define-music-properties.scm | 2 + scm/define-translator-properties.scm | 2 +- scm/font.scm | 2 + 24 files changed, 293 insertions(+), 325 deletions(-) delete mode 100644 input/test/slur-shape.ly diff --git a/ChangeLog b/ChangeLog index 37762c395c..8374433d51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ +2004-01-07 Han-Wen Nienhuys + + * input/test/slur-shape.ly (x): remove file. + + * lily/translator-group.cc (apply_property_operations): new function. + 2004-01-06 Han-Wen Nienhuys + * lily/parser.yy (optional_prop_ops): allow \with { + PROPERTYSETTINGS } following \context or \new. + + * lily/my-lily-lexer.cc: add \with. + + * lily/parser.yy (property_operation): clean up definition of + property operations. + (property_op_to_music): new function. + (context_spec_music): new function + + * VERSION: 2.1.7 released. + * input/regression/collision-merge-dots.ly: new file. * lily/note-collision.cc (check_meshing_chords): if merging heads, diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index 887a273939..69cade5933 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -8,6 +8,20 @@ @chapter New features in 2.1 since 2.0 @itemize +@item Features of spanner contexts, like Staff, can now be changed easily: + +@example + \new Staff \with { + StaffSymbol \set #'line-count = #4 + } + { c'4 } +@end example + +@noindent +puts a quarter note C on a staff with 4 lines. + + + @item Multi measure rests are now truly centered between the clefs/barlines of the staff, independent of symbols on the other staffs. diff --git a/input/regression/between-systems.ly b/input/regression/between-systems.ly index 7d57707c37..cc763cb0d2 100644 --- a/input/regression/between-systems.ly +++ b/input/regression/between-systems.ly @@ -11,15 +11,22 @@ of course. } -% +#(define (set-page-break grob grob-c context) + (let* + ((meta (ly:get-grob-property grob 'meta)) + (name (cdr (assoc 'name meta)))) + + (if (equal? 'NonMusicalPaperColumn name) + (ly:set-grob-property! grob 'between-system-string "(pagebreak)\n\n")) +)) \score { -\notes \relative c' { c1 - - \context Score \applyoutput #(outputproperty-compatibility (make-type-checker 'paper-column-interface) 'between-system-string "(pagebreak)\n\n") + \notes \relative c' { + c1 + \context Score \applyoutput #set-page-break \break - -c1 } - + + c1 + } } diff --git a/input/regression/clefs.ly b/input/regression/clefs.ly index f3ca6dbc01..b0b3687edf 100644 --- a/input/regression/clefs.ly +++ b/input/regression/clefs.ly @@ -23,17 +23,11 @@ or below the clef respectively." \clef "varbaritone"c'1^"{varbaritone}" \bar "||" \clef "bass"c'1^"{bass}" \bar "||" \clef "subbass"c'1^"{subbass}" \bar "||" - \property Staff.Clef \override #'transparent = ##t - \clef "treble" c'1^"transparent=\#t" \bar "||" - \property Staff.Clef \override #'transparent = ##f - \context Staff \applyoutput #(outputproperty-compatibility (make-type-checker 'clef-interface) 'full-size-change #t) - \clef "french" c'1^"full-size-change = \#t" \bar "|." + \property Staff.Clef \override #'full-size-change = ##t + \clef "treble" c'1^"full-size-change = \#t" \bar "|." } \paper{ - \translator{ - \StaffContext -% Clef \override #'full-size-change = ##t - } + raggedright = ##t } } diff --git a/input/regression/staff-tweak.ly b/input/regression/staff-tweak.ly index d16c0c7bae..16fa8a227e 100644 --- a/input/regression/staff-tweak.ly +++ b/input/regression/staff-tweak.ly @@ -2,21 +2,23 @@ \header { texidoc = "The staff is a grob, and may be adjusted as well: this one shows a staff with 6 thick line, and a slightly large staffspace. -Beams remain correctly quantized. - -" +Beams remain correctly quantized." } -\score { \notes { - \property Score.StaffSymbol \set #'thickness = #2.0 - \property Score.StaffSymbol \set #'line-count = #6 - \property Score.StaffSymbol \set #'staff-space = #1.1 - c'4 g'4 b'8 b'8 b'8 b'8 -} - -\paper { raggedright = ##t +mus = \notes \relative c' { c4 g' d'8 d d d } - } - } +\score { + \notes << + \new Staff \mus + \new Staff \with { + StaffSymbol \set #'thickness = #2.0 + StaffSymbol \set #'line-count = #6 + StaffSymbol \set #'staff-space = #1.1 + } \mus + >> + \paper { + raggedright = ##t + } +} diff --git a/input/test/slur-shape.ly b/input/test/slur-shape.ly deleted file mode 100644 index cca222dd99..0000000000 --- a/input/test/slur-shape.ly +++ /dev/null @@ -1,52 +0,0 @@ -#(ly:set-option 'old-relative) -\version "1.9.8" -\header { - texidoc = "Slurs become flatter as they grow longer. " - -} - -x = { - \applyoutput #(outputproperty-compatibility (make-type-checker 'note-head-interface) - 'extra-offset '(-1 . 0)) -} - -\score { - \context Staff \notes\relative c << - \new Voice { \x f(f) } - \new Voice { \x g(s4g) } - \new Voice { \x a(s4*2a) } - \new Voice { \x b(s4*3b) } - \new Voice { \x c(s4*4c) } - \new Voice { \x d(s4*5d) } - \new Voice { \x e(s4*6e) } - \new Voice { \x f(s4*7f) } - \new Voice { \x g(s4*8g) } - \new Voice { \x a(s4*9a) } - \new Voice { \x b(s4*10b) } - \new Voice { \x c(s4*11c) } - \new Voice { \x d(s4*12d) } - \new Voice { \x e(s4*13e) } - \new Voice { \x f(s4*14f) } - \new Voice { \x g(s4*15g) } - \new Voice { \x a(s4*16a) } - \new Voice { \x b(s4*17b) } - \new Voice { \x c(s4*18c) } - \new Voice { \x d(s4*19d) } - \new Voice { \x e(s4*20e) } - \new Voice { \x f(s4*21f) } - \new Voice { \x g(s4*22g) } - \new Voice { \x a(s4*23a) } - \new Voice { \x b(s4*24b) } - \new Voice { \x c(s4*25c) } - \new Voice { \x d(s4*26d) } - >> - \paper { - raggedright = ##t - \translator{ - \VoiceContext - Slur \override #'direction = #1 - Stem \override #'direction = #-1 - } - } -} - diff --git a/input/test/staff-lines.ly b/input/test/staff-lines.ly index 406dd5c3bb..6418038c0c 100644 --- a/input/test/staff-lines.ly +++ b/input/test/staff-lines.ly @@ -2,30 +2,26 @@ \version "1.9.8" \header { texidoc="@cindex Staff Lines -Staff symbol property set workaround. " +Set staff symbol property. " } upper = \notes\relative c'' { - c1-"x" d-"x" e-"x" f-"x" + c1 d e f } lower = \notes\relative c { - c1-"x" b-"x" a-"x" g-"x" + c1 b a g } \score { \context PianoStaff << - %\time 4/4 \new Staff << \upper >> - \new Staff << + \new Staff \with { StaffSymbol \set #'line-count = #4 } << \clef bass \lower - \applyoutput #(outputproperty-compatibility - (make-type-checker 'staff-symbol-interface) - 'line-count 4) >> >> \paper { raggedright=##t} diff --git a/input/test/staff-size.ly b/input/test/staff-size.ly index ca02169a75..ffe5548d83 100644 --- a/input/test/staff-size.ly +++ b/input/test/staff-size.ly @@ -1,36 +1,38 @@ #(ly:set-option 'old-relative) -\version "1.9.8" +\version "2.1.6" \header { texidoc = "@cindex Staff Size Setting staff sizes is a little clumsy. There are two options: using @code{StaffContainer} and override/revert, or -@code{\applyoutput}. Both methods are shown in this example. " +@code{\applyoutput}. Both methods are shown in this example." } \score { - \notes \relative c' << \new StaffContainer { - \property StaffContainer.StaffSymbol \set #'staff-space = #(/ 16 20) - - \property Staff.fontSize = #-1 - \property Voice.fontSize = #-1 + \notes \relative c' << + \new StaffContainer { + \property StaffContainer.StaffSymbol \set #'staff-space = #(/ (* magstep magstep)) + \property Staff.fontSize = #-2 - \dynamicUp\stemDown - - %\key gis \major - c8 d e[ f g a] b c \ff - } - -\new Staff \relative c'' { \dynamicDown c,,4 \ff c c c } -\new Staff { - \context Staff \applyoutput #(outputproperty-compatibility (make-type-checker 'staff-symbol-interface) 'staff-space 0.8) - \property Staff.fontSize = #-1 - \clef bass - c8 c c c c c c c -} ->> -\paper { raggedright = ##t} + \dynamicUp\stemDown + + %\key gis \major + c8 d e[ f g a] b c \ff + } + + \new Staff \relative c'' { + \dynamicDown c,,4 \ff c c c + } + \new Staff \with { + fontSize = #-1 + StaffSymbol \set #'staff-space = #(/ magstep) + } { + \clef bass + c8 c c c c c c c + } + >> + \paper { raggedright = ##t} } diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 4bcb65314e..030e744440 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -47,7 +47,7 @@ Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, if (last) { Translator_group * dest = - it->report_to ()->find_create_translator (to_type_sym, to_id); + it->report_to ()->find_create_translator (to_type_sym, to_id, SCM_EOL); current->remove_translator (last); dest->add_used_group_translator (last); } diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index 7d458029c9..16e3f783a1 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -65,7 +65,7 @@ Change_iterator::process (Moment m) if (last) { Translator_group * dest = - report_to ()->find_create_translator (to_type, to_id); + report_to ()->find_create_translator (to_type, to_id, SCM_EOL); current->remove_translator (last); dest->add_used_group_translator (last); } diff --git a/lily/context-specced-music-iterator.cc b/lily/context-specced-music-iterator.cc index 15dc2ece07..c6751227bb 100644 --- a/lily/context-specced-music-iterator.cc +++ b/lily/context-specced-music-iterator.cc @@ -28,9 +28,10 @@ Context_specced_music_iterator::construct_children () SCM ci = get_music ()->get_mus_property ("context-id"); if (gh_string_p (ci)) c_id = ly_scm2string (ci); + SCM ops = get_music ()->get_mus_property ("property-operations"); Translator_group* a - = report_to ()->find_create_translator (ct, c_id); + = report_to ()->find_create_translator (ct, c_id, ops); if (a) set_translator (a); diff --git a/lily/include/translator-def.hh b/lily/include/translator-def.hh index 844bf8178c..167cf28551 100644 --- a/lily/include/translator-def.hh +++ b/lily/include/translator-def.hh @@ -46,10 +46,8 @@ public: void add_element (SCM name); void remove_element (SCM name); void add_last_element (SCM name); + void add_property_operation (SCM); - void add_push_property (SCM,SCM,SCM); - void add_pop_property (SCM,SCM); - void add_property_assign (SCM, SCM); Link_array path_to_acceptable_translator (SCM type_string, Music_output_def* odef) const; Translator_group * instantiate (Music_output_def*); @@ -58,7 +56,7 @@ public: static SCM make_scm () ; SCM clone_scm ()const; - void apply_property_operations (Translator_group*); + void apply_default_property_operations (Translator_group*); private: DECLARE_SMOBS (Translator_def,foo); diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 5a1fc1f6ea..b68f4b4ec2 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -52,7 +52,7 @@ public: VIRTUAL_COPY_CONS (Translator); Translator_group (Translator_group const &); Translator_group (); - void add_fresh_group_translator (Translator *trans); + void add_fresh_group_translator (Translator *trans, SCM ops); void add_used_group_translator (Translator *trans); /// Score_register = 0, Staff_registers = 1, etc) @@ -65,7 +65,7 @@ public: void check_removal (); // Translator *get_simple_translator (String) const; Translator_group *find_existing_translator (SCM context_name, String id); - Translator_group *find_create_translator (SCM context_name, String id); + Translator_group *find_create_translator (SCM context_name, String id, SCM ops); Link_array path_to_acceptable_translator (SCM alias, Music_output_def*) const; Translator_group*get_default_interpreter (); @@ -84,6 +84,6 @@ public: bool melisma_busy (Translator* tr); // where to put this? --hwn - +void apply_property_operations (Translator_group*tg, SCM pre_init_ops); #endif // TRANSLATOR_GROUP_HH diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 07ab9374a6..b631fe6be7 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -85,6 +85,7 @@ static Keyword_ent the_key_tab[]={ {"transpose", TRANSPOSE}, {"type", TYPE}, {"unset", UNSET}, + {"with", WITH}, {0,0} }; diff --git a/lily/parser.yy b/lily/parser.yy index ef36c806ea..4f267b9c70 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -84,6 +84,8 @@ TODO: #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x)) +Music *property_op_to_music (SCM op); +Music *context_spec_music (SCM type, SCM id, Music * m, SCM ops_); #define YYERROR_VERBOSE 1 @@ -300,7 +302,7 @@ yylex (YYSTYPE *s, void * v) %token TRANSPOSE %token TYPE %token UNSET - +%token WITH /* escaped */ %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE @@ -313,6 +315,7 @@ yylex (YYSTYPE *s, void * v) %type exclamations questions dots optional_rest %type bass_mod %type grace_head +%type prop_ops_body optional_prop_ops %type lyric_element %type bass_number br_bass_figure bass_figure figure_list figure_spec %token DIGIT @@ -377,8 +380,8 @@ yylex (YYSTYPE *s, void * v) %type embedded_scm scalar %type Music Sequential_music Simultaneous_music %type relative_music re_rhythmed_music part_combined_music -%type property_def translator_change simple_property_def -%type Music_list +%type music_property_def translator_change +%type Music_list property_operation %type music_output_def_body %type shorthand_command_req %type post_event tagged_post_event @@ -599,20 +602,8 @@ translator_spec_body: | translator_spec_body DESCRIPTION string { unsmob_translator_def ($$)->description_ = $3; } - | translator_spec_body STRING '=' embedded_scm { - unsmob_translator_def ($$)->add_property_assign ($2, $4); - } - | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm { - unsmob_translator_def ($$) - ->add_push_property (scm_string_to_symbol ($2), $4, $6); - } - | translator_spec_body STRING SET embedded_scm '=' embedded_scm { - unsmob_translator_def ($$) - ->add_push_property (scm_string_to_symbol ($2), $4, $6); - } - | translator_spec_body STRING REVERT embedded_scm { - unsmob_translator_def ($$)->add_pop_property ( - scm_string_to_symbol ($2), $4); + | translator_spec_body property_operation { + unsmob_translator_def ($$)->add_property_operation ($2); } | translator_spec_body NAME STRING { unsmob_translator_def ($$)->type_name_ = scm_string_to_symbol ($3); @@ -626,9 +617,14 @@ translator_spec_body: } | translator_spec_body GROBDESCRIPTIONS embedded_scm { Translator_def*td = unsmob_translator_def($$); - // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3); - for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p)) - td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p)); + + for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p)) { + SCM tag = gh_caar (p); + if (tag == ly_symbol2scm ("poppush")) + tag = ly_symbol2scm ("push"); + td->add_property_operation (scm_list_n (ly_symbol2scm ("assign"), + tag, ly_cdar (p), SCM_UNDEFINED)); + } } | translator_spec_body CONSISTSEND STRING { unsmob_translator_def ($$)->add_last_element ( $3); @@ -915,7 +911,7 @@ Simple_music: | MUSIC_IDENTIFIER { $$ = unsmob_music ($1); } - | property_def + | music_property_def | translator_change ; @@ -926,19 +922,25 @@ grace_head: | APPOGGIATURA { $$ = scm_makfrom0str ("Appoggiatura"); } ; -Composite_music: - CONTEXT STRING Music { - Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic"); - - csm->set_mus_property ("element", $3->self_scm ()); - scm_gc_unprotect_object ($3->self_scm ()); - - csm->set_mus_property ("context-type", scm_string_to_symbol ($2)); - csm->set_mus_property ("context-id", scm_makfrom0str ("")); +optional_prop_ops: + /* */ { + $$ = SCM_EOL; + } + | WITH '{' prop_ops_body '}' { + $$ = $3; + } + ; - $$ = csm; +prop_ops_body: + /* */ { $$ = SCM_EOL; } + | prop_ops_body property_operation { + $$ = gh_cons ($2, $1); } - | AUTOCHANGE STRING Music { + ; + + +Composite_music: + AUTOCHANGE STRING Music { Music*chm = MY_MAKE_MUSIC("AutoChangeMusic"); chm->set_mus_property ("element", $3->self_scm ()); chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc); @@ -1000,33 +1002,21 @@ basic music objects too, since the meaning is different. scm_gc_unprotect_object ($2->self_scm ()); #endif } - | CONTEXT string '=' string Music { - Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - - csm->set_mus_property ("element", $5->self_scm ()); - scm_gc_unprotect_object ($5->self_scm ()); + | CONTEXT string '=' string optional_prop_ops Music { + $$ = context_spec_music ($2, $4, $6, $5); - csm->set_mus_property ("context-type", scm_string_to_symbol ($2)); - csm->set_mus_property ("context-id", $4); - - $$ = csm; } - | NEWCONTEXT string Music { + | CONTEXT STRING optional_prop_ops Music { + $$ = context_spec_music ($2, SCM_UNDEFINED, $4, $3); + } + | NEWCONTEXT string optional_prop_ops Music { static int new_context_count; - Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - - csm->set_mus_property ("element", $3->self_scm ()); - scm_gc_unprotect_object ($3->self_scm ()); - - csm->set_mus_property ("context-type", scm_string_to_symbol ($2)); - char s[1024]; snprintf (s, 1024, "uniqueContext%d", new_context_count ++); SCM new_id = scm_makfrom0str (s); - csm->set_mus_property ("context-id", new_id); - $$ = csm; + $$ = context_spec_music ($2, new_id, $4, $3); } | TIMES { THIS->push_spot (); @@ -1172,112 +1162,37 @@ translator_change: } ; -property_def: - simple_property_def - | ONCE simple_property_def { - $$ = $2; - SCM e = $2->get_mus_property ("element"); - unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T); - } - ; - -simple_property_def: - PROPERTY STRING '.' STRING '=' scalar { - Music *t = set_property_music (scm_string_to_symbol ($4), $6); - Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - - csm->set_mus_property ("element", t->self_scm ()); - scm_gc_unprotect_object (t->self_scm ()); - $$ = csm; - $$->set_spot (THIS->here_input ()); - csm-> set_mus_property ("context-type", scm_string_to_symbol ($2)); +property_operation: + STRING '=' scalar { + $$ = scm_list_n (ly_symbol2scm ("assign"), + scm_string_to_symbol ($1), $3, SCM_UNDEFINED); } - | PROPERTY STRING '.' STRING UNSET { - - Music *t = MY_MAKE_MUSIC("PropertyUnset"); - t->set_mus_property ("symbol", scm_string_to_symbol ($4)); - - Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - csm->set_mus_property ("element", t->self_scm ()); - scm_gc_unprotect_object (t->self_scm ()); - - $$ = csm; - $$->set_spot (THIS->here_input ()); - - csm-> set_mus_property ("context-type", scm_string_to_symbol ($2)); + | STRING UNSET { + $$ = scm_list_n (ly_symbol2scm ("unset"), + scm_string_to_symbol ($1), SCM_UNDEFINED); } - | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm { - bool autobeam - = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings")); - bool itc = internal_type_checking_global_b; - Music *t = MY_MAKE_MUSIC("OverrideProperty"); - t->set_mus_property ("symbol", scm_string_to_symbol ($4)); - t->set_mus_property ("pop-first", SCM_BOOL_T); - if (autobeam) - internal_type_checking_global_b = false; - t->set_mus_property ("grob-property", $6); - if (autobeam) - internal_type_checking_global_b = itc; - t->set_mus_property ("grob-value", $8); - - Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - csm->set_mus_property ("element", t->self_scm ()); - scm_gc_unprotect_object (t->self_scm ()); - $$ = csm; - $$->set_spot (THIS->here_input ()); - - csm-> set_mus_property ("context-type", scm_string_to_symbol ($2)); + | STRING SET embedded_scm '=' embedded_scm { + $$ = scm_list_n (ly_symbol2scm ("poppush"), + scm_string_to_symbol ($1), $3, $5, SCM_UNDEFINED); } - | PROPERTY STRING '.' STRING OVERRIDE - embedded_scm '=' embedded_scm - { - /* - UGH UGH UGH UGH. - */ - bool autobeam - = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings")); - bool itc = internal_type_checking_global_b; - - Music *t = MY_MAKE_MUSIC("OverrideProperty"); - t->set_mus_property ("symbol", scm_string_to_symbol ($4)); - if (autobeam) - internal_type_checking_global_b = false; - t->set_mus_property ("grob-property", $6); - t->set_mus_property ("grob-value", $8); - if (autobeam) - internal_type_checking_global_b = itc; - - Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - csm->set_mus_property ("element", t->self_scm ()); - scm_gc_unprotect_object (t->self_scm ()); - - $$ = csm; - $$->set_spot (THIS->here_input ()); - - csm-> set_mus_property ("context-type", scm_string_to_symbol ($2)); - + | STRING OVERRIDE embedded_scm '=' embedded_scm { + $$ = scm_list_n (ly_symbol2scm ("push"), + scm_string_to_symbol ($1), $3, $5, SCM_UNDEFINED); } - | PROPERTY STRING '.' STRING REVERT embedded_scm { - Music *t = MY_MAKE_MUSIC("RevertProperty"); - - /* - UGH. - */ - bool autobeam - = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings")); - bool itc = internal_type_checking_global_b; + | STRING REVERT embedded_scm { + $$ = scm_list_n (ly_symbol2scm ("pop"), + scm_string_to_symbol ($1), $3, SCM_UNDEFINED); + } + ; - t->set_mus_property ("symbol", scm_string_to_symbol ($4)); - if (autobeam) - internal_type_checking_global_b = false; - t->set_mus_property ("grob-property", $6); - if (autobeam) - internal_type_checking_global_b = itc; - +music_property_def: + PROPERTY STRING '.' property_operation { + Music * t = property_op_to_music ($4); Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); - csm->set_mus_property ("element", t->self_scm ()); + + csm->set_mus_property ("element", t->self_scm ()); scm_gc_unprotect_object (t->self_scm ()); $$ = csm; @@ -1285,6 +1200,11 @@ simple_property_def: csm-> set_mus_property ("context-type", scm_string_to_symbol ($2)); } + | ONCE music_property_def { + $$ = $2; + SCM e = $2->get_mus_property ("element"); + unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T); + } ; @@ -2447,3 +2367,71 @@ My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid) return -1; } + +Music * +property_op_to_music (SCM op) +{ + Music * m = 0; + SCM tag = gh_car (op); + SCM symbol = gh_cadr (op); + SCM args = gh_cddr (op); + SCM grob_val = SCM_UNDEFINED; + SCM grob_sym = SCM_UNDEFINED; + SCM val = SCM_UNDEFINED; + + if (tag == ly_symbol2scm ("assign")) + { + m = MY_MAKE_MUSIC("PropertySet"); + val = gh_car (args); + } + else if (tag == ly_symbol2scm ("unset")) + m = MY_MAKE_MUSIC("PropertyUnset"); + else if (tag == ly_symbol2scm ("poppush") + || tag == ly_symbol2scm ("push")) + { + m = MY_MAKE_MUSIC("OverrideProperty"); + grob_sym = gh_car (args); + grob_val = gh_cadr (args); + } + else if (tag == ly_symbol2scm ("pop")) { + m = MY_MAKE_MUSIC("RevertProperty"); + grob_sym = gh_car (args); + } + + m->set_mus_property ("symbol", symbol); + if (val != SCM_UNDEFINED) + m->set_mus_property ("value", val); + if (grob_val != SCM_UNDEFINED) + m->set_mus_property ("grob-value", grob_val); + + if (grob_sym != SCM_UNDEFINED) + { + bool itc = internal_type_checking_global_b; + bool autobeam = gh_equal_p (symbol, ly_symbol2scm ("autoBeamSettings")); + if (autobeam) + internal_type_checking_global_b = false; + m->set_mus_property ("grob-property", grob_sym); + if (autobeam) + internal_type_checking_global_b = itc; + } + if (op == ly_symbol2scm ("poppush")) + m->set_mus_property ("pop-first", SCM_BOOL_T); + + + return m; +} + +Music* +context_spec_music (SCM type, SCM id, Music * m, SCM ops) +{ + Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic"); + + csm->set_mus_property ("element", m->self_scm ()); + scm_gc_unprotect_object (m->self_scm ()); + + csm->set_mus_property ("context-type", scm_string_to_symbol (type)); + csm->set_mus_property ("property-operations", ops); + csm->set_mus_property ("context-id", id); + return csm; +} + diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index e9bdc0ec42..2445ab315d 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -124,7 +124,7 @@ Part_combine_music_iterator::change_to (Music_iterator *it, SCM to_type, if (last) { Translator_group * dest = - it->report_to ()->find_create_translator (to_type, to_id); + it->report_to ()->find_create_translator (to_type, to_id, SCM_EOL); current->remove_translator (last); dest->add_used_group_translator (last); } @@ -172,7 +172,7 @@ Part_combine_music_iterator::get_state (Moment) SCM w = p->get_mus_property ("what"); - Translator_group *first_translator = first_iter_->report_to ()->find_create_translator (w, "one" + suffix_); + Translator_group *first_translator = first_iter_->report_to ()->find_create_translator (w, "one" + suffix_, SCM_EOL); SCM s = first_translator->get_property ("changeMoment"); if (!gh_pair_p (s)) @@ -399,8 +399,8 @@ s Consider thread switching: threads "one", "two" and "both". change_to (second_iter_, w, (combine_b ? "one" : "two") + suffix_); - Translator_group *first_translator = first_iter_->report_to ()->find_create_translator (w, "one" + suffix_); - Translator_group *second_translator = second_iter_->report_to ()->find_create_translator (w, "two" + suffix_); + Translator_group *first_translator = first_iter_->report_to ()->find_create_translator (w, "one" + suffix_, SCM_EOL); + Translator_group *second_translator = second_iter_->report_to ()->find_create_translator (w, "two" + suffix_, SCM_EOL); /* Hmm */ diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 94d5b6ae04..a6b5018b0c 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -102,7 +102,7 @@ Score_engraver::initialize () error (_f ("can't find `%s'", "feta20.afm") + "\n" +_ ("Fonts have not been installed properly. Aborting")); - unsmob_translator_def (definition_)->apply_property_operations (this); + unsmob_translator_def (definition_)->apply_default_property_operations (this); assert (dynamic_cast (output_def_)); assert (!daddy_trans_); diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 0cb5d00a8b..1c0af88cfc 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -112,7 +112,7 @@ Score_performer::get_output () void Score_performer::initialize () { - unsmob_translator_def (definition_)->apply_property_operations (this); + unsmob_translator_def (definition_)->apply_default_property_operations (this); assert (dynamic_cast (output_def_)); performance_ = new Performance; performance_->midi_ = dynamic_cast (output_def_); diff --git a/lily/simultaneous-music-iterator.cc b/lily/simultaneous-music-iterator.cc index 6a93ab7b0c..c59cab4cae 100644 --- a/lily/simultaneous-music-iterator.cc +++ b/lily/simultaneous-music-iterator.cc @@ -79,7 +79,7 @@ Simultaneous_music_iterator::construct_children () SCM name = unsmob_translator_def (report_to ()->definition_)->type_name_; Translator_group * t = (j && separate_contexts_b_) - ? report_to ()->find_create_translator (name, to_string (j)) + ? report_to ()->find_create_translator (name, to_string (j), SCM_EOL) : report_to (); if (!t) diff --git a/lily/translator-def.cc b/lily/translator-def.cc index 38457e2543..3873850d01 100644 --- a/lily/translator-def.cc +++ b/lily/translator-def.cc @@ -54,7 +54,6 @@ Translator_def::Translator_def () description_ = SCM_EOL; smobify_self(); - } Translator_def::~Translator_def () @@ -142,23 +141,15 @@ Translator_def::add_last_element (SCM s) { this->end_consists_name_list_ = modify_definition (this->end_consists_name_list_, s, true); } -void -Translator_def::add_push_property (SCM props, SCM syms, SCM vals) -{ - this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("push"), props, syms, vals, SCM_UNDEFINED), - this->property_ops_); -} void -Translator_def::add_pop_property (SCM props, SCM syms) +Translator_def::add_property_operation (SCM what) { - this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("push"), props, syms, SCM_UNDEFINED), - this->property_ops_); + this->property_ops_ = gh_cons (what, this->property_ops_); } - Link_array Translator_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* odef) const { @@ -176,7 +167,6 @@ Translator_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* o Link_array best_result; for (int i=0; i < accepteds.size (); i++) { - /* don't check aliases, because \context Staff should not create RhythmicStaff. */ @@ -261,31 +251,13 @@ Translator_def::instantiate (Music_output_def* md) return tg; } - void -Translator_def::apply_property_operations (Translator_group*tg) +Translator_def::apply_default_property_operations (Translator_group*tg) { - SCM correct_order = scm_reverse (property_ops_); // pity of the mem. - for (SCM s = correct_order; gh_pair_p (s); s = ly_cdr (s)) - { - SCM entry = ly_car (s); - SCM type = ly_car (entry); - entry = ly_cdr (entry); - - if (type == ly_symbol2scm ("push")) - { - SCM val = ly_cddr (entry); - val = gh_pair_p (val) ? ly_car (val) : SCM_UNDEFINED; - - tg->execute_pushpop_property (ly_car (entry), ly_cadr (entry), val); - } - else if (type == ly_symbol2scm ("assign")) - { - tg->internal_set_property (ly_car (entry), ly_cadr (entry)); - } - } + apply_property_operations (tg, property_ops_); } + SCM Translator_def::clone_scm () const { @@ -302,12 +274,6 @@ Translator_def::make_scm () return t->self_scm(); } -void -Translator_def::add_property_assign (SCM nm, SCM val) -{ - this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("assign"), scm_string_to_symbol (nm), val, SCM_UNDEFINED), - this->property_ops_); -} /* Default child context as a SCM string, or something else if there is diff --git a/lily/translator-group.cc b/lily/translator-group.cc index b9b3b33ded..aae7f5071f 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -86,15 +86,15 @@ Translator_group::add_used_group_translator (Translator *t) void -Translator_group::add_fresh_group_translator (Translator*t) +Translator_group::add_fresh_group_translator (Translator*t, SCM pre_init_ops) { Translator_group*tg = dynamic_cast (t); assert (tg); trans_group_list_ = add_translator (trans_group_list_,t); - unsmob_translator_def (tg->definition_)->apply_property_operations (tg); + unsmob_translator_def (tg->definition_)->apply_default_property_operations (tg); + apply_property_operations (tg, pre_init_ops); t->initialize (); - } @@ -123,7 +123,7 @@ Translator_group::find_existing_translator (SCM n, String id) Translator_group* -Translator_group::find_create_translator (SCM n, String id) +Translator_group::find_create_translator (SCM n, String id, SCM operations) { Translator_group * existing = find_existing_translator (n,id); if (existing) @@ -141,9 +141,14 @@ Translator_group::find_create_translator (SCM n, String id) { Translator_group * new_group = path[i]->instantiate (output_def_); + SCM ops = SCM_EOL; if (i == path.size () -1) - new_group->id_string_ = id; - current->add_fresh_group_translator (new_group); + { + new_group->id_string_ = id; + ops = operations; + } + + current->add_fresh_group_translator (new_group, ops); current = new_group; } @@ -152,7 +157,7 @@ Translator_group::find_create_translator (SCM n, String id) Translator_group *ret = 0; if (daddy_trans_) - ret = daddy_trans_->find_create_translator (n,id); + ret = daddy_trans_->find_create_translator (n, id, operations); else { warning (_f ("can't find or create `%s' called `%s'", ly_symbol2string (n).to_str0 (), id)); @@ -232,7 +237,7 @@ Translator_group::get_default_interpreter () t = unsmob_translator_def (this->definition_); } Translator_group *tg = t->instantiate (output_def_); - add_fresh_group_translator (tg); + add_fresh_group_translator (tg, SCM_EOL); if (!tg->is_bottom_translator_b ()) return tg->get_default_interpreter (); @@ -467,3 +472,27 @@ Translator_group::context_name () const Translator_def * td = unsmob_translator_def (definition_ ); return ly_symbol2string (td->type_name_); } + +void +apply_property_operations (Translator_group*tg, SCM pre_init_ops) +{ + SCM correct_order = scm_reverse (pre_init_ops); + for (SCM s = correct_order; gh_pair_p (s); s = ly_cdr (s)) + { + SCM entry = ly_car (s); + SCM type = ly_car (entry); + entry = ly_cdr (entry); + + if (type == ly_symbol2scm ("push") || type == ly_symbol2scm ("poppush")) + { + SCM val = ly_cddr (entry); + val = gh_pair_p (val) ? ly_car (val) : SCM_UNDEFINED; + + tg->execute_pushpop_property (ly_car (entry), ly_cadr (entry), val); + } + else if (type == ly_symbol2scm ("assign")) + { + tg->internal_set_property (ly_car (entry), ly_cadr (entry)); + } + } +} diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index 705706a735..5c75926ad0 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -72,6 +72,8 @@ For chord inversions, this is negative.") (music-property-description 'pop-first boolean? "Do a revert before we try to do a override on some grob property.") (music-property-description 'procedure procedure? "The function to run with \\applycontext. It must take a single argument, being the context.") +(music-property-description 'property-operations list? + "Do these operations for instantiating the context.") (music-property-description 'predicate procedure? "the predicate of a \outputproperty") (music-property-description 'type symbol? "The type of this music object. Determines iteration in some cases.") (music-property-description 'types list? "The types of this music object. Determines iteration in some cases.") diff --git a/scm/define-translator-properties.scm b/scm/define-translator-properties.scm index 6f1342ae38..f40bb957ed 100644 --- a/scm/define-translator-properties.scm +++ b/scm/define-translator-properties.scm @@ -406,7 +406,7 @@ is erased. (translator-property-description 'stringTunings list? "The tablature strings tuning. Must be a list of the different semitons pitch of each string (starting by the lower one).") (translator-property-description 'subdivideBeams boolean? "If set, multiple beams will be subdivided at beat positions - by only drawing one beam over the beat.") -(translator-property-description 'systemStartDelimiter symbol? "Which grob to make for the start of the system/staff?") +(translator-property-description 'systemStartDelimiter symbol? "Which grob to make for the start of the system/staff? Set to @code{SystemStartBrace}, @code{SystemStartBracket} or @code{SystemStartBar}.") (translator-property-description 'tablatureFormat procedure? "Function formatting a tab notehead; it takes a string number, a list of string tunings and Pitch object. It returns the text as a string.") diff --git a/scm/font.scm b/scm/font.scm index 0592c0110a..afa6631f6d 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -29,6 +29,8 @@ or " +(define-public magstep (exp (* (/ 1 6) (log 2)))) + (define-public paper20-font-vector '((#(medium upright number) . -- 2.39.2