Hi,
Here's another patch from me. This time I've added edge-width,
edge-height and shorten-pair properties to the tuplet bracket, which do
the same thing as they do in the text spanner and the pedal bracket.
The test file here illustrates an odd bug which appeared recently -
the tuplet indicator is in a very strange place for some shapes of
beam.
--
chris
Index: input/test/tuplet.ly
===================================================================
RCS file: /home/lilypond/lilypond/input/test/tuplet.ly,v
retrieving revision 1.11
diff -p -u -r1.11 tuplet.ly
--- input/test/tuplet.ly 4 Apr 2001 22:02:42 -0000 1.11
+++ input/test/tuplet.ly 7 Apr 2002 16:33:31 -0000
@@ -1,27 +1,38 @@
-\version "1.3.146"
+\version "1.5.50"
\score {
- \context Voice \notes\relative c'' {
+ \context Voice \notes\relative c'' {
- \times 2/3 { c'8 c,, c }
- \times 2/3 { c'8 c'' c,, }
+ \times 2/3 { c'8 c,, c }
+ \times 2/3 { c'8 c'' c,, }
-
- \times 2/3 { [c8 c c] }
- \times 2/3 { c8 [c c] }
+
+ \times 2/3 { [c8 c c] }
+ \times 2/3 { c8 [c c] }
+
+ \times 2/3 { [c8 c c] }
+ \times 2/4 { r8 [c, c'] r8 }
+
+
+
+ \property Voice.TupletBracket \override #'bracket-visibility = #'if-no-beam
+ \times 2/3 { [c8 c c] }
+ \property Voice.TupletBracket \override #'direction = #1
+ \property Voice.TupletBracket \override #'number-visibility = ##f
+ \times 2/3 { c8 [c c] }
+ \property Voice.TupletBracket \revert #'number-visibility
+
+ \property Voice.TupletBracket \override #'bracket-visibility = ##t
+ \property Voice.TupletBracket \override #'edge-height = #'(0.0 . 0.0)
+ \property Voice.TupletBracket \override #'shorten-pair = #'(2.0 . 2.0)
+ \times 4/6 { c f b b f c}
+ \property Voice.TupletBracket \revert #'edge-height
+ \property Voice.TupletBracket \revert #'shorten-pair
+ \property Voice.TupletBracket \override #'edge-width = #'(-0.5 . 0.5)
+ \times 2/3 { b b b }
+ \property Voice.TupletBracket \revert #'direction
+ \times 2/3 { b b b }
- \times 2/3 { [c8 c c] }
- \times 2/4 { r8 [c, c'] r8 }
-
-
-
- \property Voice.TupletBracket \set #'tuplet-bracket-visibility = #'if-no-beam
- \times 2/3 { [c8 c c] }
- \property Voice.TupletBracket \set #'direction = #1
- \property Voice.TupletBracket \set #'tuplet-number-visibility = ##f
- \times 2/3 { c8 [c c] }
-
-
-}
+ }
}
Index: lily/tuplet-bracket.cc
===================================================================
RCS file: /home/lilypond/lilypond/lily/tuplet-bracket.cc,v
retrieving revision 1.15
diff -p -u -r1.15 tuplet-bracket.cc
--- lily/tuplet-bracket.cc 1 Apr 2002 14:57:56 -0000 1.15
+++ lily/tuplet-bracket.cc 7 Apr 2002 16:33:31 -0000
@@ -163,15 +163,31 @@ Tuplet_bracket::brew_molecule (SCM smob)
lt *= gh_scm2double (thick);
SCM gap = me->get_grob_property ("gap");
-
- Real prot_size = 0.7; // magic.
-
+ SCM ew = me->get_grob_property ("edge-width");
+ SCM eh = me->get_grob_property ("edge-height");
+ SCM sp = me->get_grob_property ("shorten-pair");
+
+ Direction d = LEFT;
+ Drul_array<Real> height, width, shorten;
+ do {
+ width[d] = height[d] = shorten[d] = 0.0;
+ if ( gh_pair_p (ew) )
+ width[d] += gh_scm2double (index_cell (ew, d)) * d;
+ if ( gh_pair_p (eh) )
+ height[d] += gh_scm2double (index_cell (eh, d));
+ if ( gh_pair_p (sp) )
+ shorten[d] += gh_scm2double (index_cell (sp, d));
+ }
+ while (flip (&d) != LEFT);
+
Molecule brack = make_bracket (Y_AXIS,
- w, ry-ly, lt,
- -prot_size*dir, -prot_size*dir,
+ w, ry - ly, lt,
+ -height[LEFT]*dir, -height[RIGHT]*dir,
gh_scm2double (gap),
- 0.0, 0.0);
+ width[LEFT], width[RIGHT],
+ shorten[LEFT], shorten[RIGHT]);
mol.add_molecule (brack);
+ mol.translate_axis (dir * max(height[LEFT], height[RIGHT]), Y_AXIS);
}
mol.translate_axis (ly, Y_AXIS);
@@ -184,31 +200,36 @@ Tuplet_bracket::brew_molecule (SCM smob)
*/
Molecule
Tuplet_bracket::make_bracket (Axis protusion_axis,
- Real dx, Real dy, Real thick, Real lprotrusion,
- Real rprotrusion, Real gap, Real left_widen,
- Real right_widen)
+ Real dx, Real dy, Real thick, Real left_height,
+ Real right_height, Real gap, Real left_widen,
+ Real right_widen, Real left_shorten, Real right_shorten)
{
Real len = Offset (dx,dy).length ();
- Real gapx = dx* (gap / len);
- Real gapy = dy* (gap / len);
+ Real gapx = dx * (gap / len);
+ Real gapy = dy * (gap / len);
+ Real lshortx = dx * (left_shorten / len);
+ Real lshorty = dy * (left_shorten / len);
+ Real rshortx = dx * (right_shorten / len);
+ Real rshorty = dy * (right_shorten / len);
Axis other = other_axis (protusion_axis);
-
- Molecule l1 = Lookup::line (thick, Offset(0,0),
+
+ Molecule l1 = Lookup::line (thick, Offset(lshortx, lshorty),
Offset ( (dx - gapx)/2, (dy - gapy)/2 ));
+
Molecule l2 = Lookup::line (thick, Offset((dx + gapx) / 2,(dy + gapy) / 2),
-
- Offset (dx,dy));
+ Offset (dx - rshortx, dy - rshorty));
Offset protusion;
- protusion[other] = left_widen;
- protusion[protusion_axis] = lprotrusion;
-
- Molecule p1 = Lookup::line (thick, Offset(0,0), protusion);
-
+ protusion[other] = -left_widen;
+ protusion[protusion_axis] = left_height;
+ Molecule p1 = Lookup::line (thick,
+ Offset(lshortx, lshorty),
+ Offset(lshortx, lshorty) + protusion);
protusion[other] = right_widen;
- protusion[protusion_axis] = rprotrusion;
- Molecule p2 = Lookup::line (thick, Offset(dx,dy),Offset(dx,dy) + protusion);
-
+ protusion[protusion_axis] = right_height;
+ Molecule p2 = Lookup::line (thick,
+ Offset(dx - rshortx, dy - rshorty),
+ Offset(dx - rshortx, dy - rshorty) + protusion);
Molecule m;
m.add_molecule (p1);
Index: lily/include/tuplet-bracket.hh
===================================================================
RCS file: /home/lilypond/lilypond/lily/include/tuplet-bracket.hh,v
retrieving revision 1.2
diff -p -u -r1.2 tuplet-bracket.hh
--- lily/include/tuplet-bracket.hh 1 Apr 2002 13:48:03 -0000 1.2
+++ lily/include/tuplet-bracket.hh 7 Apr 2002 16:33:32 -0000
@@ -32,9 +32,10 @@ public:
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
static Molecule make_bracket (Axis protusion_axis,
- Real dx, Real dy, Real thick, Real lprotrusion,
- Real rprotrusion, Real gap, Real left_widen,
- Real right_widen);
+ Real dx, Real dy, Real thick, Real left_height,
+ Real right_height, Real gap, Real left_widen,
+ Real right_widen, Real left_shorten,
+ Real right_shorten);
static Direction get_default_dir (Grob*);
};
Index: scm/grob-description.scm
===================================================================
RCS file: /home/lilypond/lilypond/scm/grob-description.scm,v
retrieving revision 1.69
diff -p -u -r1.69 grob-description.scm
--- scm/grob-description.scm 2 Apr 2002 12:34:02 -0000 1.69
+++ scm/grob-description.scm 7 Apr 2002 16:33:33 -0000
@@ -911,6 +911,9 @@
(gap . 2.0)
(padding . 0.9)
(thickness . 1.6)
+ (edge-width . (0.0 . 0.0))
+ (edge-height . (0.7 . 0.7))
+ (shorten-pair . (0.0 . 0.0))
(before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking)
(after-line-breaking-callback . ,Tuplet_bracket::after_line_breaking)
(molecule-callback . ,Tuplet_bracket::brew_molecule)