lilypond-1.3.66
[lilypond.git] / lily / hara-kiri-group-spanner.cc
blob3161032716697aba99f4b6980d71030a37b47919
1 /*
2 hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "axis-group-interface.hh"
11 #include "hara-kiri-group-spanner.hh"
12 #include "debug.hh"
13 #include "item.hh"
17 Hara_kiri_group_spanner::Hara_kiri_group_spanner(SCM s)
18 : Spanner (s)
20 set_elt_pointer ("items-worth-living", SCM_EOL);
23 void
24 Hara_kiri_group_spanner::add_interesting_item (Item* n)
26 add_dependency (n);
27 Pointer_group_interface (this, "items-worth-living").add_element (n);
31 GLUE_SCORE_ELEMENT(Hara_kiri_group_spanner,after_line_breaking);
32 SCM
33 Hara_kiri_group_spanner::member_after_line_breaking ()
35 SCM worth = get_elt_pointer ("items-worth-living");
36 if (gh_pair_p (worth))
37 return SCM_UNDEFINED;
39 Link_array<Score_element> childs = Axis_group_interface (this).get_children ();
40 for (int i = 0; i < childs.size (); i++)
42 Score_element* s = childs[i];
44 if ( line_l () != s->line_l ())
45 programming_error ("Killing other children too");
46 s->suicide ();
50 very appropriate name here :-)
52 suicide ();
53 return SCM_UNDEFINED;
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)
65 while (elt && !dynamic_cast<Hara_kiri_group_spanner const*> (elt))
66 elt = elt->parent_l(a);
68 if (elt)
70 Hara_kiri_group_spanner const * seppuku = dynamic_cast<Hara_kiri_group_spanner const*> (elt);
72 ((Hara_kiri_group_spanner*)seppuku)->member_after_line_breaking ();
76 return 0.0;