lilypond-devel
[Top][All Lists]
Advanced

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

Measure 'staff-padding' to reference points, as claimed in its docstring


From: k-ohara5a5a
Subject: Measure 'staff-padding' to reference points, as claimed in its docstring (issue 7005056)
Date: Fri, 06 Sep 2013 03:02:11 +0000

Reviewers: ,

Message:
DynamicText is shifted to that the center of the 'm' in "mf" is at the
reference line of the DynamicLineSpanner.

A shift of reference line to half the ex-height in LyricText would help
people who want truly centered lyrics, but that is another issue.

The right way to shift the reference line in TextScripts would seem to
be on each string of text, because we can mix font-sizes in markup.
This could change the alignment in hand-crafted markup though, so I did
not move this reference line.  With the reference line for text still at
the baseline, there there is no good default 'staff-padding for
TextScripts, because we generally want the baseline further below the
staff that above it.



https://codereview.appspot.com/7005056/diff/29001/scm/output-lib.scm
File scm/output-lib.scm (right):

https://codereview.appspot.com/7005056/diff/29001/scm/output-lib.scm#newcode861
scm/output-lib.scm:861:
Below is an alternative function for finding the point in "mf" that
should line up with the haripin: Y-offset =  #(center-of-text "m")

Its only benefit is if people use dynamic fonts where font-size=0 has an
ex-height significantly different from that in Feta.  If used by
default, though, it costs an extra stencil-creation per dynamic.

Description:
three commits

Measure 'staff-padding' to reference points; issue 3026
 lily/side-position-interface.cc |    6 +++---
 scm/define-grobs.scm            |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

DynamicText: reference point at middle of ex-height
 scm/define-grobs.scm |    3 +--
 scm/output-lib.scm   |   12 ++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Doc: update staff-padding
 Documentation/learning/tweaks.itely    |   20 ++++++++------------
 Documentation/notation/keyboards.itely |    2 +-
 Documentation/notation/spacing.itely   |    6 +++---
 3 files changed, 12 insertions(+), 16 deletions(-)


Please review this at https://codereview.appspot.com/7005056/

Affected files (+30, -23 lines):
  M Documentation/learning/tweaks.itely
  M Documentation/notation/keyboards.itely
  M Documentation/notation/spacing.itely
  M lily/side-position-interface.cc
  M scm/define-grobs.scm
  M scm/output-lib.scm


Index: Documentation/learning/tweaks.itely
diff --git a/Documentation/learning/tweaks.itely b/Documentation/learning/tweaks.itely index 3efb7fb07bbc79b53cb77d7cf43ae4828ca8a1eb..8b4eab6101791c08a1de72944c09e6ac754fa42a 100644
--- a/Documentation/learning/tweaks.itely
+++ b/Documentation/learning/tweaks.itely
@@ -2703,9 +2703,9 @@ space between any object which supports the
 @code{side-position-interface} and the nearest other object (generally
 the note or the staff lines); @code{staff-padding} applies only to
 those objects which are always set outside the staff -- it controls
-the minimum amount of space that should be inserted between that
-object and the staff.  Note that @code{staff-padding} has no effect on
-objects which are positioned relative to the note rather than the
+the minimum distance from the staff to the oustide-staff object.
+Note that @code{staff-padding} has no effect on
+objects that are positioned relative to the note rather than the
 staff, even though it may be overridden without error for such objects
 -- it is simply ignored.

@@ -2970,9 +2970,9 @@ note head by overriding @code{right-padding}.
 @cindex objects, aligning on a baseline

 @code{staff-padding} can be used to align objects such as dynamics
-along a baseline at a fixed height above the staff, rather than at a
-height dependent on the position of the note to which they are
-attached.  It is not a property of @code{DynamicText} but of
+along a baseline at a fixed distance from the staff, when no other
+notation forces them further from the staff.
+It is not a property of @code{DynamicText} but of
 @code{DynamicLineSpanner}.  This is because the baseline should apply
 equally to @strong{all} dynamics, including those created as extended
 spanners.  So this is the way to align the dynamic marks in the
@@ -2984,12 +2984,8 @@ example taken from the previous section:
 @cindex staff-padding property, example

 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
-\dynamicUp
-% Extend width by 1 unit
-\override DynamicText.extra-spacing-width = #'(-0.5 . 0.5)
-% Align dynamics to a base line 2 units above staff
-\override DynamicLineSpanner.staff-padding = #2
-a4\f b\mf a\mp b\p
+\override DynamicLineSpanner.staff-padding = #3
+a4\f b\mf a\p b\mp
 @end lilypond


Index: Documentation/notation/keyboards.itely
diff --git a/Documentation/notation/keyboards.itely b/Documentation/notation/keyboards.itely index c0bdb0e4b1a8ecbdc2d2f9ca61a9592932409144..93359f30a925115597d271584258b145de08ca42 100644
--- a/Documentation/notation/keyboards.itely
+++ b/Documentation/notation/keyboards.itely
@@ -206,7 +206,7 @@ Overlapping notation can result when voices cross staves:
   \new Staff = "up" {
     \voiceOne
     % Make space for fingering in the cross-staff voice
-    \once\override DynamicLineSpanner.staff-padding = #3.4
+    \once\override DynamicLineSpanner.staff-padding = #4
     e''2\p\< d''\>
     c''1\!
   }
