]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-margin-engraver.cc
44dfb2df2419f3741e83fd10e98fbae38ffc2e09
[lilypond.git] / lily / staff-margin-engraver.cc
1 /*
2   staff-margin-engraver.cc -- implement Staff_margin_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "staff-margin-engraver.hh"
10 #include "bar.hh"
11 #include "timing-translator.hh"
12 #include "text-item.hh"
13 #include "staff-side.hh"
14
15 ADD_THIS_TRANSLATOR (Staff_margin_engraver);
16
17 Staff_margin_engraver::Staff_margin_engraver ()
18 {
19   axis_ = X_AXIS;
20   type_ = "margin";
21   visibility_lambda_ = ly_ch_C_eval_scm ("postbreak-only-visibility");
22 }
23
24
25 /*
26     TODO
27
28     should be able to set whole paragraph (multiple lines, center) to
29     left (right?) of staff, e.g.:
30                     ______
31                    |_______
32       2 Clarinetti |________
33          (Bb)      |___________
34                    |______________
35 */
36 void
37 Staff_margin_engraver::acknowledge_element (Score_element_info inf)
38 {
39   Item *i = cast_to_interesting_item (inf.elem_l_);
40   if (!i || inf.origin_trans_l_arr_.size() != 1)
41     return;
42
43
44   SCM long_name = get_property ("instrument", 0);
45   SCM short_name = get_property ("instr", 0);
46
47   if (now_mom () > Moment (0))
48     long_name = short_name;
49
50   if (gh_string_p (long_name))
51     {
52       create_items (0);
53       text_p_->text_str_ = ly_scm2string (long_name);
54       staff_side_p_->set_direction (LEFT);
55       Bar_script_engraver::attach_script_to_item (i);
56
57       /*
58     UGH. ignores font size settings.
59    */
60       Interval iv(text_p_->extent (Y_AXIS));
61       text_p_->translate_axis (- iv.center (),  Y_AXIS);
62     }
63 }
64