]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #281.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 26 Mar 2007 04:17:44 +0000 (01:17 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 26 Mar 2007 04:17:44 +0000 (01:17 -0300)
Move X-parent rewire to calc-positioning-done from calc-direction.
Now, we can run this if direction is manually set too.

input/regression/script-center-seconds.ly [new file with mode: 0644]
lily/include/script-interface.hh
lily/script-interface.cc
scm/define-grobs.scm
scm/output-lib.scm

diff --git a/input/regression/script-center-seconds.ly b/input/regression/script-center-seconds.ly
new file mode 100644 (file)
index 0000000..765d47a
--- /dev/null
@@ -0,0 +1,13 @@
+\header {
+
+  texidoc = "Scripts on chords with seconds remain centered on the extremal note head"
+  }
+
+
+\version "2.10.21"
+\layout { ragged-right = ##t }
+
+\relative c''{
+  <g a>-.
+  <g a>_.
+}
index 12ba90a8fe5edbce261e4f172250c9a73824833a..157ce77bf7ddb7273b05c88bcf6f3ff43406fcc8 100644 (file)
@@ -24,6 +24,7 @@ public:
   DECLARE_GROB_INTERFACE();
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
 };
 
index 8e142179b4f2fbc211cc961ac534eb800a497a27..6db959113e846e182fb0d724956b8dc62a0ffa25 100644 (file)
@@ -42,6 +42,20 @@ Script_interface::get_stencil (Grob *me, Direction d)
   return Stencil ();
 }
 
+MAKE_SCHEME_CALLBACK (Script_interface, calc_positioning_done, 1);
+SCM
+Script_interface::calc_positioning_done (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  if (Grob *par = me->get_parent (X_AXIS))
+    {
+      Grob *stem = Note_column::get_stem (par);
+      if (stem && Stem::first_head (stem))
+       me->set_parent (Stem::first_head (stem), X_AXIS);
+    }
+  return SCM_BOOL_T;
+}
+
 MAKE_SCHEME_CALLBACK (Script_interface, calc_direction, 1);
 SCM
 Script_interface::calc_direction (SCM smob)
@@ -55,13 +69,7 @@ Script_interface::calc_direction (SCM smob)
       d = DOWN;
     }
 
-  if (Grob *par = me->get_parent (X_AXIS))
-    {
-      Grob *stem = Note_column::get_stem (par);
-      if (stem && Stem::first_head (stem))
-       me->set_parent (Stem::first_head (stem), X_AXIS);
-    }
-
+  (void) me->get_property ("positioning-done");
   return scm_from_int (d);
 }
 
@@ -108,6 +116,7 @@ ADD_INTERFACE (Script_interface,
               "An object that is put above or below a note",
               "add-stem-support "
               "avoid-slur "
+              "positioning-done "
               "script-priority "
               "script-stencil "
               "slur "
index 3e97d102cbe51bcca76e94bacbdff45e58934d36..82d377ccdce1b125f6b2fe54fcc7071b0c415313 100644 (file)
 
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
 
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (self-alignment-X . 0)
        (script-priority . 100)
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
+
        (text . ,fingering::calc-text) 
        (font-encoding . fetaNumber)
        (font-size . -5)                ; don't overlap when next to heads.
 
        ;; padding set in script definitions.
        (staff-padding . 0.25)
-       (X-offset . ,ly:self-alignment-interface::centered-on-x-parent)
+       (X-offset . ,script-interface::calc-x-offset)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (side-axis . ,Y)
 
        (stencil . ,ly:script-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
        (font-encoding . fetaMusic)
        (cross-staff . ,ly:script-interface::calc-cross-staff)
        (meta . ((class . Item)
 
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
 
        (outside-staff-priority . 450)
        (avoid-slur . around)
index 3cfefc8f3e58f53aac4f323105d7f769fb32d3ef..eea76143769952258f68b3dd449f889a1d20b7f1 100644 (file)
@@ -676,3 +676,10 @@ centered, X==1 is at the right, X == -1 is at the left."
     (grob-interpret-markup grob
                           (make-fret-diagram-verbose-markup
                            (string-frets->description string-frets string-count)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; scripts
+
+(define-public (script-interface::calc-x-offset grob)
+  (ly:grob-property grob 'positioning-done)
+  (ly:self-alignment-interface::centered-on-x-parent grob))