]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-margin-engraver.cc
release: 1.1.1
[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 "script.hh"
11 #include "text-def.hh"
12 #include "paper-def.hh"
13 #include "command-request.hh"
14 #include "bar.hh"
15 #include "stem.hh"
16 #include "time-description.hh"
17
18 IMPLEMENT_IS_TYPE_B1 (Staff_margin_engraver, Engraver);
19 ADD_THIS_TRANSLATOR (Staff_margin_engraver);
20
21 Staff_margin_engraver::Staff_margin_engraver ()
22 {
23   script_p_ = 0;
24 }
25
26
27
28 /*
29     TODO
30     fix alignment/support
31
32     should be able to set whole paragraph (multiple lines, centre) to
33     left (right?) of staff, e.g.:
34                     ______
35                    |_______
36       2 Clarinetti |________
37          (Bb)      |___________
38                    |______________
39 */
40 void
41 Staff_margin_engraver::acknowledge_element (Score_element_info i)
42 {
43   Item * it =  dynamic_cast <Item *> (i.elem_l_);
44
45   if (!it
46       || script_p_ 
47       || !(dynamic_cast<Bar *> (it))
48       || (i.origin_grav_l_arr_.size() != 1))
49     return;
50
51   String string = get_property ("instrument");
52   String str = get_property ("instr");
53   if (now_moment () > Moment (0))
54     string = str;
55
56   if (!string.length_i ())
57     return;
58
59   script_p_ = new Script;
60   script_p_->axis_ = X_AXIS;
61   
62   Text_def *td_p =new Text_def;
63   td_p->align_dir_ = LEFT;
64   td_p->text_str_ = string;
65   // huh?
66   script_p_->dir_ = RIGHT;
67   script_p_->specs_p_ = td_p;
68   script_p_->breakable_b_ = true;
69
70   
71   Scalar pri = get_property ("marginBreakPriority");
72   if (pri.length_i () && pri.isnum_b ())
73     {
74       script_p_->break_priority_i_ = int (pri);
75     }
76   else
77     script_p_ ->break_priority_i_ = it->break_priority_i_;
78
79   announce_element (Score_element_info (script_p_, 0));
80 }
81
82 void
83 Staff_margin_engraver::do_pre_move_processing ()
84 {
85   if (script_p_) 
86     {
87       typeset_element (script_p_);
88       script_p_ =0;
89     }
90 }
91