]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-margin-engraver.cc
54fe0efa1f29b958d6f217116dd551dd56cc9812
[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 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "staff-margin-engraver.hh"
10 #include "bar.hh"
11 #include "time-description.hh"
12 #include "g-text-item.hh"
13 #include "g-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_
22     = gh_eval_str ("(lambda (d) (if (= d 1) '(#f . #f) '(#t . #t)))");
23 }
24
25
26
27 /*
28     TODO
29     fix alignment/support
30
31     should be able to set whole paragraph (multiple lines, centre) to
32     left (right?) of staff, e.g.:
33                     ______
34                    |_______
35       2 Clarinetti |________
36          (Bb)      |___________
37                    |______________
38 */
39 void
40 Staff_margin_engraver::acknowledge_element (Score_element_info i)
41 {
42   Bar * b =dynamic_cast<Bar *> (i.elem_l_);
43   if (!b)
44     return ;
45
46   if (i.origin_grav_l_arr_.size() != 1)
47     return;
48
49
50   String long_str = get_property ("instrument", 0);
51   String str = get_property ("instr", 0);
52   if (now_mom () > Moment (0) && str.length_i ())
53     long_str = str;
54
55   if (long_str.empty_b ())
56     return;
57
58   create_items (0);
59   text_p_->text_str_ = long_str;
60   staff_side_p_->dir_ = LEFT;
61   Bar_script_engraver::acknowledge_element(i);
62 }
63
64