Hi Victor, 2008/7/2 V!ctor Adán <[EMAIL PROTECTED]>: > Hello All, > > I'm using Staff contexts with the "line-positions" property modified to fit > my capricious needs. > In doing so I'm running into 2 problems (please see attached png): > > 1. When I set lines to odd numbers, the duration dots of the note heads fall > *on* the staff lines rather than within the spaces. It's like Lilypond is > hard-coded to put the dots on the even number slots rather that looking at > the "line-positions" attribute to decide on the best place to put these > dots. Is there a way to change this? > > 2. It seems that the line-positions must be centered at 0, otherwise (as in > the example below), the bar line is drawn off-center, either moved up or > down. Is there a way to have the barline fit the boundaries of the two > outermost staff lines exactly without having the line-positions 0-centered? > I found this mail by Kevin Dalley in the mailing list, so it seems this has > been an issue before... > http://www.nabble.com/Does-the-center-of-the-staff-need-to-be-zero--p9507190.html
It's a good thing you've brought this up, since that post from Kevin and another he posted a few days later include patches which fix both of the issues you're experiencing; there were some problems with the patches which prevented them being applied for testing, so they seem to have fallen by the wayside. I certainly think they would be a useful improvement on the current behaviour, so I've tidied the patches up to make them work with the current version; attached is the output of your snippet with the patches applied. Regards, Neil
<<attachment: test.png>>
From 7cd7b83dc9591426384ec6e4e253dadfae05ad61 Mon Sep 17 00:00:00 2001
From: Kevin Dalley <[EMAIL PROTECTED]>
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 [EMAIL PROTECTED]
+"
+}
+\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
From 56d793a12307e44d79c63a14f72152ba7c664763 Mon Sep 17 00:00:00 2001
From: Kevin Dalley <[EMAIL PROTECTED]>
Date: Fri, 4 Jul 2008 22:01:31 +0100
Subject: [PATCH] Corrected on_line for better ledger lines for different staves.
---
input/regression/ledger-lines-varying-staves.ly | 50 +++++++++++++++++++++++
lily/include/staff-symbol.hh | 1 +
lily/staff-symbol-referencer.cc | 3 +-
lily/staff-symbol.cc | 29 +++++++++++++-
4 files changed, 80 insertions(+), 3 deletions(-)
create mode 100644 input/regression/ledger-lines-varying-staves.ly
diff --git a/input/regression/ledger-lines-varying-staves.ly b/input/regression/ledger-lines-varying-staves.ly
new file mode 100644
index 0000000..7d9f0e0
--- /dev/null
+++ b/input/regression/ledger-lines-varying-staves.ly
@@ -0,0 +1,50 @@
+\version "2.11.51"
+\header {
+ texidoc = "Ledger lines should appear at every other location
+for a variety of staves using both @code{line-count} and
[EMAIL PROTECTED]"
+}
+
+notes = \relative c' {
+ c1 | d | e | f
+ g1 | a | b | c
+ d1 | e | f | g
+ a1
+}
+
+\new Staff {
+ % upper and lower lines both odd
+ #(define mylines '(-1 0 1))
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \override Staff.StaffSymbol #'line-positions = #mylines
+ \notes
+}
+
+\new Staff {
+ % upper and lower lines both even
+ #(define mylines '(-2 0 2))
+ \override Staff.StaffSymbol #'line-positions = #mylines
+
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \notes
+}
+
+\new Staff {
+ % lower line odd, upper line even
+ #(define mylines '(-1 0 2))
+ \override Staff.StaffSymbol #'line-positions = #mylines
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \notes
+}
+
+\new Staff {
+ % odd line count
+ \override Staff.StaffSymbol #'line-count = #5
+ \notes
+}
+
+\new Staff {
+ % even line count
+ \override Staff.StaffSymbol #'line-count = #4
+ \notes
+}
diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh
index 4dacde8..6791e7b 100644
--- a/lily/include/staff-symbol.hh
+++ b/lily/include/staff-symbol.hh
@@ -24,6 +24,7 @@ public:
static int get_steps (Grob *);
static int line_count (Grob *);
+ static bool on_line (Grob *me, int pos);
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (height, (SCM));
DECLARE_GROB_INTERFACE();
diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc
index e8ef99f..d623bd3 100644
--- a/lily/staff-symbol-referencer.cc
+++ b/lily/staff-symbol-referencer.cc
@@ -35,8 +35,7 @@ Staff_symbol_referencer::on_staff_line (Grob *me)
bool
Staff_symbol_referencer::on_line (Grob *me, int pos)
{
- int sz = line_count (me) - 1;
- return ((pos + sz) % 2) == 0;
+ return Staff_symbol::on_line (me, pos);
}
bool
diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc
index d4aa9e1..df441d4 100644
--- a/lily/staff-symbol.cc
+++ b/lily/staff-symbol.cc
@@ -167,8 +167,35 @@ Staff_symbol::height (SCM smob)
return ly_interval2scm (y_ext);
}
+bool
+Staff_symbol::on_line (Grob *me, int pos)
+{
+ SCM line_positions = me->get_property ("line-positions");
+ if (scm_is_pair (line_positions))
+ {
+ Real min_line = SCM_FLTMAX;
+ Real max_line = -SCM_FLTMAX;
+ for (SCM s = line_positions; scm_is_pair (s); s = scm_cdr (s))
+ {
+ Real current_line = scm_to_double (scm_car (s));
+ if (pos == current_line)
+ return true;
+ if (current_line > max_line)
+ max_line = current_line;
+ if (current_line < min_line)
+ min_line = current_line;
+
+ }
+ if (pos < min_line)
+ return (( (int) (rint (pos - min_line)) % 2) == 0);
+ if (pos > max_line)
+ return (( (int) (rint (pos - max_line)) % 2) == 0);
-
+ return false;
+ }
+ else
+ return ((abs (pos + line_count (me)) % 2) == 1);
+}
ADD_INTERFACE (Staff_symbol,
"This spanner draws the lines of a staff. A staff symbol"
--
1.5.4.3
_______________________________________________ lilypond-user mailing list [email protected] http://lists.gnu.org/mailman/listinfo/lilypond-user
