]> git.donarmstrong.com Git - lilypond.git/blob - lily/separation-item.cc
release: 1.5.47
[lilypond.git] / lily / separation-item.cc
1 /*   
2      separation-item.cc --  implement Separation_item
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "separation-item.hh"
11 #include "paper-column.hh"
12 #include "debug.hh"
13 #include "group-interface.hh"
14
15 bool
16 Separation_item::has_interface (Grob *g)
17 {
18   return g->has_interface (ly_symbol2scm ("separation-item-interface"));
19 }
20
21 void
22 Separation_item::add_item (Grob*s,Item* i)
23 {
24   assert (i);
25   Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"),i);
26   s->add_dependency (i);
27 }
28
29 /*
30   DOCME:
31
32   why don't we use extent()
33  */
34 Interval
35 Separation_item::my_width (Grob *me)
36 {
37   Item *item = dynamic_cast<Item*> (me);
38   Paper_column * pc = item->column_l ();
39   Interval w;
40   
41   for (SCM s =  me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
42     {
43       SCM elt = ly_car (s);
44       if (!unsmob_grob (elt))
45         continue;
46
47       Item *il = unsmob_item (elt);
48       if (pc != il->column_l ())
49         {
50           /* this shouldn't happen, but let's continue anyway. */
51           programming_error (_ ("Separation_item:  I've been drinking too much"));
52           continue;             /*UGH UGH*/ 
53         }
54
55       if (to_boolean (il->get_grob_property ("no-spacing-rods")))
56         {
57           continue;
58         }
59
60       Interval iv (il->extent (pc, X_AXIS));
61       if (!iv.empty_b ())
62         {
63           w.unite (iv);
64         }
65     }
66
67   SCM pad = me->get_grob_property ("padding");
68
69   if (gh_number_p (pad))
70   {
71     w[RIGHT] += gh_scm2double (pad)/2;
72     w[LEFT] -= gh_scm2double (pad)/2;    
73   }
74   
75   return w;
76  // add this->offset_ ? this-> relative_coordinate ()? 
77 }
78
79
80
81
82
83 ADD_INTERFACE (Separation_item,"separation-item-interface",
84   "Item that computes widths to generate spacing rods.
85
86 Calc dimensions for the Separating_group_spanner; this has to be
87 an item to get dependencies correct.  It can't be an grob_group
88 since these usually are in a different X_group
89 ",
90   "elements");