X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fa2-engraver.cc;h=a08d9e0765428b4dcff58ae69caf2589ec466b4a;hb=d9b43b93f2c885409bafdb157138158f65cc49aa;hp=ee33e68d75f4e3353fbead06625b376039cce5b3;hpb=4975901229a1b074f6c93d812e15d653aa8e2952;p=lilypond.git diff --git a/lily/a2-engraver.cc b/lily/a2-engraver.cc index ee33e68d75..a08d9e0765 100644 --- a/lily/a2-engraver.cc +++ b/lily/a2-engraver.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2000 Jan Nieuwenhuizen + (c) 2000--2002 Jan Nieuwenhuizen */ #include "engraver.hh" @@ -14,25 +14,22 @@ #include "translator-group.hh" #include "side-position-interface.hh" #include "directional-element-interface.hh" +#include "multi-measure-rest.hh" class A2_engraver : public Engraver { -public: - A2_engraver (); - VIRTUAL_COPY_CONS (Translator); - -protected: - virtual void do_process_music (); - virtual void acknowledge_element (Score_element_info); - - virtual void do_pre_move_processing (); + TRANSLATOR_DECLARATIONS(A2_engraver); +protected: + virtual void acknowledge_grob (Grob_info); + virtual void create_grobs (); + virtual void stop_translation_timestep (); private: Item* text_p_; enum State { SOLO, SPLIT_INTERVAL, UNIRHYTHM, UNISILENCE, UNISON } state_; }; -ADD_THIS_TRANSLATOR (A2_engraver); + A2_engraver::A2_engraver () { @@ -41,7 +38,7 @@ A2_engraver::A2_engraver () } void -A2_engraver::do_process_music () +A2_engraver::create_grobs () { if (!to_boolean (get_property ("combineParts"))) return ; @@ -54,18 +51,18 @@ A2_engraver::do_process_music () if (solo_adue == SCM_BOOL_T && ((solo == SCM_BOOL_T && state_ != SOLO) || (unison == SCM_BOOL_T && state_ != UNISON - && daddy_trans_l_->id_str_ == "one"))) + && daddy_trans_l_->id_str_.left_str (3) == "one"))) { text_p_ = new Item (get_property ("TextScript")); - Side_position::set_axis (text_p_, Y_AXIS); - announce_element (text_p_, 0); + Side_position_interface::set_axis (text_p_, Y_AXIS); + announce_grob (text_p_, 0); Direction dir = UP; - SCM text; + SCM text = SCM_EOL; if (solo == SCM_BOOL_T) { state_ = SOLO; - if (daddy_trans_l_->id_str_ == "one") + if (daddy_trans_l_->id_str_.left_str (3) == "one") { text = get_property ("soloText"); } @@ -78,35 +75,35 @@ A2_engraver::do_process_music () else if (unison == SCM_BOOL_T) { state_ = UNISON; - if (daddy_trans_l_->id_str_ == "one") + if (daddy_trans_l_->id_str_.left_str (3) == "one") text = get_property ("aDueText"); } - Side_position::set_direction (text_p_, dir); - text_p_->set_elt_property ("text", text); + Side_position_interface::set_direction (text_p_, dir); + text_p_->set_grob_property ("text", text); } } } void -A2_engraver::acknowledge_element (Score_element_info i) +A2_engraver::acknowledge_grob (Grob_info i) { if (!to_boolean (get_property ("combineParts"))) return ; if (text_p_) { - if (Note_head::has_interface (i.elem_l_)) + if (Note_head::has_interface (i.grob_l_)) { - Score_element*t = text_p_; - Side_position::add_support (t, i.elem_l_); - if (Side_position::get_axis (t) == X_AXIS - && !t->parent_l (Y_AXIS)) - t->set_parent (i.elem_l_, Y_AXIS); + Grob*t = text_p_; + Side_position_interface::add_support (t, i.grob_l_); + if (Side_position_interface::get_axis (t) == X_AXIS + && !t->get_parent (Y_AXIS)) + t->set_parent (i.grob_l_, Y_AXIS); } - if (Stem::has_interface (i.elem_l_)) + if (Stem::has_interface (i.grob_l_)) { - Side_position::add_support (text_p_, i.elem_l_); + Side_position_interface::add_support (text_p_, i.grob_l_); } } @@ -131,12 +128,33 @@ A2_engraver::acknowledge_element (Score_element_info i) state_ = SPLIT_INTERVAL; else if (unirhythm) state_ = UNIRHYTHM; + + Direction d = CENTER; + if (daddy_trans_l_->id_str_.left_str (3) == "one") + d = UP; + else if (daddy_trans_l_->id_str_.left_str (3) == "two") + d = DOWN; + + /* Must only set direction for VoiceCombines, not for StaffCombines: + we can't detect that here, so, ugh, yet another property */ + if (!to_boolean (get_property ("noDirection")) + && (Stem::has_interface (i.grob_l_) + || Slur::has_interface (i.grob_l_) + // || Tie::has_interface (i.grob_l_) + || i.grob_l_->has_interface (ly_symbol2scm ("tie-interface")) - if (Stem::has_interface (i.elem_l_) - || Slur::has_interface (i.elem_l_) - // || Text_item::has_interface (i.elem_l_) - //|| Hairpin::has_interface (i.elem_l_) - ) + /* + Usually, dynamics are removed by *_devnull_engravers for the + second voice. On the one hand, we don't want all dynamics for + the first voice to be placed above the staff. On the other + hand, colliding of scripts may be worse. + So, we don't set directions for these when we're playing solo. + */ + || (i.grob_l_->has_interface (ly_symbol2scm ("dynamic-interface")) + && state_ != SOLO) + || (i.grob_l_->has_interface (ly_symbol2scm ("text-interface")) + && state_ != SOLO) + )) { /* Hmm. We must set dir when solo, in order to get @@ -147,26 +165,48 @@ A2_engraver::acknowledge_element (Score_element_info i) || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T))) { - if (daddy_trans_l_->id_str_ == "one") - { - i.elem_l_->set_elt_property ("direction", gh_int2scm (1)); - } - else if (daddy_trans_l_->id_str_ == "two") - { - i.elem_l_->set_elt_property ("direction", gh_int2scm (-1)); - } + + /* + Blunt axe method: every grob gets a propertysetting. + */ + i.grob_l_->set_grob_property ("direction", gh_int2scm (d)); } } + + /* + todo: should we have separate state variable for being "rest while + other has solo?" */ + if ( Multi_measure_rest::has_interface (i.grob_l_) && d ) + if (state_ == UNIRHYTHM + && unisilence != SCM_BOOL_T) + { + i.grob_l_->set_grob_property ("staff-position", gh_int2scm (d * 6)); + } } void -A2_engraver::do_pre_move_processing () +A2_engraver::stop_translation_timestep () { if (text_p_) { - Side_position::add_staff_support (text_p_); - typeset_element (text_p_); + Side_position_interface::add_staff_support (text_p_); + typeset_grob (text_p_); text_p_ = 0; } } +ENTER_DESCRIPTION(A2_engraver, +/* descr */ "Part combine engraver for orchestral scores. + +The markings @emph{a2}, @emph{Solo} and @emph{Solo II}, are +created by this engraver. It also acts upon instructions of the part +combiner. Another thing that the this engraver, is forcing of stem, +slur and tie directions, always when both threads are not identical; +up for the musicexpr called @code{one}, down for the musicexpr called +@code{two}. + +", +/* creats*/ "TextScript", +/* acks */ "grob-interface tie-interface note-head-interface ", +/* reads */ "combineParts noDirection soloADue soloText soloIIText aDueText split-interval unison solo unisilence unirhythm", +/* write */ "");