2 hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 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
->get_parent (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
);
89 Hara_kiri_group_spanner::add_interesting_item (Grob
* me
,Grob
* n
)
91 me
->add_dependency (n
);
92 Pointer_group_interface::add_grob (me
, ly_symbol2scm ("items-worth-living"),n
);
96 ADD_INTERFACE (Hara_kiri_group_spanner
,"hara-kiri-group-interface",
97 " As Vertical_group_spanner, but keep track of interesting items. If \
98 we don't contain any interesting items after linebreaking, then \
99 gracefully commit suicide. Objective: don't disgrace Lily by \
100 typesetting empty lines in orchestral scores.", \
101 "items-worth-living");