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