lilypond-1.3.30
[lilypond.git] / lily / staff-margin-engraver.cc
blobd581d513525f1abc0a5fcdaae9dd87cbbf8dea9c
1 /*
2 staff-margin-engraver.cc -- implement Staff_margin_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "staff-margin-engraver.hh"
10 #include "bar.hh"
11 #include "timing-translator.hh"
12 #include "text-item.hh"
13 #include "side-position-interface.hh"
15 ADD_THIS_TRANSLATOR (Staff_margin_engraver);
17 Staff_margin_engraver::Staff_margin_engraver ()
19 axis_ = X_AXIS;
20 type_ = "margin";
25 TODO
27 should be able to set whole paragraph (multiple lines, center) to
28 left (right?) of staff, e.g.:
29 ______
30 |_______
31 2 Clarinetti |________
32 (Bb) |___________
33 |______________
35 void
36 Staff_margin_engraver::acknowledge_element (Score_element_info inf)
38 Item *i = cast_to_interesting_item (inf.elem_l_);
39 if (!i || inf.origin_trans_l_arr (this).size() != 1)
40 return;
43 SCM long_name = get_property ("instrument");
44 SCM short_name = get_property ("instr");
46 if (now_mom () > Moment (0))
47 long_name = short_name;
49 if (gh_string_p (long_name))
51 create_items (0);
52 text_p_->set_elt_property ("text", long_name);
53 text_p_->set_elt_property ("direction", gh_int2scm (LEFT));
54 Bar_script_engraver::attach_script_to_item (i);
57 UGH. ignores font size settings.
59 Interval iv(text_p_->extent (Y_AXIS));
60 text_p_->translate_axis (- iv.center (), Y_AXIS);