X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstaff-margin-engraver.cc;h=a7f2607c26cbda21ac42a0e52caf42eede5c8d2c;hb=949737e17ed7cbc231a3c08e45d32897a636d94d;hp=9b51b97c7c0fae918ee9c9548b4e74387224ae4e;hpb=615a9212789c2cb2994748c023d0e19f3a83a0fd;p=lilypond.git diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index 9b51b97c7c..a7f2607c26 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -3,33 +3,29 @@ source file of the GNU LilyPond music typesetter - (c) 1998 Jan Nieuwenhuizen + (c) 1998--2000 Jan Nieuwenhuizen */ #include "staff-margin-engraver.hh" -#include "script.hh" -#include "text-def.hh" -#include "paper-def.hh" -#include "command-request.hh" #include "bar.hh" -#include "stem.hh" -#include "time-description.hh" - +#include "timing-translator.hh" +#include "text-item.hh" +#include "side-position-interface.hh" ADD_THIS_TRANSLATOR (Staff_margin_engraver); Staff_margin_engraver::Staff_margin_engraver () { - script_p_ = 0; + axis_ = X_AXIS; + type_ = "margin"; + visibility_lambda_ = ly_eval_str ("postbreak-only-visibility"); } - /* TODO - fix alignment/support - should be able to set whole paragraph (multiple lines, centre) to + should be able to set whole paragraph (multiple lines, center) to left (right?) of staff, e.g.: ______ |_______ @@ -38,54 +34,31 @@ Staff_margin_engraver::Staff_margin_engraver () |______________ */ void -Staff_margin_engraver::acknowledge_element (Score_element_info i) +Staff_margin_engraver::acknowledge_element (Score_element_info inf) { - Item * it = dynamic_cast (i.elem_l_); - - if (!it - || script_p_ - || !(dynamic_cast (it)) - || (i.origin_grav_l_arr_.size() != 1)) + Item *i = cast_to_interesting_item (inf.elem_l_); + if (!i || inf.origin_trans_l_arr (this).size() != 1) return; - String string = get_property ("instrument"); - String str = get_property ("instr"); - if (now_moment () > Moment (0)) - string = str; - if (!string.length_i ()) - return; + SCM long_name = get_property ("instrument", 0); + SCM short_name = get_property ("instr", 0); - script_p_ = new Script; - script_p_->axis_ = X_AXIS; - - Text_def *td_p =new Text_def; - td_p->align_dir_ = LEFT; - td_p->text_str_ = string; - // huh? - script_p_->dir_ = RIGHT; - script_p_->specs_p_ = td_p; - script_p_->breakable_b_ = true; + if (now_mom () > Moment (0)) + long_name = short_name; - - Scalar pri = get_property ("marginBreakPriority"); - if (pri.length_i () && pri.isnum_b ()) - { - script_p_->break_priority_i_ = int (pri); - } - else - script_p_ ->break_priority_i_ = it->break_priority_i_; - - announce_element (Score_element_info (script_p_, 0)); -} - -void -Staff_margin_engraver::do_pre_move_processing () -{ - if (script_p_) + if (gh_string_p (long_name)) { - typeset_element (script_p_); - script_p_ =0; + create_items (0); + text_p_->set_elt_property ("text", long_name); + text_p_->set_elt_property ("direction", gh_int2scm (LEFT)); + Bar_script_engraver::attach_script_to_item (i); + + /* + UGH. ignores font size settings. + */ + Interval iv(text_p_->extent (Y_AXIS)); + text_p_->translate_axis (- iv.center (), Y_AXIS); } }