]> git.donarmstrong.com Git - lilypond.git/blob - lily/separation-item.cc
release: 1.3.68
[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--2000 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 (Score_element*s)
17 {
18   s->set_elt_pointer ("elements", SCM_EOL);
19   s->set_extent_callback (0, X_AXIS);
20   s->set_extent_callback (0,  Y_AXIS);
21 }
22
23 void
24 Separation_item::add_item (Score_element*s,Item* i)
25 {
26   assert (i);
27   Pointer_group_interface (s).add_element (i);
28   s->add_dependency (i);
29 }
30
31 Interval
32 Separation_item::my_width (Score_element *me)
33 {
34   Item *item = dynamic_cast<Item*> (me);
35   Paper_column * pc = item->column_l ();
36   Interval w;
37   
38   for (SCM s =  me->get_elt_pointer ("elements"); gh_pair_p (s); s = gh_cdr (s))
39     {
40       SCM elt = gh_car (s);
41       if (!SMOB_IS_TYPE_B(Score_element, elt))
42         continue;
43       
44       Item *il = dynamic_cast<Item*> (unsmob_element (elt));
45       if (pc != il->column_l ())
46         {
47           /* this shouldn't happen, but let's continue anyway. */
48           programming_error (_("Separation_item:  I've been drinking too much"));
49           continue;             /*UGH UGH*/ 
50         }
51
52       if (to_boolean (il->get_elt_property ("no-spacing-rods")))
53         {
54           continue;
55         }
56
57       Interval iv (il->extent (X_AXIS));
58       if (!iv.empty_b ())
59         {
60           Real off = il->relative_coordinate (pc, X_AXIS);
61           w.unite  (iv + off);
62         }
63     }
64
65   return w;
66  // add this->offset_ ? this-> relative_coordinate ()? 
67 }
68
69
70