2 separation-item.cc -- implement Separation_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 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 Return the width of ME given that we are considering the object on
35 Separation_item::conditional_width (Grob * me, Grob * left)
37 Interval w = width (me);
39 Item *item = dynamic_cast<Item*> (me);
40 Paper_column * pc = item->get_column ();
43 for (SCM s = me->get_property ("conditional-elements"); ly_c_pair_p (s); s = ly_cdr (s))
46 if (!unsmob_grob (elt))
49 Item *il = unsmob_item (elt);
50 if (pc != il->get_column ())
52 /* this shouldn't happen, but let's continue anyway. */
53 programming_error (_ ("Separation_item: I've been drinking too much"));
57 if (to_boolean (il->get_property ("no-spacing-rods")))
62 if (Accidental_placement::has_interface (il))
64 w.unite (Accidental_placement::get_relevant_accidental_extent (il, pc, left));
68 SCM pad = me->get_property ("padding");
70 w.widen (robust_scm2double (pad, 0.0));
75 Separation_item::width (Grob *me)
77 SCM sw = me->get_property ("X-extent");
78 if (is_number_pair (sw))
80 return ly_scm2interval (sw);
83 Item *item = dynamic_cast<Item*> (me);
84 Paper_column * pc = item->get_column ();
87 for (SCM s = me->get_property ("elements"); ly_c_pair_p (s); s = ly_cdr (s))
90 if (!unsmob_grob (elt))
93 Item *il = unsmob_item (elt);
94 if (pc != il->get_column ())
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_property ("no-spacing-rods")))
106 Interval iv (il->extent (pc, X_AXIS));
113 SCM pad = me->get_property ("padding");
115 w.widen (robust_scm2double (pad, 0.0));
117 me->set_property ("X-extent", ly_interval2scm (w));
123 Separation_item::relative_width (Grob * me, Grob * common)
125 Interval iv = width (me);
127 return dynamic_cast<Item*>(me)->get_column ()->relative_coordinate (common, X_AXIS) + iv ;
132 Try to find the break-aligned symbol in SEPARATION_ITEM that is
133 sticking out at direction D. The x size is put in LAST_EXT
136 Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d,
139 Grob *col = dynamic_cast<Item*> (separation_item)->get_column ();
140 last_ext->set_empty ();
142 for (SCM s = separation_item->get_property ("elements");
143 ly_c_pair_p (s); s = ly_cdr (s))
145 Grob * break_item = unsmob_grob (ly_car (s));
147 if (!ly_c_symbol_p (break_item->get_property ("break-align-symbol")))
150 Interval ext = break_item->extent (col, X_AXIS);
155 || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0) )
158 last_grob = break_item;
169 ADD_INTERFACE (Separation_item,"separation-item-interface",
170 "Item that computes widths to generate spacing rods. "
171 "This is done in concert with @ref{separation-spanner-interface}."
175 "padding X-extent conditional-elements elements");