X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstem-engraver.cc;h=296422cfea1d11d03fb87c75c8bfa80e3c078510;hb=670a98f23a2561c6a4a4a19bb72c776189715541;hp=b8f3984c5b4355c2131e3a90f00bc31e4e0fc7b5;hpb=615a9212789c2cb2994748c023d0e19f3a83a0fd;p=lilypond.git diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index b8f3984c5b..296422cfea 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1999 Han-Wen Nienhuys */ #include "stem-engraver.hh" @@ -12,7 +12,9 @@ #include "musical-request.hh" #include "duration-convert.hh" #include "misc.hh" -#include "abbrev.hh" +#include "stem-tremolo.hh" +#include "staff-info.hh" +#include "translator-group.hh" Stem_engraver::Stem_engraver() { @@ -20,13 +22,13 @@ Stem_engraver::Stem_engraver() stem_p_ = 0; abbrev_p_ = 0; default_abbrev_i_ = 16; - dir_ = CENTER; + rhythmic_req_l_ =0; } void Stem_engraver::do_creation_processing () { - Scalar prop = get_property ("abbrev"); + Scalar prop = get_property ("abbrev", 0); if (prop.isnum_b ()) { default_abbrev_i_ = prop; @@ -36,22 +38,23 @@ Stem_engraver::do_creation_processing () void Stem_engraver::acknowledge_element(Score_element_info i) { - if (dynamic_cast (i.elem_l_)) + if (Rhythmic_head * h = dynamic_cast (i.elem_l_)) { - Rhythmic_head *h = dynamic_cast (i.elem_l_); + if (h->stem_l_) + return; + + Rhythmic_req * r = dynamic_cast (i.req_l_); + int duration_log = r->duration_.durlog_i_; if (!stem_p_) { - Rhythmic_req * r = dynamic_cast (i.req_l_); stem_p_ = new Stem; - int durlog_i = r->duration_.durlog_i_; - stem_p_->flag_i_ = durlog_i; + stem_p_->flag_i_ = duration_log; - if (abbrev_req_l_) { /* suggests typing of: - c8:16 c: c: c: + c8:16 c: c: c: hmm, which isn't so bad? */ int t = abbrev_req_l_->type_i_; @@ -62,15 +65,21 @@ Stem_engraver::acknowledge_element(Score_element_info i) if (t) { - abbrev_p_ = new Abbreviation; + abbrev_p_ = new Stem_tremolo; announce_element (Score_element_info (abbrev_p_, abbrev_req_l_)); - abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (durlog_i>? 2); + abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (duration_log>? 2); } } // must give the request, to preserve the rhythmic info. announce_element (Score_element_info (stem_p_, r)); } + + if (stem_p_->flag_i_ != duration_log) + { + r->warning (_f("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_)); + } + stem_p_->add_head (h); } } @@ -84,16 +93,43 @@ Stem_engraver::do_pre_move_processing() typeset_element (abbrev_p_); abbrev_p_ = 0; } + if (stem_p_) { - Scalar prop = get_property ("ydirection"); - dir_ = prop.isnum_b () ? (Direction)int(prop) : CENTER; - if (dir_) + Scalar prop = get_property ("verticalDirection", 0); + Direction dir = prop.isnum_b () ? (Direction)int(prop) : CENTER; + if (dir) + { + stem_p_->dir_ = dir; + stem_p_->set_elt_property (dir_forced_scm_sym, SCM_BOOL_T); + } + + Translator_group const *which; + prop = get_property ("stemLeftBeamCount", &which); + if (prop.isnum_b ()) + { + stem_p_->beams_i_drul_[LEFT] = prop; + ((Translator_group*)which)->set_property ("stemLeftBeamCount", ""); + } + prop = get_property ("stemRightBeamCount", &which); + if (prop.isnum_b ()) { - stem_p_->dir_ = dir_; - stem_p_->dir_forced_b_ = true; + stem_p_->beams_i_drul_[RIGHT] = prop; + ((Translator_group*)which)->set_property ("stemRightBeamCount", ""); } + prop = get_property ("stemLength", 0); + if (prop.isnum_b ()) + { + stem_p_->set_elt_property (length_scm_sym, gh_double2scm (prop.to_f ())); + } + + prop = get_property ("stemStyle", 0); + if (prop.to_bool ()) + { + stem_p_->set_elt_property (style_scm_sym, gh_str02scm (prop.ch_C())); + } + typeset_element(stem_p_); stem_p_ = 0; } @@ -103,17 +139,12 @@ Stem_engraver::do_pre_move_processing() bool Stem_engraver::do_try_music (Music* r) { - Musical_req* mus_l = dynamic_cast (r); - if (!mus_l) - return false; - - Abbreviation_req* a = dynamic_cast (mus_l); - if (!a) - return false; - - abbrev_req_l_ = a; - - return true; + if (Tremolo_req* a = dynamic_cast (r)) + { + abbrev_req_l_ = a; + return true; + } + return false; }