2 separation-item.cc -- implement Separation_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "separation-item.hh"
11 #include "paper-column.hh"
13 #include "group-interface.hh"
14 #include "accidental-placement.hh"
17 Separation_item::add_item (Grob*s,Item* i)
20 Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"),i);
21 s->add_dependency (i);
25 Separation_item::add_conditional_item (Grob* me , Grob *e)
27 Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e);
31 Separation_item::conditional_width (Grob * me, Grob * left)
33 Interval w = width (me);
35 Item *item = dynamic_cast<Item*> (me);
36 Paper_column * pc = item->column_l ();
39 for (SCM s = me->get_grob_property ("conditional-elements"); gh_pair_p (s); s = ly_cdr (s))
42 if (!unsmob_grob (elt))
45 Item *il = unsmob_item (elt);
46 if (pc != il->column_l ())
48 /* this shouldn't happen, but let's continue anyway. */
49 programming_error (_ ("Separation_item: I've been drinking too much"));
53 if (to_boolean (il->get_grob_property ("no-spacing-rods")))
58 if (Accidental_placement::has_interface (il))
60 w.unite (Accidental_placement::get_relevant_accidental_extent (il, pc, left));
64 SCM pad = me->get_grob_property ("padding");
66 if (gh_number_p (pad))
68 w[RIGHT] += gh_scm2double (pad)/2;
69 w[LEFT] -= gh_scm2double (pad)/2;
75 Separation_item::width (Grob *me)
77 SCM sw = me->get_grob_property ("extent-X");
78 if (ly_number_pair_p (sw))
80 return ly_scm2interval (sw);
83 Item *item = dynamic_cast<Item*> (me);
84 Paper_column * pc = item->column_l ();
87 for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
90 if (!unsmob_grob (elt))
93 Item *il = unsmob_item (elt);
94 if (pc != il->column_l ())
96 /* this shouldn't happen, but let's continue anyway. */
97 programming_error (_ ("Separation_item: I've been drinking too much"));
101 if (to_boolean (il->get_grob_property ("no-spacing-rods")))
106 Interval iv (il->extent (pc, X_AXIS));
113 SCM pad = me->get_grob_property ("padding");
115 if (gh_number_p (pad))
117 w[RIGHT] += gh_scm2double (pad)/2;
118 w[LEFT] -= gh_scm2double (pad)/2;
122 me->set_grob_property ("extent-X", ly_interval2scm (w));
126 // add this->offset_ ? this-> relative_coordinate ()?
133 ADD_INTERFACE (Separation_item,"separation-item-interface",
134 "Item that computes widths to generate spacing rods.
136 Calc dimensions for the Separating_group_spanner; this has to be
137 an item to get dependencies correct. It can't be an grob_group
138 since these usually are in a different X_group
140 "extent-X conditional-elements elements");