]> git.donarmstrong.com Git - lilypond.git/blob - lily/hara-kiri-group-spanner.cc
release: 1.3.69
[lilypond.git] / lily / hara-kiri-group-spanner.cc
1 /*
2   hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7   Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10 #include "axis-group-interface.hh"
11 #include "spanner.hh"
12 #include "hara-kiri-group-spanner.hh"
13 #include "debug.hh"
14 #include "item.hh"
15
16 void
17 Hara_kiri_group_spanner::set_interface (Score_element*me)
18 {
19   me->set_elt_property ("items-worth-living", SCM_EOL);
20   me->add_offset_callback (force_hara_kiri_callback, Y_AXIS);
21   me->set_interface (ly_symbol2scm ("hara-kiri-spanner-interface"));
22 }
23
24 bool
25 Hara_kiri_group_spanner::has_interface (Score_element*me)
26 {
27   return me->has_interface (ly_symbol2scm ("hara-kiri-spanner-interface"));
28 }
29
30 void 
31 Hara_kiri_group_spanner::add_interesting_item (Score_element* me,Score_element* n)
32 {
33   me->add_dependency (n);
34   Pointer_group_interface (me, "items-worth-living").add_element (n);
35 }
36
37 void
38 Hara_kiri_group_spanner::consider_suicide(Score_element*me)
39 {
40   SCM worth = me->get_elt_property ("items-worth-living");
41   if (gh_pair_p (worth))
42     return ;
43
44   Link_array<Score_element> childs = Axis_group_interface::get_children (me);
45   for (int i = 0; i < childs.size (); i++)
46     childs[i]->suicide ();
47
48
49   /*
50     very appropriate name here :-)
51    */
52   me->suicide ();
53 }
54
55
56
57 /*
58   We can't rely on offsets and dimensions of elements in a hara-kiri
59   group. Use a callback to make sure that hara-kiri has been done
60   before asking for offsets.  */
61 Real
62 Hara_kiri_group_spanner::force_hara_kiri_callback (Score_element *elt, Axis a)
63 {
64   assert (a == Y_AXIS);
65   consider_suicide (elt);
66   return 0.0;
67 }
68