lilypond-1.3.28
[lilypond.git] / lily / axis-group-spanner.cc
blob7af3118a1163f9ddb4efc3664cb0fcfc0e352a6b
1 /*
2 axis-group-spanner.cc -- implement Axis_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "axis-group-spanner.hh"
10 #include "debug.hh"
11 #include "item.hh"
12 #include "paper-column.hh"
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.
18 void
19 Axis_group_spanner::do_break_processing_if_unbroken()
21 #if 0
22 Link_array<Score_element> elems = elem_l_arr ();
23 Line_of_score *my_line = line_l();
24 for (int i=0; i < elems.size(); i++)
26 if (!elems[i]->line_l())
28 Item * item_l = dynamic_cast<Item*> (elems[i]);
29 if (item_l
30 && item_l->breakable_b ()
31 && item_l->break_status_dir() == 0)
33 // last two checks are paranoia
34 Score_element * broken_item_l =
35 item_l->find_broken_piece (my_line);
36 add_element (broken_item_l);
39 Spanner *spanner_l = dynamic_cast<Spanner*> (elems[i]);
40 if (spanner_l)
42 Score_element *broken_spanner_l =
43 spanner_l->find_broken_piece (my_line);
44 add_element (broken_spanner_l);
46 remove_element (elems[i]);
50 #endif
53 void
54 Axis_group_spanner::do_break_processing()
56 Spanner::do_break_processing ();
58 bool breaking_self_b = ! Spanner::line_l();
59 if (!breaking_self_b)
61 do_break_processing_if_unbroken();
62 Spanner::do_break_processing();
63 return;
66 #if 0
67 break_into_pieces ();
68 Link_array<Score_element> loose_elems = elem_l_arr ();
70 Array<int> axeses;
72 for (int i=0; i < loose_elems.size (); i++)
74 Score_element* elt = loose_elems[i];
76 with which axes do we have to meddle?
78 int j =0;
79 int as [2];
80 for (int a = X_AXIS; a < NO_AXES; ++a)
81 if (elt->parent_l (Axis (a)) == this)
82 as[j++] = a;
83 if (j == 1)
84 as[j++] = as[0];
86 axeses.push (as[0]);
87 axeses.push (as[1]);
90 remove_all();
92 for (int i=0; i < loose_elems.size(); i++)
94 Score_element * elt = loose_elems[i];
95 Line_of_score *elt_line = elt->line_l();
97 Axis a1= (Axis)axeses[2*i]; // ugh.
98 Axis a2= (Axis)axeses[2*i+1]; // ugh.
99 if (! elt_line)
101 /* this piece doesn't know where it belongs.
102 Find out if it was broken, and use the broken remains
106 Item *it = dynamic_cast <Item *> (elt) ;
107 if (Spanner * sp =dynamic_cast <Spanner *> (elt))
109 for (int j =0; j < sp->broken_into_l_arr_.size(); j++)
111 Line_of_score *l = sp->broken_into_l_arr_[j]->line_l ();
113 Axis_group_spanner * my_broken_l
114 = dynamic_cast<Axis_group_spanner*>(find_broken_piece (l));
116 Score_element * broken_span_l
117 = sp->find_broken_piece (l);
119 if (broken_span_l)
120 my_broken_l->add_element (broken_span_l, a1, a2);
123 else if (it && it->broken_original_b ())
125 // broken items
126 Direction j=LEFT;
129 Item * broken_item = it->find_broken_piece (j);
130 Line_of_score * item_line_l = broken_item->line_l() ;
131 if (! item_line_l)
132 continue;
134 Axis_group_spanner * v
135 = dynamic_cast<Axis_group_spanner*>(find_broken_piece (item_line_l));
136 if (v)
137 v->add_element (broken_item, a1, a2);
138 else
140 broken_item->set_elt_property ("transparent", SCM_BOOL_T);
141 broken_item->set_empty (X_AXIS); // UGH.
142 broken_item->set_empty (Y_AXIS);
146 while (flip(&j) != LEFT);
149 else
151 /* this piece *does* know where it belongs.
152 Put it in appropriate piece of this spanner
154 Axis_group_spanner * my_broken_l
155 = dynamic_cast<Axis_group_spanner*> (find_broken_piece (elt->line_l()));
156 my_broken_l->add_element (elt, a1, a2);
160 Spanner::do_break_processing();
161 #endif