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