From 7cd7b83dc9591426384ec6e4e253dadfae05ad61 Mon Sep 17 00:00:00 2001 From: Kevin Dalley Date: Fri, 4 Jul 2008 22:11:49 +0100 Subject: [PATCH] Draw bar lines correctly when staff is not centered at zero. --- input/regression/non-centered-bar-lines.ly | 12 ++++++++++++ lily/bar-line.cc | 21 +++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 input/regression/non-centered-bar-lines.ly diff --git a/input/regression/non-centered-bar-lines.ly b/input/regression/non-centered-bar-lines.ly new file mode 100644 index 0000000..099d9af --- /dev/null +++ b/input/regression/non-centered-bar-lines.ly @@ -0,0 +1,12 @@ +\version "2.11.51" +\header { + texidoc = "Bar lines are positioned correctly when using custom +staves which are not centered around address@hidden +" +} +\new Staff { + \override Staff.StaffSymbol #'line-positions = #'(1 3 5 7 9) + c''1 + c''1 \bar ":" + c''1 \bar "|." +} diff --git a/lily/bar-line.cc b/lily/bar-line.cc index e51aad7..4d2cbf9 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -94,13 +94,28 @@ Bar_line::compound_barline (Grob *me, string str, Real h, colon.translate_axis (-dist / 2, Y_AXIS); Stencil m; + Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); + Real center = 0; + if (staff) + { + Interval staff_extent = staff->extent (staff, Y_AXIS); + center = staff_extent.center (); + } + if (str == "||:") str = "|:"; if (str == "") - return Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2))); + { + Stencil empty = Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2))); + empty.translate_axis (center, Y_AXIS); + return empty; + } else if (str == "|") - return thin; + { + thin.translate_axis (center, Y_AXIS); + return thin; + } else if (str == "|." || (h == 0 && str == ":|")) { m.add_at_edge (X_AXIS, LEFT, thick, 0); @@ -165,6 +180,8 @@ Bar_line::compound_barline (Grob *me, string str, Real h, { m = dot; } + + m.translate_axis (center, Y_AXIS); return m; } -- 1.5.4.3