X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fottava-engraver.cc;h=bd39702bdb59da5c14ef516551455c8f9ce57673;hb=32a34dcef0c0041c6d62677487a380b5c8b85712;hp=3426052280a014a8610fb4eabe5d0775f7931fa9;hpb=d77933148612eca5821af90e30803793d2e3daed;p=lilypond.git diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index 3426052280..bd39702bdb 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -1,41 +1,61 @@ /* - text-spanner-engraver.cc -- implement Ottava_spanner_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2012 Han-Wen Nienhuys - (c) 2000--2003 Han-Wen Nienhuys - Jan Nieuwenhuizen + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ -#include "protected-scm.hh" -#include "note-column.hh" +#include "engraver.hh" #include "item.hh" +#include "note-column.hh" +#include "protected-scm.hh" #include "side-position-interface.hh" -#include "engraver.hh" +#include "spanner.hh" +#include "text-interface.hh" class Ottava_spanner_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Ottava_spanner_engraver); + TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver); protected: virtual void finalize (); - virtual void acknowledge_grob (Grob_info); - virtual void process_music (); - virtual void stop_translation_timestep (); + + DECLARE_ACKNOWLEDGER (note_column); + + void process_music (); + void stop_translation_timestep (); + virtual void derived_mark () const; private: Spanner *span_; Spanner *finished_; - - Protected_scm last_ottavation_; - + + SCM last_ottavation_; + void typeset_all (); }; +void +Ottava_spanner_engraver::derived_mark () const +{ + scm_gc_mark (last_ottavation_); +} Ottava_spanner_engraver::Ottava_spanner_engraver () { finished_ = 0; - span_ =0; + span_ = 0; last_ottavation_ = SCM_EOL; } @@ -45,53 +65,49 @@ Ottava_spanner_engraver::process_music () SCM ott = get_property ("ottavation"); if (ott != last_ottavation_) { - finished_= span_; + finished_ = span_; span_ = 0; - if (gh_string_p (ott)) - { - span_ = new Spanner (get_property ("OttavaSpanner")); - span_->set_grob_property ("edge-text", gh_cons (ott, SCM_EOL)); - announce_grob (span_, SCM_EOL); - - SCM c0 (get_property ("centralCPosition")); - SCM oc0 (get_property ("originalCentralCPosition")); - if (scm_less_p (oc0, c0) == SCM_BOOL_T) - span_->set_grob_property ("direction", gh_int2scm (DOWN)); - } + if (Text_interface::is_markup (ott)) + { + span_ = make_spanner ("OttavaBracket", SCM_EOL); + span_->set_property ("text", ott); + + SCM offset (get_property ("middleCOffset")); + if (robust_scm2double (offset, 0) > 0) + span_->set_property ("direction", scm_from_int (DOWN)); + } } last_ottavation_ = ott; } void -Ottava_spanner_engraver::acknowledge_grob (Grob_info info) +Ottava_spanner_engraver::acknowledge_note_column (Grob_info info) { - Item *it = dynamic_cast (info.grob_); - if (span_ && it && Note_column::has_interface (info.grob_)) + Item *it = info.item (); + if (span_ && it) { Side_position_interface::add_support (span_, it); + if (!span_->get_bound (LEFT)) - span_->set_bound (LEFT, it); + span_->set_bound (LEFT, it); span_->set_bound (RIGHT, it); } } void Ottava_spanner_engraver::typeset_all () -{ +{ if (finished_) { - Direction d = LEFT; - do - { - if (!finished_->get_bound (RIGHT)) - { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); - finished_->set_bound (d, e); - } - } - while (flip (&d) != LEFT); - - typeset_grob (finished_); + for (LEFT_and_RIGHT (d)) + { + if (!finished_->get_bound (RIGHT)) + { + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); + finished_->set_bound (d, e); + } + } + finished_ = 0; } } @@ -101,7 +117,7 @@ Ottava_spanner_engraver::stop_translation_timestep () { if (span_ && !span_->get_bound (LEFT)) { - Grob* e = unsmob_grob (get_property ("currentMusicalColumn")); + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); span_->set_bound (LEFT, e); } @@ -114,13 +130,26 @@ Ottava_spanner_engraver::finalize () typeset_all (); if (span_) finished_ = span_; - typeset_all(); + typeset_all (); + last_ottavation_ = SCM_EOL; } -ENTER_DESCRIPTION(Ottava_spanner_engraver, -/* descr */ "Create a text spanner when the ottavation property changes..", -/* creats*/ "OttavaSpanner", -/* accepts */ "", -/* acks */ "note-column-interface", -/* reads */ "ottavation", -/* write */ ""); +#include "translator.icc" + +ADD_ACKNOWLEDGER (Ottava_spanner_engraver, note_column); + +ADD_TRANSLATOR (Ottava_spanner_engraver, + /* doc */ + "Create a text spanner when the ottavation property changes.", + + /* create */ + "OttavaBracket ", + + /* read */ + "middleCOffset " + "ottavation " + "currentMusicalColumn ", + + /* write */ + "" + );