X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpiano-pedal-engraver.cc;h=2a2d2aa8ec5b417081fb09f8f1a31ba8e7de9f19;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=4cbc7adbd320abd22cd789ac0b584bfa8b30b9bf;hpb=4a401ca1c60f428daa242dbdd102fdb3f327ebfb;p=lilypond.git diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 4cbc7adbd3..2a2d2aa8ec 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2000--2011 Jan Nieuwenhuizen , + Copyright (C) 2000--2015 Jan Nieuwenhuizen , Erik Sandberg Chris Jackson - extended to support @@ -123,10 +123,9 @@ public: protected: virtual void initialize (); virtual void finalize (); - DECLARE_TRANSLATOR_LISTENER (sustain); - DECLARE_TRANSLATOR_LISTENER (una_corda); - DECLARE_TRANSLATOR_LISTENER (sostenuto); - DECLARE_ACKNOWLEDGER (note_column); + void listen_sustain (Stream_event *); + void listen_una_corda (Stream_event *); + void listen_sostenuto (Stream_event *); void stop_translation_timestep (); void process_music (); @@ -167,9 +166,9 @@ init_pedal_types () be careful, as we don't want to loose references to the _sym_ members. */ Pedal_type_info info; - info.event_class_sym_ = scm_from_locale_symbol ((base_ident + "-event").c_str ()); - info.style_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Style").c_str ()); - info.strings_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Strings").c_str ()); + info.event_class_sym_ = scm_from_ascii_symbol ((base_ident + "-event").c_str ()); + info.style_sym_ = scm_from_ascii_symbol (("pedal" + base_name + "Style").c_str ()); + info.strings_sym_ = scm_from_ascii_symbol (("pedal" + base_name + "Strings").c_str ()); info.base_name_ = name; info.pedal_c_str_ = strdup ((base_name + "Pedal").c_str ()); @@ -182,7 +181,8 @@ init_pedal_types () ADD_SCM_INIT_FUNC (Piano_pedal_engraver_init_pedal_types_, init_pedal_types); -Piano_pedal_engraver::Piano_pedal_engraver () +Piano_pedal_engraver::Piano_pedal_engraver (Context *c) + : Engraver (c) { } @@ -206,23 +206,6 @@ Piano_pedal_engraver::initialize () info_list_[NUM_PEDAL_TYPES].type_ = 0; } -/* - Urg: Code dup - I'm a script -*/ -void -Piano_pedal_engraver::acknowledge_note_column (Grob_info info) -{ - for (Pedal_info *p = info_list_; p->type_; p++) - { - if (p->bracket_) - add_bound_item (p->bracket_, info.grob ()); - if (p->finished_bracket_) - add_bound_item (p->finished_bracket_, info.grob ()); - } -} - -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sostenuto); void Piano_pedal_engraver::listen_sostenuto (Stream_event *ev) { @@ -230,7 +213,6 @@ Piano_pedal_engraver::listen_sostenuto (Stream_event *ev) ASSIGN_EVENT_ONCE (info_list_[SOSTENUTO].event_drul_[d], ev); } -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sustain); void Piano_pedal_engraver::listen_sustain (Stream_event *ev) { @@ -238,7 +220,6 @@ Piano_pedal_engraver::listen_sustain (Stream_event *ev) ASSIGN_EVENT_ONCE (info_list_[SUSTAIN].event_drul_[d], ev); } -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, una_corda); void Piano_pedal_engraver::listen_una_corda (Stream_event *ev) { @@ -266,13 +247,13 @@ Piano_pedal_engraver::process_music () mixed: Ped. _____/\____| */ - SCM style = internal_get_property (p->type_->style_sym_); + SCM style = get_property (p->type_->style_sym_); - bool mixed = style == ly_symbol2scm ("mixed"); + bool mixed = scm_is_eq (style, ly_symbol2scm ("mixed")); bool bracket = (mixed - || style == ly_symbol2scm ("bracket")); - bool text = (style == ly_symbol2scm ("text") - || mixed); + || scm_is_eq (style, ly_symbol2scm ("bracket"))); + bool text = (mixed + || scm_is_eq (style, ly_symbol2scm ("text"))); if (text && !p->item_) create_text_grobs (p, mixed); @@ -286,7 +267,7 @@ void Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) { SCM s = SCM_EOL; - SCM strings = internal_get_property (p->type_->strings_sym_); + SCM strings = get_property (p->type_->strings_sym_); if (scm_ilength (strings) < 3) { @@ -363,10 +344,8 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) { assert (!p->finished_bracket_); - Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); - - if (!p->bracket_->get_bound (RIGHT)) - p->bracket_->set_bound (RIGHT, cmc); + Grob *cmc = unsmob (get_property ("currentMusicalColumn")); + p->bracket_->set_bound (RIGHT, cmc); /* Set properties so that the stencil-creating function will @@ -443,7 +422,7 @@ Piano_pedal_engraver::finalize () if (p->bracket_) { SCM cc = get_property ("currentCommandColumn"); - Item *c = unsmob_item (cc); + Item *c = unsmob (cc); p->bracket_->set_bound (RIGHT, c); p->finished_bracket_ = p->bracket_; @@ -463,10 +442,8 @@ Piano_pedal_engraver::stop_translation_timestep () typeset_all (p); if (p->bracket_ && !p->bracket_->get_bound (LEFT)) { - Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); - - if (!p->bracket_->get_bound (LEFT)) - p->bracket_->set_bound (LEFT, cmc); + Grob *cmc = unsmob (get_property ("currentMusicalColumn")); + p->bracket_->set_bound (LEFT, cmc); } } @@ -494,13 +471,19 @@ Piano_pedal_engraver::typeset_all (Pedal_info *p) { Grob *r = p->finished_bracket_->get_bound (RIGHT); if (!r) - p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); + p->finished_bracket_->set_bound (RIGHT, unsmob (get_property ("currentMusicalColumn"))); p->finished_bracket_ = 0; } } -ADD_ACKNOWLEDGER (Piano_pedal_engraver, note_column); +void +Piano_pedal_engraver::boot () +{ + ADD_LISTENER (Piano_pedal_engraver, sostenuto); + ADD_LISTENER (Piano_pedal_engraver, sustain); + ADD_LISTENER (Piano_pedal_engraver, una_corda); +} ADD_TRANSLATOR (Piano_pedal_engraver, /* doc */