X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpiano-pedal-engraver.cc;h=9d76fb4c5df0fb41468475d478823c8d2f5589f2;hb=89bf299597169eeaa5ed7a215b6e808fa849c8cd;hp=b8a69703a7f9a9e985ca67bf98d6bdaa217b2611;hpb=f5e5c04d731e93b1d8d4cf7e7697f71f6e7c2bdf;p=lilypond.git diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index b8a69703a7..9d76fb4c5d 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -8,32 +8,16 @@ #include "engraver.hh" #include "musical-request.hh" -#include "score-element.hh" +#include "grob.hh" #include "item.hh" -#include "lookup.hh" #include "lily-guile.hh" -#include "note-head.hh" +#include "rhythmic-head.hh" #include "stem.hh" #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" -#include "text-item.hh" -#include "sustain-pedal.hh" +#include "item.hh" -/* - TODO: - * it would be really cool if an engraver could be initialised with a - string, ie: - Piano_pedal_engraver::"sostenuto" - Piano_pedal_engraver::"sustain" - Piano_pedal_engraver::"una-chorda" - - */ - -/* - Would it? The semantics are unclear, and real benefits are muddy - too. --hwn -*/ @@ -47,12 +31,12 @@ public: Piano_pedal_engraver (); ~Piano_pedal_engraver (); protected: - virtual void do_creation_processing (); - virtual bool do_try_music (Music*); - virtual void do_process_music (); - virtual void do_pre_move_processing (); - virtual void do_post_move_processing (); - virtual void acknowledge_element (Score_element_info); + virtual void initialize (); + virtual bool try_music (Music*); + virtual void stop_translation_timestep (); + virtual void start_translation_timestep (); + virtual void acknowledge_grob (Grob_info); + virtual void create_grobs (); private: struct Pedal_info @@ -74,7 +58,7 @@ Piano_pedal_engraver::Piano_pedal_engraver () info_list_ = 0; } void -Piano_pedal_engraver::do_creation_processing() +Piano_pedal_engraver::initialize() { info_list_ = new Pedal_info[4]; Pedal_info *p = info_list_; @@ -101,43 +85,43 @@ Piano_pedal_engraver::~Piano_pedal_engraver() } /* - Urg: Code dup - I'm a script - */ + Urg: Code dup + I'm a script + */ void -Piano_pedal_engraver::acknowledge_element (Score_element_info info) +Piano_pedal_engraver::acknowledge_grob (Grob_info info) { - for (Pedal_info*p = info_list_; p->name_; p ++) + for (Pedal_info*p = info_list_; p && p->name_; p ++) { if (p->item_p_) { - if (Note_head* n = dynamic_cast (info.elem_l_)) + if (Rhythmic_head::has_interface (info.elem_l_)) { - Side_position_interface st (p->item_p_); - st.add_support (n); - if (st.get_axis( ) == X_AXIS + Side_position::add_support (p->item_p_, info.elem_l_); + + if (Side_position::get_axis(p->item_p_) == X_AXIS && !p->item_p_->parent_l (Y_AXIS)) - p->item_p_->set_parent (n, Y_AXIS); + p->item_p_->set_parent (info.elem_l_, Y_AXIS); } - if (Stem* s = dynamic_cast (info.elem_l_)) + if (Stem::has_interface (info.elem_l_)) { - Side_position_interface st (p->item_p_); - st.add_support (s); + Side_position::add_support (p->item_p_,info.elem_l_); } } } } bool -Piano_pedal_engraver::do_try_music (Music *m) +Piano_pedal_engraver::try_music (Music *m) { if (Span_req * s = dynamic_cast(m)) { for (Pedal_info*p = info_list_; p->name_; p ++) { - if (s->span_type_str_ == p->name_) + if (scm_equal_p (s->get_mus_property ("span-type"), + ly_str02scm (p->name_))==SCM_BOOL_T) { - p->req_l_drul_[s->span_dir_] = s; + p->req_l_drul_[s->get_span_dir()] = s; return true; } } @@ -146,20 +130,22 @@ Piano_pedal_engraver::do_try_music (Music *m) } void -Piano_pedal_engraver::do_process_music () +Piano_pedal_engraver::create_grobs () { - for (Pedal_info*p = info_list_; p->name_; p ++) + for (Pedal_info*p = info_list_; p && p->name_; p ++) { - SCM s = SCM_UNDEFINED; + if (p->item_p_) + continue; + SCM s = SCM_EOL; if (p->req_l_drul_[STOP] && p->req_l_drul_[START]) { if (!p->start_req_l_) { - p->req_l_drul_[STOP]->warning (_f ("can't find start of piano pedal: %s", p->name_ )); + p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: %s", p->name_ )); } else { - s = get_property ("stopStart" + String (p->name_ )); + s = get_property (("stopStart" + String (p->name_ )).ch_C()); } p->start_req_l_ = p->req_l_drul_[START]; } @@ -167,50 +153,38 @@ Piano_pedal_engraver::do_process_music () { if (!p->start_req_l_) { - p->req_l_drul_[STOP]->warning (_f ("can't find start of piano pedal: %s", p->name_ )); + p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: %s", p->name_ )); } else { - s = get_property ("stop" + String (p->name_ )); + s = get_property (("stop" + String (p->name_ )).ch_C()); } p->start_req_l_ = 0; } else if (p->req_l_drul_[START]) { p->start_req_l_ = p->req_l_drul_[START]; - s = get_property ("start" + String (p->name_ )); + s = get_property (("start" + String (p->name_ )).ch_C()); } if (gh_string_p (s)) { - if (p->name_ == String ("Sustain")) - { - // fixme: Item should be sufficient. - p->item_p_ = new Text_item (get_property ("basicSustainPedalProperties")); - } - else - { - p->item_p_ = new Text_item (get_property ("basicPedalProperties")); - } - p->item_p_->set_elt_property ("text", s); - // guh - - Side_position_interface si (p->item_p_); - si.set_axis (Y_AXIS); - - // todo: init with basic props. - p->item_p_->add_offset_callback (Side_position_interface::aligned_on_self, X_AXIS); - p->item_p_->add_offset_callback (Side_position_interface::centered_on_parent, X_AXIS); - announce_element (Score_element_info (p->item_p_, - p->req_l_drul_[START] - ? p->req_l_drul_[START] - : p->req_l_drul_[STOP])); + String propname = String (p->name_) + "Pedal"; + p->item_p_ = new Item (get_property (propname.ch_C())); + p->item_p_->set_grob_property ("text", s); + + announce_grob (p->item_p_, + p->req_l_drul_[START] + ? p->req_l_drul_[START] + : p->req_l_drul_[STOP]); } + p->req_l_drul_[START] = 0; + p->req_l_drul_[STOP] = 0; } } void -Piano_pedal_engraver::do_pre_move_processing () +Piano_pedal_engraver::stop_translation_timestep () { Item * sustain = 0; for (Pedal_info*p = info_list_; p->name_; p ++) @@ -223,7 +197,7 @@ Piano_pedal_engraver::do_pre_move_processing () { if (p->item_p_) { - Side_position_interface (p->item_p_).add_staff_support (); + Side_position::add_staff_support (p->item_p_); /* Hmm. */ @@ -231,18 +205,17 @@ Piano_pedal_engraver::do_pre_move_processing () { if (sustain) { - Side_position_interface st (p->item_p_); - st.add_support (sustain); + Side_position::add_support (p->item_p_,sustain); } } - typeset_element (p->item_p_); + typeset_grob (p->item_p_); } p->item_p_ = 0; } } void -Piano_pedal_engraver::do_post_move_processing () +Piano_pedal_engraver::start_translation_timestep () { for (Pedal_info*p = info_list_; p->name_; p ++) {