2 spanner.cc -- implement Spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
13 #include "outputter.hh"
15 IMPLEMENT_IS_TYPE_B1(Spanner
,Score_elem
);
18 Spanner::do_print() const
21 DOUT
<< "Between col ";
22 if (broken_into_l_arr_
.size())
23 DOUT
<< "with broken pieces\n";
28 Spanner::break_into_pieces ()
30 if (broken_into_l_arr_
.size())
33 Item
* left
= spanned_drul_
[LEFT
];
34 Item
* right
= spanned_drul_
[RIGHT
];
37 Link_array
<Item
> break_cols
= pscore_l_
->broken_col_range (left
,right
);
38 Link_array
<Spanner
> broken_into_l_arr
;
40 break_cols
.insert (left
,0);
41 break_cols
.push (right
);
43 for (int i
=1; i
< break_cols
.size(); i
++)
45 Spanner
* span_p
= clone()->spanner ();
46 left
= break_cols
[i
-1];
47 right
= break_cols
[i
];
49 right
= right
->find_prebroken_piece(-1);
51 left
= left
->find_prebroken_piece(1);
53 assert (left
&&right
&& left
->line_l() == right
->line_l());
55 span_p
->set_bounds(LEFT
,left
);
56 span_p
->set_bounds(RIGHT
,right
);
58 pscore_l_
->typeset_broken_spanner (span_p
);
59 broken_into_l_arr
.push (span_p
);
62 broken_into_l_arr_
= broken_into_l_arr
;
66 Spanner::set_my_columns()
68 Direction i
= (Direction
)1;
71 if (!spanned_drul_
[i
]->line_l())
72 set_bounds(i
,spanned_drul_
[i
]->find_prebroken_piece(-i
));
79 Spanner::set_bounds(Direction d
, Item
*i
)
82 spanned_drul_
[d
]->attached_span_l_arr_
.substitute(this,0);
86 i
->attached_span_l_arr_
.push(this);
88 assert (!spanned_drul_
[d
] ||
89 spanned_drul_
[Direction(-d
)] != spanned_drul_
[d
]);
94 Spanner::do_break_processing()
99 for (int i
=0; i
< broken_into_l_arr_
.size(); i
++)
100 broken_into_l_arr_
[i
]->handle_broken_dependencies();
104 handle_broken_dependencies();
111 spanned_drul_
[LEFT
]=0;
112 spanned_drul_
[RIGHT
]=0;
116 Spanner::do_brew_molecule ()
120 Molecule
*output
= brew_molecule_p ();
121 Offset
left_off (spanned_drul_
[LEFT
]->absolute_coordinate(X_AXIS
), 0);
122 Offset o
= absolute_offset() + left_off
;
123 pscore_l_
->outputter_l_
->output_molecule (output
, o
);
127 Spanner::do_width() const
129 Real l
= spanned_drul_
[LEFT
]->absolute_coordinate (X_AXIS
);
130 Real r
= spanned_drul_
[RIGHT
]->absolute_coordinate (X_AXIS
);
133 return Interval (0, r
-l
);
137 Spanner::line_l() const
139 if (!spanned_drul_
[LEFT
] || !spanned_drul_
[RIGHT
])
141 if (spanned_drul_
[LEFT
]->line_l() != spanned_drul_
[RIGHT
]->line_l())
143 return spanned_drul_
[LEFT
]->line_l();
148 Spanner::find_broken_piece (Line_of_score
*l
) const
150 for (int i
=0; i
< broken_into_l_arr_
.size(); i
++)
151 if (broken_into_l_arr_
[i
]->line_l() == l
)
152 return broken_into_l_arr_
[i
];
158 Spanner::broken_b() const
160 return broken_into_l_arr_
.size();
166 set_bounds (LEFT
, 0);
167 set_bounds (RIGHT
, 0);
171 Spanner::do_junk_links()
173 spanned_drul_
[LEFT
] = spanned_drul_
[RIGHT
] =0;