X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcue-clef-engraver.cc;h=cf7f0bd9681f7715b96f78b409f32ddb1121a153;hb=8e2eaf4959bec63a1128a444591a540f4f1e2937;hp=5da4f168173eed888417d559106bdd8c249924aa;hpb=b95e6a554272b0f4472d436d1b3d0803bd192478;p=lilypond.git diff --git a/lily/cue-clef-engraver.cc b/lily/cue-clef-engraver.cc index 5da4f16817..cf7f0bd968 100644 --- a/lily/cue-clef-engraver.cc +++ b/lily/cue-clef-engraver.cc @@ -1,9 +1,9 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2010 Han-Wen Nienhuys + Copyright (C) 1997--2015 Han-Wen Nienhuys Mats Bengtsson - Copyright (C) 2010 Reinhold Kainhofer + Copyright (C) 2010--2015 Reinhold Kainhofer LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ using namespace std; #include "item.hh" #include "context.hh" -#include "bar-line.hh" #include "staff-symbol-referencer.hh" #include "engraver.hh" #include "direction.hh" @@ -42,37 +41,38 @@ public: protected: void stop_translation_timestep (); void process_music (); - DECLARE_ACKNOWLEDGER (bar_line); + void acknowledge_bar_line (Grob_info); virtual void derived_mark () const; private: Item *clef_; - Item *octavate_; + Item *modifier_; SCM prev_glyph_; SCM prev_cpos_; - SCM prev_octavation_; + SCM prev_transposition_; void create_clef (); void create_end_clef (); void set_glyph (); void inspect_clef_properties (); - void create_octavate_eight (SCM oct); + void create_clef_modifier (SCM oct); }; void Cue_clef_engraver::derived_mark () const { - scm_gc_mark (prev_octavation_); + scm_gc_mark (prev_transposition_); scm_gc_mark (prev_cpos_); scm_gc_mark (prev_glyph_); } -Cue_clef_engraver::Cue_clef_engraver () +Cue_clef_engraver::Cue_clef_engraver (Context *c) + : Engraver (c) { clef_ = 0; - octavate_ = 0; + modifier_ = 0; - prev_octavation_ = prev_cpos_ = prev_glyph_ = SCM_EOL; + prev_transposition_ = prev_cpos_ = prev_glyph_ = SCM_EOL; } void @@ -101,28 +101,31 @@ Cue_clef_engraver::acknowledge_bar_line (Grob_info info) } void -Cue_clef_engraver::create_octavate_eight (SCM oct) +Cue_clef_engraver::create_clef_modifier (SCM transp) { - if (scm_is_number (oct) && scm_to_int (oct)) + if (scm_is_number (transp) && scm_to_int (transp)) { - Item *g = make_item ("OctavateEight", SCM_EOL); + Item *g = make_item ("ClefModifier", SCM_EOL); - int abs_oct = scm_to_int (oct); - int dir = sign (abs_oct); - abs_oct = abs (abs_oct) + 1; + int abs_transp = scm_to_int (transp); + int dir = sign (abs_transp); + abs_transp = abs (abs_transp) + 1; - SCM txt = scm_number_to_string (scm_from_int (abs_oct), - scm_from_int (10)); + SCM txt = scm_number_to_string (scm_from_int (abs_transp), + scm_from_int (10)); + + SCM style = get_property ("cueClefTranspositionStyle"); + + SCM formatter = get_property ("cueClefTranspositionFormatter"); + if (ly_is_procedure (formatter)) + g->set_property ("text", scm_call_2 (formatter, txt, style)); - g->set_property ("text", - scm_list_n (ly_lily_module_constant ("vcenter-markup"), - txt, SCM_UNDEFINED)); Side_position_interface::add_support (g, clef_); g->set_parent (clef_, Y_AXIS); g->set_parent (clef_, X_AXIS); g->set_property ("direction", scm_from_int (dir)); - octavate_ = g; + modifier_ = g; } } @@ -136,9 +139,9 @@ Cue_clef_engraver::create_clef () clef_ = c; SCM cpos = get_property ("cueClefPosition"); if (scm_is_number (cpos)) - clef_->set_property ("staff-position", cpos); + clef_->set_property ("staff-position", cpos); - create_octavate_eight (get_property ("cueClefOctavation")); + create_clef_modifier (get_property ("cueClefTransposition")); } } @@ -150,9 +153,9 @@ Cue_clef_engraver::create_end_clef () clef_ = make_item ("CueEndClef", SCM_EOL); SCM cpos = get_property ("clefPosition"); if (scm_is_number (cpos)) - clef_->set_property ("staff-position", cpos); + clef_->set_property ("staff-position", cpos); - create_octavate_eight (get_property ("clefOctavation")); + create_clef_modifier (get_property ("clefTransposition")); } } @@ -167,25 +170,25 @@ Cue_clef_engraver::inspect_clef_properties () { SCM glyph = get_property ("cueClefGlyph"); SCM clefpos = get_property ("cueClefPosition"); - SCM octavation = get_property ("cueClefOctavation"); + SCM transposition = get_property ("cueClefTransposition"); - if (scm_equal_p (glyph, prev_glyph_) == SCM_BOOL_F - || scm_equal_p (clefpos, prev_cpos_) == SCM_BOOL_F - || scm_equal_p (octavation, prev_octavation_) == SCM_BOOL_F) + if (!ly_is_equal (glyph, prev_glyph_) + || !ly_is_equal (clefpos, prev_cpos_) + || !ly_is_equal (transposition, prev_transposition_)) { set_glyph (); if (scm_is_string (glyph)) - { - create_clef (); - if (clef_) - clef_->set_property ("non-default", SCM_BOOL_T); - } + { + create_clef (); + if (clef_) + clef_->set_property ("non-default", SCM_BOOL_T); + } else create_end_clef (); prev_cpos_ = clefpos; prev_glyph_ = glyph; - prev_octavation_ = octavation; + prev_transposition_ = transposition; } } @@ -195,36 +198,43 @@ Cue_clef_engraver::stop_translation_timestep () { if (clef_) { - SCM vis = 0; if (to_boolean (clef_->get_property ("non-default"))) - vis = get_property ("explicitCueClefVisibility"); + { + SCM vis = get_property ("explicitCueClefVisibility"); - if (vis) - clef_->set_property ("break-visibility", vis); + if (scm_is_vector (vis)) + clef_->set_property ("break-visibility", vis); + } clef_ = 0; - octavate_ = 0; + modifier_ = 0; } } -ADD_ACKNOWLEDGER (Cue_clef_engraver, bar_line); +void +Cue_clef_engraver::boot () +{ + ADD_ACKNOWLEDGER (Cue_clef_engraver, bar_line); +} + ADD_TRANSLATOR (Cue_clef_engraver, - /* doc */ - "Determine and set reference point for pitches in cued voices.", - - /* create */ - "CueClef " - "CueEndClef " - "OctavateEight ", - - /* read */ - "cueClefGlyph " - "cueClefOctavation " - "cueClefPosition " - "explicitCueClefVisibility " - "middleCCuePosition " - "clefOctavation ", - - /* write */ - "" - ); + /* doc */ + "Determine and set reference point for pitches in cued voices.", + + /* create */ + "CueClef " + "CueEndClef " + "ClefModifier ", + + /* read */ + "cueClefGlyph " + "cueClefTransposition " + "cueClefTranspositionStyle " + "cueClefPosition " + "explicitCueClefVisibility " + "middleCCuePosition " + "clefTransposition ", + + /* write */ + "" + );