Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(44)

Unified Diff: lily/time-signature.cc

Issue 6419064: line_count related patches in a single commit for review Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Patch Set: new version of line-count fixes, without bar-line Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lily/slur-scoring.cc ('k') | lily/vaticana-ligature.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lily/time-signature.cc
diff --git a/lily/time-signature.cc b/lily/time-signature.cc
index ad553e4229268800e94763b3d81de959213272c2..082b62a93c0f45bd0d7f786fd4808e22dde1496b 100644
--- a/lily/time-signature.cc
+++ b/lily/time-signature.cc
@@ -23,6 +23,7 @@
#include "font-interface.hh"
#include "international.hh"
#include "output-def.hh"
+#include "staff-symbol.hh"
#include "staff-symbol-referencer.hh"
#include "text-interface.hh"
#include "warn.hh"
@@ -57,8 +58,35 @@ Time_signature::print (SCM smob)
else
m = numbered_time_signature (me, n, d);
- if (Staff_symbol_referencer::line_count (me) % 2 == 0)
- m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
+ /*
+ position the signature centred on the staff line
+ nearest to the middle of the staff
+ */
+ if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me))
+ {
+ std::vector<Real> const linepos = Staff_symbol::line_positions (staff);
+ if (!linepos.empty ())
+ {
+ Interval const span = Staff_symbol::line_span (staff);
+ Real const mid = span.center ();
+ Real pos = linepos.front ();
+ Real dist = fabs (pos - mid);
+ for (std::vector<Real>::const_iterator
+ i = linepos.begin (), e = linepos.end ();
+ ++i != e;)
+ {
+ double const d = fabs (*i - mid);
+ if (d < dist)
+ {
+ pos = *i;
+ dist = d;
+ }
+ }
+
+ m.translate_axis
+ (pos * Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
+ }
+ }
return m.smobbed_copy ();
}
« no previous file with comments | « lily/slur-scoring.cc ('k') | lily/vaticana-ligature.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b