lilypond-0.1.56
[lilypond.git] / lily / axis-group-spanner.cc
blob5cace351e33134d0de7eb1b37d69726a5851c37a
1 /*
2 axis-group-spanner.cc -- implement Axis_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "axis-group-spanner.hh"
10 #include "item.hh"
11 #include "p-col.hh"
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.
17 void
18 Axis_group_spanner::do_break_processing_if_unbroken()
20 Link_array<Score_elem> elems = elem_l_arr ();
21 Line_of_score *my_line = line_l();
22 for (int i=0; i < elems.size(); i++)
24 if (!elems[i]->line_l())
26 Item * item_l = elems[i]->item();
27 if (item_l
28 && item_l->breakable_b_
29 && item_l->break_status_i() == 0)
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);
36 remove_element (elems[i]);
40 void
41 Axis_group_spanner::do_break_processing()
43 bool breaking_self_b = ! Spanner::line_l();
44 if (!breaking_self_b)
46 do_break_processing_if_unbroken();
47 Spanner::do_break_processing();
48 return;
51 break_into_pieces ();
52 Link_array<Score_elem> loose_elems = elem_l_arr ();
53 remove_all();
55 for (int i=0; i < loose_elems.size(); i++)
57 Score_elem * elt = loose_elems[i];
58 Line_of_score *elt_line = elt->line_l();
60 if (! elt_line)
62 /* this piece doesn't know where it belongs.
63 Find out if it was broken, and use the broken remains
65 if (elt->spanner())
67 Spanner * sp = elt->spanner();
69 for (int j =0; j < broken_into_l_arr_.size(); j++)
71 Axis_group_spanner * my_broken_l
72 = (Axis_group_spanner*)broken_into_l_arr_[j];
74 Spanner * broken_span_l
75 = sp->find_broken_piece (
76 ((Score_elem*)my_broken_l)->line_l());
78 if (broken_span_l)
79 my_broken_l->add_element (broken_span_l);
83 else if (elt->item()
84 && elt->item()->breakable_b_
85 && elt->item()->break_status_i () == 0)
87 // broken items
88 Direction j=LEFT;
89 do
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;
96 Axis_group_spanner * v
97 = (Axis_group_spanner*)find_broken_piece (item_line_l);
98 if (v)
99 v->add_element (my_item);
101 while (flip(&j) != LEFT);
104 else
106 /* this piece *does* know where it belongs.
107 Put it in appropriate piece of this spanner
109 Axis_group_spanner * my_broken_l
110 = (Axis_group_spanner*)find_broken_piece (elt->line_l());
111 my_broken_l->add_element (elt);
115 Spanner::do_break_processing();
118 void
119 Axis_group_spanner::do_print() const
121 Axis_group_element::do_print();
126 IMPLEMENT_IS_TYPE_B2(Axis_group_spanner, Spanner, Axis_group_element);