2 note-spacing.cc -- implement Note_spacing
4 source file of the GNU LilyPond music typesetter
6 (c) 2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "paper-column.hh"
13 #include "note-spacing.hh"
15 #include "note-column.hh"
19 Note_spacing::has_interface (Grob* g)
21 return g && g->has_interface (ly_symbol2scm ("note-spacing-interface"));
27 Note_spacing::get_spacing (Grob *me)
29 Drul_array<SCM> props(me->get_grob_property ("left-items"),
30 me->get_grob_property ("right-items"));
32 Drul_array<Interval> extents;
35 for (SCM s = props[d]; gh_pair_p (s); s = gh_cdr (s))
37 Item * it= dynamic_cast<Item*> (unsmob_grob (gh_car(s)));
38 extents[d].unite (it->extent (it->column_l (), X_AXIS));
42 Grob * accs = Note_column::accidentals (it);
44 extents[d].unite (accs->extent (it->column_l (), X_AXIS));
48 if (extents[d].empty_b ())
49 extents[d] = Interval (0,0);
51 while (flip (&d) != LEFT);
55 What's sticking out at the left of the right side has less
59 Real dx= extents[LEFT][RIGHT] - 0.5 * extents[RIGHT][LEFT];
64 MAKE_SCHEME_CALLBACK(Note_spacing, before_line_breaking, 1)
66 Note_spacing::before_line_breaking (SCM g)
68 Grob * me = unsmob_grob (g);
69 SCM right = me->get_grob_property ("right-items");
71 if (gh_pair_p (right))
72 right = gh_car (right);
74 Grob *right_grob = unsmob_grob (right);
76 Item * ri = dynamic_cast<Item*> (right_grob);
79 int r = Paper_column::rank_i (dynamic_cast<Item*>(me)->column_l ());
80 programming_error (_f("Spacing wish column %d has no right item.", r));
84 me->set_grob_property ("right-column", ri->column_l ()->self_scm());
87 return SCM_UNSPECIFIED;