lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Corrected on_line for better ledger lines for different staffs.


From: Kevin Dalley
Subject: [PATCH] Corrected on_line for better ledger lines for different staffs.
Date: Mon, 19 Mar 2007 05:57:44 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux)

Here's a patch for problems with ledger lines when using
line-positions.  

>From 26d959b6b66a7929e1a2ceed8c0456e2113a91fe Mon Sep 17 00:00:00 2001
From: Kevin Dalley <address@hidden>
Date: Mon, 19 Mar 2007 05:32:37 -0700
Subject: [PATCH] Corrected on_line for better ledger lines
for different staffs.
---
 lily/include/staff-symbol.hh    |    1 +
 lily/staff-symbol-referencer.cc |    3 +--
 lily/staff-symbol.cc            |   38 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh
index edf3a0f..6439868 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));  
   static bool has_interface (Grob *);
diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc
index aa45e55..cf6e7ba 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 554b2e2..b4cd2d3 100644
--- a/lily/staff-symbol.cc
+++ b/lily/staff-symbol.cc
@@ -168,7 +168,43 @@ Staff_symbol::height  (SCM smob)
 }
 
 
-
+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, "staff-symbol-interface",
               "This spanner draws the lines of a staff. "
-- 
1.5.0.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]