2 hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "axis-group-interface.hh"
12 #include "hara-kiri-group-spanner.hh"
17 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner
,y_extent
,2);
19 Hara_kiri_group_spanner::y_extent (SCM element_smob
, SCM scm_axis
)
21 Grob
*me
= unsmob_grob (element_smob
);
22 Axis a
= (Axis
) gh_scm2int (scm_axis
);
25 consider_suicide (me
);
26 return Axis_group_interface::group_extent_callback (me
->self_scm (), scm_axis
);
31 Hara_kiri_group_spanner::consider_suicide (Grob
*me
)
33 SCM worth
= me
->get_grob_property ("items-worth-living");
34 if (gh_pair_p (worth
))
37 Link_array
<Grob
> childs
= Axis_group_interface::get_children (me
);
38 for (int i
= 0; i
< childs
.size (); i
++)
39 childs
[i
]->suicide ();
43 very appropriate name here :-)
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 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner
,force_hara_kiri_callback
,2);
56 Hara_kiri_group_spanner::force_hara_kiri_callback (SCM element_smob
, SCM axis
)
58 Grob
*me
= unsmob_grob (element_smob
);
59 Axis a
= (Axis
) gh_scm2int (axis
);
61 consider_suicide (me
);
62 return gh_double2scm (0.0);
66 MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner
,force_hara_kiri_in_parent_callback
,2);
68 Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM element_smob
, SCM axis
)
70 Grob
*daughter
= unsmob_grob (element_smob
);
71 Axis a
= (Axis
) gh_scm2int (axis
);
73 force_hara_kiri_callback (daughter
->parent_l (a
)->self_scm (), axis
);
74 return gh_double2scm (0.0);
78 Hara_kiri_group_spanner::add_element (Grob
* me
, Grob
*e
)
80 // e->add_offset_callback (force_hara_kiri_in_parent_callback, Y_AXIS);
81 Axis_group_interface::add_element (me
, e
);
86 Hara_kiri_group_spanner::set_interface (Grob
*me
)
88 me
->set_interface (ly_symbol2scm ("hara-kiri-group-interface"));
93 Hara_kiri_group_spanner::has_interface (Grob
*me
)
95 return me
->has_interface (ly_symbol2scm ("hara-kiri-group-interface"));
99 Hara_kiri_group_spanner::add_interesting_item (Grob
* me
,Grob
* n
)
101 me
->add_dependency (n
);
102 Pointer_group_interface::add_element (me
, "items-worth-living",n
);