]> git.donarmstrong.com Git - lilypond.git/commitdiff
''
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 7 Apr 2002 19:16:16 +0000 (19:16 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 7 Apr 2002 19:16:16 +0000 (19:16 +0000)
input/test/tuplet.ly
lily/include/tuplet-bracket.hh
lily/tuplet-bracket.cc
scm/grob-description.scm

index 5191612043dc1f9540907815536a70db0e073f30..4c9ab555893187c859a1f48abcb2dc729f8d79f9 100644 (file)
@@ -1,27 +1,38 @@
-\version "1.3.146"
+\version "1.5.50"
 
 
 \score { 
-  \context Voice \notes\relative 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/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]  }
-    
-
-}
+    \context Voice \notes\relative 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/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 }
+
+    }
 }
index 86a89262f79284295efd8f9cc3b2463c21ac7b34..97c10572dc1616f134f50a6c49ae8bbe07290d2f 100644 (file)
@@ -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 bb397a27fa34cec23ade1098f6fcd23ac67a90c7..bdb6ed922c011d0f1b5d416af28097dac7787046 100644 (file)
@@ -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 7244f1f54d0ff6b56049a6b8beb624f1ca5f841a..5f775ddd5ca3352550d071a271476bf6c642167a 100644 (file)
        (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)