Add break-align-anchor property and use it for barlines.
return Stencil ();
}
+MAKE_SCHEME_CALLBACK (Bar_line, calc_anchor, 1)
+SCM
+Bar_line::calc_anchor (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ Real kern = robust_scm2double (me->get_property ("kern"), 1);
+ Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
+ string str = robust_scm2string (me->get_property ("glyph-name"), "");
+
+ /* we put the anchor in the center of the barline, unless we are
+ a repeat bar, in which case we put the anchor in the center of
+ the barline without the dots. */
+ Interval ext = me->extent (me, X_AXIS);
+ Real anchor = ext.center ();
+
+ Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
+ Real dot_width = dot.extent (X_AXIS).length () + kern * staffline;
+ if (str == "|:")
+ anchor -= dot_width / 2;
+ else if (str == ":|")
+ anchor += dot_width / 2;
+
+ return scm_from_double (anchor);
+}
ADD_INTERFACE (Bar_line,
else
which_edge = RIGHT;
- Grob *common = me->common_refpoint (elements[last_idx_found], X_AXIS);
+ Grob *alignment_parent = elements[last_idx_found];
+ Grob *common = me->common_refpoint (alignment_parent, X_AXIS);
+ Real anchor = robust_scm2double (alignment_parent->get_property ("break-align-anchor"), 0);
- return scm_from_double (robust_relative_extent (elements[last_idx_found], common, X_AXIS)[which_edge]
- - me->relative_coordinate (common, X_AXIS));
+ return scm_from_double (alignment_parent->relative_coordinate (common, X_AXIS)
+ - me->relative_coordinate (common, X_AXIS)
+ + anchor);
+}
+
+MAKE_SCHEME_CALLBACK (Break_aligned_interface, calc_anchor, 1)
+SCM
+Break_aligned_interface::calc_anchor (SCM grob)
+{
+ Grob *me = unsmob_grob (grob);
+ Real avg = 0.0;
+ int count = 0;
+
+ /* average the anchors of those children that have it set */
+ extract_grob_set (me, "elements", elts);
+ for (vsize i = 0; i < elts.size (); i++)
+ {
+ SCM anchor = elts[i]->get_property ("break-align-anchor");
+ if (scm_is_number (anchor))
+ {
+ count++;
+ avg += scm_to_double (anchor);
+ }
+ }
+
+ return scm_from_double (count > 0 ? avg / count : 0);
}
ADD_INTERFACE (Break_alignable_interface,
"See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147\n",
/* properties */
+ "break-align-anchor "
"break-align-symbol "
"space-alist "
);
static Stencil simple_barline (Grob *, Real wid, Real height, bool rounded);
DECLARE_SCHEME_CALLBACK (calc_bar_size, (SCM));
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_anchor, (SCM));
};
#endif // BAR_HH
struct Break_aligned_interface
{
+ DECLARE_SCHEME_CALLBACK (calc_anchor, (SCM element));
DECLARE_GROB_INTERFACE();
};
printing of the bracket. Setting the property to @code{if-no-beam}
makes it print only if there is no beam associated with this tuplet
bracket.")
+ (break-align-anchor ,number? "Grobs aligned to this break-align
+grob will have their X-offsets shifted by this number. In barlines,
+for example, this is used to position grobs relative to the (visual)
+center of the barline.")
(break-align-symbol ,symbol? "This key is used for aligning and
spacing breakable items.")
(break-align-orders ,vector? "Defines the order in which
(BarLine
. (
(break-align-symbol . staff-bar)
+ (break-align-anchor . ,ly:bar-line::calc-anchor)
(glyph . "|")
(gap . 0.4)
(layer . 0)
. (
(axes . (0))
(X-extent . ,ly:axis-group-interface::width)
+ (break-align-anchor . ,ly:break-aligned-interface::calc-anchor)
(meta . ((class . Item)
(interfaces . (break-aligned-interface
axis-group-interface))))))