lilypond-1.4.1
[lilypond.git] / lily / extender-spanner.cc
blob8a987bad27c7526798ef78642d5a8dde4214a36e
1 /*
2 extender-spanner.cc -- implement Extender_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 /*
10 TODO: too complicated implementation. Why the dx_drul?.
14 #include "dimension-cache.hh"
15 #include "box.hh"
16 #include "debug.hh"
17 #include "lookup.hh"
18 #include "molecule.hh"
19 #include "paper-column.hh"
20 #include "paper-def.hh"
21 #include "extender-spanner.hh"
23 Extender_spanner::Extender_spanner (SCM s)
24 : Spanner (s)
27 dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
28 set_extent_callback (Score_element::point_dimension_callback, Y_AXIS);
34 Molecule
35 Extender_spanner::do_brew_molecule () const
37 Molecule mol;
39 Real w = spanner_length ();
41 w += (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
42 Real h = paper_l ()->get_var ("extender_height");
43 Molecule a = lookup_l ()->filledbox ( Box (Interval (0,w), Interval (0,h)));
44 a.translate (Offset (dx_f_drul_[LEFT], 0));
46 mol.add_molecule (a);
48 return mol;
53 void
54 Extender_spanner::after_line_breaking ()
56 // UGH
57 Real gap = paper_l ()->get_var ("interline");
59 Direction d = LEFT;
62 Item* t = get_bound (d)
63 ? get_bound (d) : get_bound ((Direction)-d);
64 if (d == LEFT)
65 dx_f_drul_[d] += t->extent (X_AXIS).length ();
66 else
67 dx_f_drul_[d] -= d * gap / 2;
69 while (flip(&d) != LEFT);
73 void
74 Extender_spanner::set_textitem (Direction d, Item* textitem_l)
76 set_bound (d, textitem_l);
77 add_dependency (textitem_l);