]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-script-engraver.cc
release: 1.1.28
[lilypond.git] / lily / bar-script-engraver.cc
1 /*   
2   bar-script-engraver.cc --  implement Bar_script_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "bar-script-engraver.hh"
11 #include "bar.hh"
12 #include "g-staff-side.hh"
13 #include "g-text-item.hh"
14 #include "lily-guile.hh"
15
16 Bar_script_engraver::Bar_script_engraver ()
17 {
18   axis_ = Y_AXIS;
19   staff_side_p_ = 0;
20   text_p_ =0;
21   visibility_lambda_ 
22     = gh_eval_str ("non_postbreak_visibility");
23 }
24
25 void
26 Bar_script_engraver::acknowledge_element (Score_element_info i)
27 {
28   Axis other_axis = Axis((axis_ + 1)%2);
29   
30   if (staff_side_p_ && !staff_side_p_->dim_cache_[other_axis].parent_l_) 
31     {
32       Bar * bar_l = dynamic_cast<Bar*> (i.elem_l_);
33       if (!bar_l)
34         return;
35       
36       /* Only put numbers on bars that are at our own level (don't put
37          numbers over the staffs of a GrandStaff, only over the GrandStaff
38          itself */
39       if (i.origin_grav_l_arr_.size () == 1)
40         {
41           staff_side_p_->dim_cache_[other_axis].parent_l_ =  &bar_l->dim_cache_[other_axis];
42           //      staff_side_p_->dim_cache_[axis_].parent_l_ =  &bar_l->dim_cache_[axis_];        
43           staff_side_p_->add_support (i.elem_l_);
44           bar_l->add_dependency (staff_side_p_); // UGH. 
45         }
46     }
47 }
48
49 void 
50 Bar_script_engraver::do_pre_move_processing ()
51 {
52   if (text_p_)
53     {
54       text_p_->breakable_b_ = true; // ugh
55       typeset_element (text_p_);
56       text_p_ =0;
57     }
58   
59   if (staff_side_p_) 
60     {
61       staff_side_p_->breakable_b_ = true; // ugh
62       typeset_element (staff_side_p_);
63       staff_side_p_ = 0;
64     }
65 }
66
67
68 void
69 Bar_script_engraver::create_items (Request *rq)
70 {
71   if (staff_side_p_ || text_p_)
72     return;
73   
74   staff_side_p_ = new G_staff_side_item;
75   staff_side_p_->axis_ = axis_;
76   
77   text_p_ = new G_text_item;
78
79   Scalar prop = get_property (type_ + "Direction", 0);
80   if (prop.isnum_b ())
81     {
82       staff_side_p_->dir_ = (Direction) (int) prop;
83     }
84   else 
85     {
86       staff_side_p_->dir_ = UP;
87     }
88
89   staff_side_p_->set_victim(text_p_);
90   
91   Scalar padding = get_property (type_ + "ScriptPadding", 0);
92   if (padding.length_i() && padding.isnum_b ())
93     {
94       staff_side_p_->padding_f_ = Real(padding);
95     }
96
97   staff_side_p_->visibility_lambda_  = visibility_lambda_;
98   text_p_->visibility_lambda_ = visibility_lambda_;  
99   
100   announce_element (Score_element_info (text_p_, rq));
101   announce_element (Score_element_info (staff_side_p_, rq));
102 }