summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2007-03-26 01:17:44 -0300
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2007-03-26 01:17:44 -0300
commit16a385de7fce2b05cd70e1c7de3d0b52df62edfc (patch)
tree971723d123ed1b0f58dad5153c207e42e2cd431f
parent12e2badcb781322c0449e69dc820efe961fe26ce (diff)
Fix #281.
Move X-parent rewire to calc-positioning-done from calc-direction. Now, we can run this if direction is manually set too.
-rw-r--r--input/regression/script-center-seconds.ly13
-rw-r--r--lily/include/script-interface.hh1
-rw-r--r--lily/script-interface.cc23
-rw-r--r--scm/define-grobs.scm7
-rw-r--r--scm/output-lib.scm7
5 files changed, 43 insertions, 8 deletions
diff --git a/input/regression/script-center-seconds.ly b/input/regression/script-center-seconds.ly
new file mode 100644
index 0000000000..765d47a367
--- /dev/null
+++ b/input/regression/script-center-seconds.ly
@@ -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>_.
+}
diff --git a/lily/include/script-interface.hh b/lily/include/script-interface.hh
index 12ba90a8fe..157ce77bf7 100644
--- a/lily/include/script-interface.hh
+++ b/lily/include/script-interface.hh
@@ -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));
};
diff --git a/lily/script-interface.cc b/lily/script-interface.cc
index 8e142179b4..6db959113e 100644
--- a/lily/script-interface.cc
+++ b/lily/script-interface.cc
@@ -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 "
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 3e97d102cb..82d377ccdc 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -612,6 +612,7 @@
(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)
@@ -686,6 +687,8 @@
(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.
@@ -1401,12 +1404,13 @@
;; 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)
@@ -1801,6 +1805,7 @@
(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)
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 3cfefc8f3e..eea7614376 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -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))