X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdynamic-engraver.cc;h=408fde144e29bf9eeb674b211d578b8bc14160c4;hb=875cf3061b68867a109cdaf52c93be868a3e01be;hp=dd36db400b7215294dea6a6ba2df4acad8ba43ed;hpb=afa5829cd270e1b0c616b7ba5c5e6cdc0e920e5f;p=lilypond.git diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index dd36db400b..408fde144e 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -3,20 +3,18 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1999 Han-Wen Nienhuys */ #include "debug.hh" #include "crescendo.hh" -#include "dynamic-engraver.hh" #include "musical-request.hh" -#include "text-item.hh" #include "lookup.hh" #include "paper-def.hh" #include "score-column.hh" -#include "staff-sym.hh" +#include "staff-symbol.hh" #include "note-column.hh" -#include "g-text-item.hh" -#include "g-staff-side.hh" +#include "text-item.hh" +#include "staff-side.hh" #include "engraver.hh" #include "stem.hh" #include "note-head.hh" @@ -26,13 +24,12 @@ */ class Dynamic_engraver : public Engraver { - G_text_item * text_p_; - G_staff_side_item * staff_side_p_; - + Text_item * text_p_; Crescendo * to_end_cresc_p_; Crescendo * cresc_p_; - Span_dynamic_req * cresc_req_l_; - Array dynamic_req_l_arr_; + + Span_req * cresc_req_l_; + Array dynamic_req_l_arr_; void typeset_all (); public: VIRTUAL_COPY_CONS(Translator); @@ -53,8 +50,9 @@ Dynamic_engraver::Dynamic_engraver() { do_post_move_processing(); text_p_ =0; - staff_side_p_ =0; + to_end_cresc_p_ = cresc_p_ = 0; + cresc_req_l_ = 0; } @@ -65,83 +63,110 @@ Dynamic_engraver::do_post_move_processing() } bool -Dynamic_engraver::do_try_music (Music * r) +Dynamic_engraver::do_try_music (Music * m) { - if(Dynamic_req * d = dynamic_cast (r)) + Request * r = dynamic_cast (m); + + if(Text_script_req * d = dynamic_cast (r)) { - for (int i=0; i < dynamic_req_l_arr_.size (); i++) - if (d->equal_b (dynamic_req_l_arr_[i])) - return true; - - dynamic_req_l_arr_.push (d); - return true; + if (d->style_str_ != "dynamic") + return false; } - return false; + else if (Span_req * s = dynamic_cast (r)) + { + if (s-> span_type_str_ != "crescendo" + && s->span_type_str_ != "decrescendo") + return false; + } + else + return false; + + for (int i=0; i < dynamic_req_l_arr_.size (); i++) + if (r->equal_b (dynamic_req_l_arr_[i])) + return true; + + dynamic_req_l_arr_.push (r); + return true; } + + void Dynamic_engraver::do_process_requests() { Crescendo* new_cresc_p=0; + for (int i=0; i < dynamic_req_l_arr_.size(); i++) { - Dynamic_req *dreq_l = dynamic_req_l_arr_[i]; - if (Absolute_dynamic_req *absd = dynamic_cast (dreq_l)) + if (Text_script_req *absd = + dynamic_cast ( dynamic_req_l_arr_[i])) { if (text_p_) { - dynamic_req_l_arr_[i]->warning (_("Got a dynamic already. Continuing dazed and confused")); + dynamic_req_l_arr_[i]->warning (_("Got a dynamic already. Continuing dazed and confused.")); continue; } - String loud = absd->loudness_str (); + String loud = absd->text_str_; - text_p_ = new G_text_item; - text_p_->text_str_ = paper ()->lookup_l (0)->dynamic (loud).str_; - Scalar prop = get_property ("dynamicStyle", 0); + text_p_ = new Text_item; + text_p_->text_str_ = loud; // ugh + text_p_->set_elt_property ("style", gh_str02scm ("dynamic")); + text_p_->set_elt_property ("script-priority", + gh_int2scm (100)); + Side_position_interface (text_p_).set_axis (Y_AXIS); - text_p_->style_str_ = prop.length_i () ? prop : "dynamic"; - - staff_side_p_ = new G_staff_side_item; - staff_side_p_->set_victim (text_p_); + if (absd->get_direction ()) + { + text_p_->set_elt_property ("direction", gh_int2scm (absd->get_direction ())); + } + - prop = get_property ("dynamicDir", 0); - if (prop.isnum_b ()) + /* + UGH UGH + */ + SCM prop = get_property ("dynamicDirection", 0); + if (!isdir_b (prop)) { - staff_side_p_->dir_ = (Direction) (int) prop; + prop = get_property ("verticalDirection", 0); } + if (isdir_b (prop) && to_dir (prop)) + text_p_->set_elt_property ("direction", prop); + - announce_element (Score_element_info (text_p_, dreq_l)); - announce_element (Score_element_info (staff_side_p_, dreq_l)); + prop = get_property ("dynamicPadding", 0); + if (gh_number_p(prop)) + { + text_p_->set_elt_property ("padding", prop); + } + announce_element (Score_element_info (text_p_, absd)); } - else if (Span_dynamic_req *span_l = dynamic_cast (dreq_l)) + else if (Span_req *span_l + = dynamic_cast (dynamic_req_l_arr_[i])) { - if (span_l->spantype_ == STOP) + if (span_l->span_dir_ == STOP) { if (!cresc_p_) { - span_l->warning (_ ("can't find (de)crescendo to end")); + span_l->warning (_ ("Can't find (de)crescendo to end")); } else { assert (!to_end_cresc_p_); to_end_cresc_p_ =cresc_p_; - cresc_p_ = 0; - Scalar prop = get_property ("dynamicDir", 0); - if (prop.isnum_b ()) - { - to_end_cresc_p_->dir_ = (Direction) (int) prop; - } + cresc_p_ = 0; } } - else if (span_l->spantype_ == START) + else if (span_l->span_dir_ == START) { cresc_req_l_ = span_l; assert (!new_cresc_p); new_cresc_p = new Crescendo; - new_cresc_p->grow_dir_ = span_l->dynamic_dir_; + new_cresc_p->grow_dir_ = (span_l->span_type_str_ == "crescendo") ? BIGGER : SMALLER; + + Side_position_interface (new_cresc_p).set_axis (Y_AXIS); announce_element (Score_element_info (new_cresc_p, span_l)); } } @@ -153,11 +178,13 @@ Dynamic_engraver::do_process_requests() { ::warning (_ ("Too many crescendi here")); typeset_element (cresc_p_); + cresc_p_ = 0; } cresc_p_ = new_cresc_p; - cresc_p_->set_bounds(LEFT,get_staff_info().musical_l ()); + cresc_p_->set_bounds(LEFT,get_staff_info().musical_pcol_l ()); + if (text_p_) { cresc_p_->dyn_b_drul_[LEFT] = true; @@ -170,13 +197,6 @@ Dynamic_engraver::do_process_requests() void Dynamic_engraver::do_pre_move_processing() { - Staff_symbol* s_l = get_staff_info().staff_sym_l_; - if (to_end_cresc_p_) - to_end_cresc_p_->add_support (s_l); - if (staff_side_p_) - staff_side_p_->add_support (s_l); - - typeset_all (); } @@ -202,16 +222,18 @@ Dynamic_engraver::typeset_all () { if (to_end_cresc_p_) { - to_end_cresc_p_->set_bounds(RIGHT,get_staff_info().musical_l ()); + to_end_cresc_p_->set_bounds(RIGHT,get_staff_info().musical_pcol_l ()); + typeset_element (to_end_cresc_p_); + to_end_cresc_p_ =0; + } + if (text_p_) { typeset_element (text_p_); - typeset_element (staff_side_p_); text_p_ =0; - staff_side_p_ =0; } } @@ -223,13 +245,14 @@ Dynamic_engraver::acknowledge_element (Score_element_info i) || dynamic_cast (i.elem_l_) ) { - if (staff_side_p_) - staff_side_p_->add_support (i.elem_l_); + if (text_p_) + Side_position_interface (text_p_).add_support (i.elem_l_); if (to_end_cresc_p_) - to_end_cresc_p_->add_support (i.elem_l_); + Side_position_interface (to_end_cresc_p_).add_support (i.elem_l_); if (cresc_p_) - cresc_p_->add_support (i.elem_l_); + Side_position_interface(cresc_p_).add_support (i.elem_l_); } } +