]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group-spanner.cc
033a55b33a25be97a84e0af417556f87249d7bc6
[lilypond.git] / lily / axis-group-spanner.cc
1 /*
2   axis-group-spanner.cc -- implement Axis_group_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "axis-group-spanner.hh"
10 #include "item.hh"
11 #include "p-col.hh"
12
13 /** Do stuff if we're not broken. In this case the last and first
14   columns usually are pre- and postbreak respectively,
15   so the items from these columns need adjusting.
16   */
17 void
18 Axis_group_spanner::do_break_processing_if_unbroken()
19 {
20   Link_array<Score_elem> elems = axis_admin_.elem_l_arr_;
21   Line_of_score *my_line = line_l();
22   for (int i=0; i < elems.size(); i++) 
23     {
24       if (!elems[i]->line_l()) 
25         {
26           Item * item_l = elems[i]->item();
27           if  (item_l
28                && item_l->breakable_b_ 
29                && item_l->break_status_i() == 0) 
30             {
31               // last two checks are paranoia
32               Item * broken_item_l = 
33                 item_l->find_prebroken_piece (my_line);
34               add_element (broken_item_l);
35             }
36           remove_element (elems[i]);  
37         }
38     }
39 }
40 void
41 Axis_group_spanner::do_break_processing()
42 {
43   bool breaking_self_b = ! Spanner::line_l();
44   if (!breaking_self_b)  
45     {
46       do_break_processing_if_unbroken();
47       Spanner::do_break_processing();
48       return;
49     }
50
51   break_into_pieces ();
52   Link_array<Score_elem> loose_elems = axis_admin_.elem_l_arr_;
53   remove_all();
54   
55   for (int i=0; i < loose_elems.size(); i++) 
56     {
57       Score_elem * elt = loose_elems[i];
58       Line_of_score *elt_line = elt->line_l();
59         
60       if (! elt_line)
61         {
62           /* this piece doesn't know where it belongs.
63              Find out if it was broken, and use the broken remains
64              */
65           if (elt->spanner()) 
66             {
67               Spanner * sp = elt->spanner();
68                 
69               for (int j =0; j < broken_into_l_arr_.size(); j++) 
70                 {
71                   Axis_group_spanner * my_broken_l
72                     = (Axis_group_spanner*)broken_into_l_arr_[j];
73                     
74                   Spanner * broken_span_l 
75                     = sp->find_broken_piece (
76                                              ((Score_elem*)my_broken_l)->line_l());
77                     
78                   if (broken_span_l) 
79                     my_broken_l->add_element (broken_span_l);
80                     
81                 }
82             }
83           else if (elt->item() 
84                    && elt->item()->breakable_b_ 
85                    && elt->item()->break_status_i () == 0) 
86             {
87               // broken items
88               Direction  j=LEFT;
89               do 
90                 {
91                   Item * my_item = elt->item()->broken_to_drul_[j];
92                   Line_of_score * item_line_l = my_item->line_l() ;
93                   if (! item_line_l) 
94                     continue;
95                     
96                   Axis_group_spanner * v
97                     = (Axis_group_spanner*)find_broken_piece (item_line_l);
98                   if (v)
99                     v->add_element (my_item);
100                 }
101               while ((j*=-1) != LEFT);
102             }
103         }
104       else 
105         {
106           /* this piece *does* know where it belongs.
107              Put it in appropriate piece of this spanner
108              */
109           Axis_group_spanner * my_broken_l
110             = (Axis_group_spanner*)find_broken_piece (elt->line_l());
111           my_broken_l->add_element (elt);
112         }
113     }
114   
115   Spanner::do_break_processing();
116 }
117
118 void
119 Axis_group_spanner::do_print() const
120 {
121   Axis_group_element::do_print();
122 }
123
124
125
126 IMPLEMENT_IS_TYPE_B2(Axis_group_spanner, Spanner, Axis_group_element);