2 hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "hara-kiri-group-spanner.hh"
12 #include "paper-column.hh"
13 #include "pointer-group-interface.hh"
14 #include "axis-group-interface.hh"
19 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, y_extent, 1);
21 Hara_kiri_group_spanner::y_extent (SCM smob)
23 Grob *me = unsmob_grob (smob);
24 consider_suicide (me);
25 return Axis_group_interface::generic_group_extent (me, Y_AXIS);
29 Hara_kiri_group_spanner::consider_suicide (Grob *me)
31 Spanner *sp = dynamic_cast<Spanner *> (me);
32 if (!to_boolean (me->get_property ("remove-empty")))
35 extract_grob_set (me, "items-worth-living", worth);
39 bool remove_first = to_boolean (me->get_property ("remove-first"));
41 && ((sp->original () && broken_spanner_index (sp) == 0)
42 || Paper_column::get_rank (sp->get_bound (LEFT)->get_column ())
46 Link_array<Grob> childs;
47 Axis_group_interface::get_children (me, &childs);
48 for (int i = 0; i < childs.size (); i++)
49 childs[i]->suicide ();
52 very appropriate name here :-)
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 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, force_hara_kiri_callback, 2);
63 Hara_kiri_group_spanner::force_hara_kiri_callback (SCM smob, SCM axis)
65 Grob *me = unsmob_grob (smob);
68 assert (scm_to_int (axis) == Y_AXIS);
69 consider_suicide (me);
70 return scm_from_double (0.0);
73 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, force_hara_kiri_in_parent_callback, 2);
75 Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM smob, SCM axis)
77 Grob *daughter = unsmob_grob (smob);
78 Axis a = (Axis) scm_to_int (axis);
80 force_hara_kiri_callback (daughter->get_parent (a)->self_scm (), axis);
81 return scm_from_double (0.0);
85 Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n)
87 Pointer_group_interface::add_grob (me, ly_symbol2scm ("items-worth-living"), n);
90 ADD_INTERFACE (Hara_kiri_group_spanner, "hara-kiri-group-interface",
91 "A group spanner that keeps track of interesting items. If it "
92 "doesn't contain any after linebreaking, then it "
93 "will remove itself and all its children.",