]> git.donarmstrong.com Git - lilypond.git/blob - lily/hara-kiri-group-spanner.cc
partial: 1.3.62.jcn
[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   /*
37     worth == self_scm  is a stupid way to signal that we're done.
38    */
39   if (gh_pair_p (worth))
40     return SCM_UNDEFINED;
41
42   Link_array<Score_element> childs = Axis_group_interface (this).get_children ();
43   for (int i = 0; i < childs.size (); i++)
44     {
45       Score_element* s = childs[i];
46
47       if ( line_l () != s->line_l ())
48         programming_error ("Killing other children too");
49       s->suicide ();
50     }
51
52   /*
53     very appropriate name here :-)
54    */
55   suicide ();
56   return SCM_UNDEFINED;
57 }
58
59
60
61 /*
62   We can't rely on offsets and dimensions of elements in a hara-kiri
63   group. Use a callback to make sure that hara-kiri has been done
64   before asking for offsets.  */
65 Real
66 Hara_kiri_group_spanner::force_hara_kiri_callback (Score_element const  *elt, Axis a)
67 {
68   while (elt && !dynamic_cast<Hara_kiri_group_spanner const*> (elt))
69     elt = elt->parent_l(a);
70
71   if (elt)
72     {
73       Hara_kiri_group_spanner const  * seppuku = dynamic_cast<Hara_kiri_group_spanner const*> (elt);
74
75       ((Hara_kiri_group_spanner*)seppuku)->member_after_line_breaking ();
76     }
77   
78
79   return 0.0;
80 }