]> git.donarmstrong.com Git - lilypond.git/blob - lily/single-malt-grouping-item.cc
e12f7ed0c1857fcbcca1385eb0e10660337a90cf
[lilypond.git] / lily / single-malt-grouping-item.cc
1 /*   
2   single-malt-grouping-item.cc --  implement Single_malt_grouping_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 "single-malt-grouping-item.hh"
11 #include "paper-column.hh"
12 #include "debug.hh"
13 #include "group-interface.hh"
14
15 Single_malt_grouping_item ::Single_malt_grouping_item()
16 {
17   set_elt_property ("transparent", SCM_BOOL_T);
18   set_elt_pointer ("elements", SCM_EOL);
19
20   // this is weird! , but needed!
21   set_extent_callback (0, X_AXIS);
22   set_extent_callback (0,  Y_AXIS);
23
24 }
25
26 void
27 Single_malt_grouping_item::add_item (Item* i)
28 {
29   assert (i);
30   Pointer_group_interface (this).add_element (i);
31
32   add_dependency (i);
33 }
34
35 Interval
36 Single_malt_grouping_item::my_width () const
37 {
38   Paper_column * pc = column_l ();
39   Interval w;
40   
41   for (SCM s = get_elt_pointer ("elements"); gh_pair_p (s); s = gh_cdr (s))
42     {
43       SCM elt = gh_car (s);
44       if (!SMOB_IS_TYPE_B(Score_element, elt))
45         continue;
46       
47       Item *il = dynamic_cast<Item*> (SMOB_TO_TYPE (Score_element, elt));
48       if (pc != il->column_l ())
49         {
50           /* this shouldn't happen, but let's continue anyway. */
51           programming_error (_("Single_malt_grouping_item:  I've been drinking too much"));
52           continue;             /*UGH UGH*/ 
53         }
54
55       if (to_boolean (il->get_elt_property ("no-spacing-rods")))
56         {
57           continue;
58         }
59
60       Interval iv (il->extent (X_AXIS));
61       if (!iv.empty_b ())
62         {
63           Real off = il->relative_coordinate (pc, X_AXIS);
64           w.unite  (iv + off);
65         }
66     }
67
68   return w;
69  // add this->offset_ ? this-> relative_coordinate ()? 
70 }
71
72
73