]> git.donarmstrong.com Git - lilypond.git/blob - lily/separation-item.cc
release: 1.5.29
[lilypond.git] / lily / separation-item.cc
1 /*   
2   single-malt-grouping-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 void
16 Separation_item::set_interface (Grob*s)
17 {
18   s->set_extent_callback (SCM_EOL, X_AXIS);
19   s->set_extent_callback (SCM_EOL, Y_AXIS);
20 }
21
22 void
23 Separation_item::add_item (Grob*s,Item* i)
24 {
25   assert (i);
26   Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"),i);
27   s->add_dependency (i);
28 }
29
30 Interval
31 Separation_item::my_width (Grob *me)
32 {
33   Item *item = dynamic_cast<Item*> (me);
34   Paper_column * pc = item->column_l ();
35   Interval w;
36   
37   for (SCM s =  me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
38     {
39       SCM elt = ly_car (s);
40       if (!unsmob_grob (elt))
41         continue;
42
43       Item *il = unsmob_item (elt);
44       if (pc != il->column_l ())
45         {
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*/ 
49         }
50
51       if (to_boolean (il->get_grob_property ("no-spacing-rods")))
52         {
53           continue;
54         }
55
56       Interval iv (il->extent (pc, X_AXIS));
57       if (!iv.empty_b ())
58         {
59           w.unite (iv);
60         }
61     }
62
63   SCM pad = me->get_grob_property ("padding");
64
65   if (gh_number_p (pad))
66   {
67     w[RIGHT] += gh_scm2double (pad)/2;
68     w[LEFT] -= gh_scm2double (pad)/2;    
69   }
70   
71   return w;
72  // add this->offset_ ? this-> relative_coordinate ()? 
73 }
74
75
76