]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.12
authorfred <fred>
Sun, 24 Mar 2002 19:56:17 +0000 (19:56 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:56:17 +0000 (19:56 +0000)
lily/include/lookup.hh
lily/tex-slur.cc

index ce55ce46575e2f5b75874edb5671a789091bd961..c9af80091c01cae44ee4bedfcbead1a4cc29d224 100644 (file)
@@ -12,6 +12,7 @@
 #include "symbol.hh"
 #include "fproto.hh"
 #include "scalar.hh"
+#include "direction.hh"
 
 /// intuitive interface to symbol table
 struct Lookup {
@@ -48,10 +49,10 @@ struct Lookup {
     Symbol bar (String, Real height) const;
     
     Symbol dots (int) const;
-    Symbol slur (int dy, Real &dx, int dir) const;
-    Symbol half_slur (int dy, Real &dx, int dir, int xpart) const;
-    Symbol half_slur_middlepart (Real &dx, int dir) const;
-    Symbol big_slur (int dy, Real &dx, int dir) const;
+    Symbol slur (int dy, Real &dx, Direction dir) const;
+    Symbol half_slur (int dy, Real &dx, Direction dir, int xpart) const;
+    Symbol half_slur_middlepart (Real &dx, Direction dir) const;
+    Symbol big_slur (int dy, Real &dx, Direction dir) const;
     Symbol text (String style, String text, int align = 1) const;
     Symbol script (String idx) const;
     Symbol hairpin (Real & width, bool decresc) const;
index 3463d38494eb53dc3b6dd1236342513de5a05e62..30d06d3d32609ffa421d2d7a77751355f822bea5 100644 (file)
 #include "paper-def.hh"
 
 
-
-static
-char direction_char (int y_sign)
+static char
+direction_char (Direction y_sign)
 {
   char c='#';
   switch (y_sign)
     {
-    case -1:
+    case DOWN:
       c = 'd';
       break;
-    case 0:
+    case CENTER:
       c = 'h';
       break;
-    case 1:
+    case UP:
       c = 'u';
       break;
     default:
@@ -38,12 +37,14 @@ char direction_char (int y_sign)
 }
 
 Symbol
-Lookup::half_slur_middlepart (Real &dx, int dir) const
+Lookup::half_slur_middlepart (Real &dx, Direction dir) const
 {
-  if (dx >= 400 PT) {// todo
-    WARN<<"halfslur too large" <<print_dimen (dx)<< "shrinking (ugh)\n";
-    dx = 400 PT;
-  }
+  // todo
+  if (dx >= 400 PT)
+    {
+      WARN<<"halfslur too large" <<print_dimen (dx)<< "shrinking (ugh)\n";
+      dx = 400 PT;
+    }
   int widx = int (floor (dx / 4.0));
   dx = widx * 4.0;
   if (widx) widx --;
@@ -58,7 +59,7 @@ Lookup::half_slur_middlepart (Real &dx, int dir) const
   s.dim.x() = Interval (0,dx);
 
   String f =  String ("\\hslurchar");
-  f += direction_char (0);
+  f += direction_char (CENTER);
 
   int idx = widx;
   if (dir < 0)
@@ -74,8 +75,9 @@ Lookup::half_slur_middlepart (Real &dx, int dir) const
 
   return s;
 }
+
 Symbol
-Lookup::half_slur (int dy, Real &dx, int dir, int xpart) const
+Lookup::half_slur (int dy, Real &dx, Direction dir, int xpart) const
 {
   Real orig_dx = dx;
   if (!xpart)
@@ -127,10 +129,16 @@ Lookup::half_slur (int dy, Real &dx, int dir, int xpart) const
 }
 
 Symbol
-Lookup::slur (int dy , Real &dx, int dir) const
+Lookup::slur (int dy , Real &dx, Direction dir) const
 {
-  assert (dx >=0 && abs (dir) <= 1);
-  int y_sign = sign (dy);
+  
+  assert (abs (dir) <= 1);
+  if  (dx < 0)
+    {
+      warning ("Negative slur/tie length: " + print_dimen (dx));
+      dx = 4.0 PT;
+    }
+  Direction y_sign = (Direction) sign (dy);
 
   bool large = abs (dy) > 8;
 
@@ -201,9 +209,14 @@ Lookup::slur (int dy , Real &dx, int dir) const
 }
 
 Symbol
-Lookup::big_slur (int dy , Real &dx, int dir) const
+Lookup::big_slur (int dy , Real &dx, Direction dir) const
 {
-  assert (dx >= 24 PT);
+  if (dx < 24 PT) 
+    {
+      warning ("big_slur too small " + print_dimen (dx) + " (stretching)");
+      dx = 24 PT;
+    }
+  
   Real slur_extra =abs (dy)  /2.0 + 2; 
   int l_dy = int (Real (dy)/2 + slur_extra*dir);
   int r_dy =  dy - l_dy;