Index: Documentation/notation/spacing.itely
diff --git a/Documentation/notation/spacing.itely b/Documentation/notation/spacing.itely index 91eeefa4e82687acb6fb7b6f40a57b5c6c6e61e6..d94aa6d920b2833f2b2bf2e068a9d29c1e057b08 100644
--- a/Documentation/notation/spacing.itely
+++ b/Documentation/notation/spacing.itely
@@ -1982,7 +1982,7 @@ given in the following table:
 @item @code{ChordNames}  @tab baseline
 @item @code{NoteNames}   @tab baseline
 @item @code{Lyrics}      @tab baseline
address@hidden @code{Dynamics}    @tab vertical center
address@hidden @code{Dynamics}    @tab mid-height of @q{m}
 @item @code{FiguredBass} @tab highest point
 @item @code{FretBoards}  @tab top line
 @end multitable
@@ -2044,10 +2044,10 @@ labelContext =
   \new Lyrics { \lyrics { \skip 1*2 | ghijk1 | } }
 >>

-%% The reference point for Dynamics is its vertical center
+%% The reference point for Dynamics is the midlne of 'm' in the font
 <<
   \new RhythmicStaff {
-    \set RhythmicStaff.instrumentName = #"vertical center "
+    \set RhythmicStaff.instrumentName = #"mid-height "
     \labelContext "Dynamics" s1*3
   }
   \new Dynamics { s1\mp s\fp }
Index: lily/side-position-interface.cc
diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index e3830d3d2f7d5484f8e3291e58385808aa64f491..54b5cb162b5c25739ddd15a7061062e9e75c38f6 100644
--- a/lily/side-position-interface.cc
+++ b/lily/side-position-interface.cc
@@ -360,8 +360,8 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
     }

   /*
-    Maintain a minimum distance to the staff. This is similar to side
-    position with padding, but it will put adjoining objects on a row if
+ Ensure 'staff-padding' from my refpoint to the staff. This is similar to + side-position with padding, but it will put adjoining objects on a row if
     stuff sticks out of the staff a little.
   */
   Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
@@ -404,7 +404,7 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i Real staff_position = staff->maybe_pure_coordinate (common, Y_AXIS, pure, start, end); Interval staff_extent = staff->maybe_pure_extent (staff, a, pure, start, end);
           Real diff = (dir * staff_extent[dir] + staff_padding
-                       - dir * (total_off + iv[-dir])
+                       - dir * total_off
                        + dir * (staff_position - parent_position));
           total_off += dir * max (diff, 0.0);
         }
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 184d086b304216b0fb21d977a83ed5d3728c4ec1..e8038c873dd4f3d05a60da66cf9be0ecd001a4c4 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -583,7 +583,7 @@
         (color . ,(grob::inherit-parent-property
                    X 'color))
         (self-alignment-X . ,CENTER)
-        (staff-padding . 0.2)
+        (staff-padding . 0.7)
         (stencil . ,ly:text-interface::print)
         (X-offset . ,(ly:make-simple-closure
                       `(,+
@@ -844,12 +844,11 @@
         (positioning-done . ,ly:script-interface::calc-positioning-done)
         (right-padding . 0.5)
         (self-alignment-X . ,CENTER)
-        (self-alignment-Y . ,CENTER)
         (stencil . ,ly:text-interface::print)
         (vertical-skylines . ,grob::always-vertical-skylines-from-stencil)
         (Y-extent . ,grob::always-Y-extent-from-stencil)
         (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
-        (Y-offset . ,self-alignment-interface::y-aligned-on-self)
+        (Y-offset . ,(scale-by-font-size -0.6))
         (meta . ((class . Item)
                  (interfaces . (dynamic-interface
                                 dynamic-text-interface
@@ -1669,7 +1668,7 @@
         (outside-staff-priority . 400)
         (padding . 0.5)
         (shorten-pair . (0.0 . -0.6))
-        (staff-padding . 1.0)
+        (staff-padding . 2.0)
         (stencil . ,ly:ottava-bracket::print)
         (style . dashed-line)
         (vertical-skylines . ,grob::unpure-vertical-skylines-from-stencil)
Index: scm/output-lib.scm
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 23ff2640bb4f3efce22411efd1b6fbb907999a15..a54291a4a06d0bb4d5e6dcde2ccc194639f4f259 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -854,6 +854,18 @@ and duration-log @var{log}."
    the previous calculated offset value."
   prev-offset)

+(define-public (scale-by-font-size x)
+  (ly:make-unpure-pure-container
+    (lambda (grob)
+      (* x (magstep (ly:grob-property grob 'font-size 0))))))
+
+(define-public (center-of-text text)
+  (ly:make-unpure-pure-container
+    (lambda (grob)
+      (- (interval-center (ly:stencil-extent
+                            (grob-interpret-markup grob text)
+                            Y))))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;






reply via email to

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