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