]> git.donarmstrong.com Git - lilypond.git/blob - lily/hara-kiri-group-spanner.cc
release: 1.3.68
[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_pointer ("items-worth-living", SCM_EOL);
20 }
21
22 void 
23 Hara_kiri_group_spanner::add_interesting_item (Score_element* me,Item* n)
24 {
25   me->add_dependency (n);
26   Pointer_group_interface (me, "items-worth-living").add_element (n);
27
28 }
29
30 void
31 Hara_kiri_group_spanner::consider_suicide(Score_element*me)
32 {
33   SCM worth = me->get_elt_pointer ("items-worth-living");
34   if (gh_pair_p (worth))
35     return ;
36
37   Link_array<Score_element> childs = Axis_group_interface (me).get_children ();
38   for (int i = 0; i < childs.size (); i++)
39     childs[i]->suicide ();
40
41
42   /*
43     very appropriate name here :-)
44    */
45   me->suicide ();
46 }
47
48
49
50 /*
51   We can't rely on offsets and dimensions of elements in a hara-kiri
52   group. Use a callback to make sure that hara-kiri has been done
53   before asking for offsets.  */
54 Real
55 Hara_kiri_group_spanner::force_hara_kiri_callback (Score_element *elt, Axis a)
56 {
57   while (elt
58          && to_boolean (elt->get_elt_property ("hara-kiri-interface")))
59     elt = elt->parent_l(a);
60
61   if (elt)
62     {
63       Hara_kiri_group_spanner::consider_suicide (elt);
64     }
65
66   return 0.0;
67 }