static Grob *accidentals (Grob *me);
static Slice head_positions_interval (Grob *me);
static Grob *first_head (Grob *me);
- static Interval calc_main_heads_extent (Grob *me);
+ static Interval calc_main_extent (Grob *me);
static Grob *get_rest (Grob *me);
static void set_stem (Grob *me, Grob *);
static void add_head (Grob *me, Grob *);
/*
Return extent of the noteheads in the "main column",
- i.e. excluding any suspended noteheads.
+ (i.e. excluding any suspended noteheads), or extent
+ of the rest (if there are no heads).
*/
Interval
-Note_column::calc_main_heads_extent (Grob *me)
+Note_column::calc_main_extent (Grob *me)
{
- if (get_stem (me))
- return first_head (me)->extent (me, X_AXIS);
- else
- {
- // no stems => no suspended noteheads.
- extract_grob_set (me, "note-heads", heads);
- if (heads.size())
- return heads[0]->extent (me, X_AXIS);
- else
- return Interval (0, 0);
- }
+ Grob *main_head;
+ if (get_stem (me))
+ main_head = first_head (me);
+ else
+ {
+ // no stems => no suspended noteheads.
+ extract_grob_set (me, "note-heads", heads);
+ if (heads.size())
+ main_head = heads[0];
+ }
+ Grob *main_item = main_head
+ ? main_head
+ : Grob::unsmob (me->get_object ("rest"));
+
+ return main_item
+ ? main_item->extent (me, X_AXIS)
+ : Interval (0, 0);
}
/*
(him, ly_symbol2scm ("note-column-interface"), a);
else
{
- if (ly_scm2bool(me->internal_get_property (ly_symbol2scm ("X-align-on-main-noteheads")))
+ if (to_boolean (me->get_property ("X-align-on-main-noteheads"))
&& Note_column::has_interface (him))
- he = Note_column::calc_main_heads_extent(him);
+ he = Note_column::calc_main_extent(him);
else
he = him->extent (him, a);
}