]> git.donarmstrong.com Git - lilypond.git/blob - lily/hara-kiri-group-spanner.cc
release: 1.3.66
[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 "hara-kiri-group-spanner.hh"
12 #include "debug.hh"
13 #include "item.hh"
14
15 /*
16  */
17 Hara_kiri_group_spanner::Hara_kiri_group_spanner(SCM s)
18   : Spanner (s)
19 {
20   set_elt_pointer ("items-worth-living", SCM_EOL);
21 }
22
23 void 
24 Hara_kiri_group_spanner::add_interesting_item (Item* n)
25 {
26   add_dependency (n);
27   Pointer_group_interface (this, "items-worth-living").add_element (n);
28
29 }
30
31 GLUE_SCORE_ELEMENT(Hara_kiri_group_spanner,after_line_breaking);
32 SCM 
33 Hara_kiri_group_spanner::member_after_line_breaking ()
34 {
35   SCM worth = get_elt_pointer ("items-worth-living");
36   if (gh_pair_p (worth))
37     return SCM_UNDEFINED;
38
39   Link_array<Score_element> childs = Axis_group_interface (this).get_children ();
40   for (int i = 0; i < childs.size (); i++)
41     {
42       Score_element* s = childs[i];
43
44       if ( line_l () != s->line_l ())
45         programming_error ("Killing other children too");
46       s->suicide ();
47     }
48
49   /*
50     very appropriate name here :-)
51    */
52   suicide ();
53   return SCM_UNDEFINED;
54 }
55
56
57
58 /*
59   We can't rely on offsets and dimensions of elements in a hara-kiri
60   group. Use a callback to make sure that hara-kiri has been done
61   before asking for offsets.  */
62 Real
63 Hara_kiri_group_spanner::force_hara_kiri_callback (Score_element const  *elt, Axis a)
64 {
65   while (elt && !dynamic_cast<Hara_kiri_group_spanner const*> (elt))
66     elt = elt->parent_l(a);
67
68   if (elt)
69     {
70       Hara_kiri_group_spanner const  * seppuku = dynamic_cast<Hara_kiri_group_spanner const*> (elt);
71
72       ((Hara_kiri_group_spanner*)seppuku)->member_after_line_breaking ();
73     }
74   
75
76   return 0.0;
77 }