[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does the center of the staff need to be zero?
From: |
Kevin Dalley |
Subject: |
Re: Does the center of the staff need to be zero? |
Date: |
Sun, 18 Mar 2007 09:36:18 -0700 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux) |
Here's my patch for the bar line. The ledgers definitely need some
work for staffs which are not centered at zero.
>From ca021c722d6f74690d189c99eff0ccefe420a3b3 Mon Sep 17 00:00:00 2001
From: Kevin Dalley <address@hidden>
Date: Sun, 18 Mar 2007 09:30:57 -0700
Subject: [PATCH] Draw bar lines correctly when staff is not centered at zero.
---
input/regression/non-centered-bar-lines.ly | 8 ++++++++
lily/bar-line.cc | 20 +++++++++++++++++---
2 files changed, 25 insertions(+), 3 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..5f8814d
--- /dev/null
+++ b/input/regression/non-centered-bar-lines.ly
@@ -0,0 +1,8 @@
+\version "2.10"
+\new Staff \with {
+}
+{
+ \override Staff.StaffSymbol #'line-positions = #'(1 3 5 7 9)
+ \time 4/4
+ c''1 | c'' \bar "" | c'' \bar "|."
+}
diff --git a/lily/bar-line.cc b/lily/bar-line.cc
index 0a1c0d9..996eaac 100644
--- a/lily/bar-line.cc
+++ b/lily/bar-line.cc
@@ -69,13 +69,25 @@ 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)));
- else if (str == "|")
+ if (str == ""){
+ Stencil empty = Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h /
2)));
+ empty.translate_axis(center, Y_AXIS);
+ return empty;
+ }
+ else if (str == "|") {
+ thin.translate_axis(center, Y_AXIS);
return thin;
+ }
else if (str == "|." || (h == 0 && str == ":|"))
{
m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);
@@ -140,6 +152,8 @@ Bar_line::compound_barline (Grob *me, string str, Real h,
{
m = dot;
}
+
+ m.translate_axis(center, Y_AXIS);
return m;
}
--
1.5.0.3