lilypond-1.5.10
[lilypond.git] / lily / separation-item.cc
blob522cde9ac162a6a3324610c2aaac920a86350d8b
1 /*
2 single-malt-grouping-item.cc -- implement Separation_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "separation-item.hh"
11 #include "paper-column.hh"
12 #include "debug.hh"
13 #include "group-interface.hh"
15 void
16 Separation_item::set_interface (Grob*s)
18 s->set_extent_callback (SCM_EOL, X_AXIS);
19 s->set_extent_callback (SCM_EOL, Y_AXIS);
22 void
23 Separation_item::add_item (Grob*s,Item* i)
25 assert (i);
26 Pointer_group_interface::add_element (s,"elements",i);
27 s->add_dependency (i);
30 Interval
31 Separation_item::my_width (Grob *me)
33 Item *item = dynamic_cast<Item*> (me);
34 Paper_column * pc = item->column_l ();
35 Interval w;
37 for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
39 SCM elt = gh_car (s);
40 if (!unsmob_grob (elt))
41 continue;
43 Item *il = dynamic_cast<Item*> (unsmob_grob (elt));
44 if (pc != il->column_l ())
46 /* this shouldn't happen, but let's continue anyway. */
47 programming_error (_ ("Separation_item: I've been drinking too much"));
48 continue; /*UGH UGH*/
51 if (to_boolean (il->get_grob_property ("no-spacing-rods")))
53 continue;
56 Interval iv (il->extent (pc, X_AXIS));
57 if (!iv.empty_b ())
59 w.unite (iv);
63 SCM pad = me->get_grob_property ("padding");
65 if (gh_number_p (pad))
67 w[RIGHT] += gh_scm2double (pad)/2;
68 w[LEFT] -= gh_scm2double (pad)/2;
71 return w;
72 // add this->offset_ ? this-> relative_coordinate ()?