Reviewers: ,
Message:
I had added a Rietveld issue about this, but the example on my Rietveld
issue was bunk so I pulled it. The current width function in
arpeggio.cc does not give the correct width for chord brackets or chord
slurs, nor does it give the correct width for arpeggios with arrows (I
think). This should fix it w/o causing problems w/ the print function
triggering a vertical alignment.
It is kinda code-dupy, so if anyone has suggestions for how to roll this
into one unified function, I'll take it!
Description:
Better width functions for the current arpeggio print functions.
Please review this at http://codereview.appspot.com/4517051/
Affected files:
M lily/arpeggio.cc
M lily/include/arpeggio.hh
Index: lily/arpeggio.cc
diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc
index
b609f846d7a350fd6a541dec4bb2540285d4bcea..70c8c82a89438428cb6021504f227591bf804d71
100644
--- a/lily/arpeggio.cc
+++ b/lily/arpeggio.cc
@@ -92,6 +92,13 @@ MAKE_SCHEME_CALLBACK (Arpeggio, print, 1);
SCM
Arpeggio::print (SCM smob)
{
+ return internal_print (smob);
+}
+
+MAKE_SCHEME_CALLBACK (Arpeggio, internal_print, 1);
+SCM
+Arpeggio::internal_print (SCM smob)
+{
Grob *me = unsmob_grob (smob);
Interval heads = robust_scm2interval (me->get_property ("positions"),
Interval ())
@@ -156,10 +163,32 @@ Arpeggio::print (SCM smob)
/* Draws a vertical bracket to the left of a chord
Chris Jackson <ch...@fluffhouse.org.uk> */
+/*
+ We have to do a callback, because print () triggers a
+ vertical alignment if it is cross-staff.
+*/
+MAKE_SCHEME_CALLBACK (Arpeggio, chord_bracket_width, 1);
+SCM
+Arpeggio::chord_bracket_width (SCM smob)
+{
+ Stencil *s = unsmob_stencil (internal_brew_chord_bracket (smob));
+ if (!s)
+ return ly_interval2scm (Interval (0,0));
+
+ return ly_interval2scm (s->extent (X_AXIS));
+}
+
MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1);
SCM
Arpeggio::brew_chord_bracket (SCM smob)
{
+ return internal_brew_chord_bracket (smob);
+}
+
+MAKE_SCHEME_CALLBACK (Arpeggio, internal_brew_chord_bracket, 1);
+SCM
+Arpeggio::internal_brew_chord_bracket (SCM smob)
+{
Grob *me = unsmob_grob (smob);
Interval heads = robust_scm2interval (me->get_property ("positions"),
Interval ())
@@ -175,10 +204,32 @@ Arpeggio::brew_chord_bracket (SCM smob)
return mol.smobbed_copy ();
}
+/*
+ We have to do a callback, because print () triggers a
+ vertical alignment if it is cross-staff.
+*/
+MAKE_SCHEME_CALLBACK (Arpeggio, chord_slur_width, 1);
+SCM
+Arpeggio::chord_slur_width (SCM smob)
+{
+ Stencil *s = unsmob_stencil (internal_brew_chord_slur (smob));
+ if (!s)
+ return ly_interval2scm (Interval (0,0));
+
+ return ly_interval2scm (s->extent (X_AXIS));
+}
+
MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_slur, 1);
SCM
Arpeggio::brew_chord_slur (SCM smob)
{
+ return internal_brew_chord_slur (smob);
+}
+
+MAKE_SCHEME_CALLBACK (Arpeggio, internal_brew_chord_slur, 1);
+SCM
+Arpeggio::internal_brew_chord_slur (SCM smob)
+{
Grob *me = unsmob_grob (smob);
SCM dash_definition = me->get_property ("dash-definition");
Interval heads = robust_scm2interval (me->get_property ("positions"),
@@ -206,8 +257,11 @@ MAKE_SCHEME_CALLBACK (Arpeggio, width, 1);
SCM
Arpeggio::width (SCM smob)
{
- Grob *me = unsmob_grob (smob);
- return ly_interval2scm (get_squiggle (me).extent (X_AXIS));
+ Stencil *s = unsmob_stencil (internal_print (smob));
+ if (!s)
+ return ly_interval2scm (Interval (0,0));
+
+ return ly_interval2scm (s->extent (X_AXIS));
}
MAKE_SCHEME_CALLBACK (Arpeggio, pure_height, 3);
Index: lily/include/arpeggio.hh
diff --git a/lily/include/arpeggio.hh b/lily/include/arpeggio.hh
index
094afe687b329c765ab2288a2e010b09be33cefc..7ca7a54b41e97eef964b9395dd97d284a0361417
100644
--- a/lily/include/arpeggio.hh
+++ b/lily/include/arpeggio.hh
@@ -29,10 +29,15 @@ class Arpeggio
public:
static Grob *get_common_y (Grob *);
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (internal_print, (SCM));
DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
DECLARE_SCHEME_CALLBACK (brew_chord_bracket, (SCM));
DECLARE_SCHEME_CALLBACK (brew_chord_slur, (SCM));
+ DECLARE_SCHEME_CALLBACK (internal_brew_chord_bracket, (SCM));
+ DECLARE_SCHEME_CALLBACK (internal_brew_chord_slur, (SCM));
DECLARE_SCHEME_CALLBACK (width, (SCM));
+ DECLARE_SCHEME_CALLBACK (chord_bracket_width, (SCM));
+ DECLARE_SCHEME_CALLBACK (chord_slur_width, (SCM));
DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
DECLARE_GROB_INTERFACE();
};
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel