]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group-spanner.cc
1d45de3ae0e3bd003c7ff457ec5daf88ab859bcd
[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 }
41 void
42 Axis_group_spanner::do_break_processing()
43 {
44   set_my_columns();
45   bool breaking_self_b = ! Spanner::line_l();
46   if (!breaking_self_b)  
47     {
48         do_break_processing_if_unbroken();
49         Spanner::do_break_processing();
50         return;
51     }
52
53   break_into_pieces (true);
54   Link_array<Score_elem> loose_elems = axis_admin_.elem_l_arr_;
55   remove_all();
56   
57   for (int i=0; i < loose_elems.size(); i++) 
58     {
59         Score_elem * elt = loose_elems[i];
60         Line_of_score *elt_line = elt->line_l();
61         
62         if ( ! elt_line)
63           {
64             /* this piece doesn't know where it belongs.
65                Find out if it was broken, and use the broken remains
66                */
67             if (elt->spanner()) 
68               {
69                 Spanner * sp = elt->spanner();
70                 
71                 for (int j =0; j < broken_into_l_arr_.size(); j++) 
72                   {
73                     Axis_group_spanner * my_broken_l
74                          = (Axis_group_spanner*)broken_into_l_arr_[j];
75                     
76                     Spanner * broken_span_l 
77                         = sp->find_broken_piece (
78                             ((Score_elem*)my_broken_l)->line_l());
79                     
80                     if (broken_span_l) 
81                         my_broken_l->add_element (broken_span_l);
82                     
83                   }
84               }
85             else if (elt->item() 
86                        && elt->item()->breakable_b_ 
87                        && elt->item()->break_status_i () == 0) 
88                          {
89
90                 // broken items
91                 for (int j =0; j < 2; j++) 
92                   {
93                     Item * my_item = elt->item()->broken_to_a_[j];
94                     Line_of_score * item_line_l = my_item->line_l() ;
95                     if ( ! item_line_l) 
96                         continue;
97                     
98                     Axis_group_spanner * v
99                         = (Axis_group_spanner*)find_broken_piece (item_line_l);
100                     if (v)
101                         v->add_element (my_item);
102                   }
103                     
104               }
105           }
106         else 
107           {
108           /* this piece *does* know where it belongs.
109              Put it in appropriate piece of this spanner
110              */
111             Axis_group_spanner * my_broken_l
112                 = (Axis_group_spanner*)find_broken_piece (elt->line_l());
113             my_broken_l->add_element (elt);
114           }
115     }
116   
117   Spanner::do_break_processing();
118 }
119
120 void
121 Axis_group_spanner::do_print() const
122 {
123   Axis_group_element::do_print();
124 }
125
126
127
128 IMPLEMENT_IS_TYPE_B2(Axis_group_spanner, Spanner, Axis_group_element);