]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
release: 0.1.37
[lilypond.git] / lily / lookup.cc
index cc26384fec9dc3fe17e217f9e76e171d9d973f87..8fa26797224dc7681ccbd027b072523c598f1a80 100644 (file)
@@ -19,6 +19,7 @@
 #include "tex.hh"
 #include "scalar.hh"
 #include "paper-def.hh"
+#include "main.hh"
 
 Lookup::Lookup()
 {
@@ -158,15 +159,37 @@ Lookup::streepje (int type) const
 Atom
 Lookup::hairpin (Real &wid, bool decresc) const
 {
-  int idx = int (rint (wid / 6 PT));
-  if (!idx) idx ++;
-  wid = idx*6 PT;
-  String idxstr = (decresc)? "decrescendosym" : "crescendosym";
-  Atom ret=(*symtables_p_)("param")->lookup (idxstr);
-
-  Array<String> a;
-  a.push (idx);
-  ret.tex_ = substitute_args (ret.tex_, a);
+  bool embedded_b = postscript_global_b;
+  String embed;
+  Atom ret;  
+  if (embedded_b)
+    {
+      Real height = 2 PT;
+      embed = "\\embeddedps{\n" ;
+      embed += String (wid) + " " 
+       + String (height)
+       + " draw_"  + String(decresc ? "de" : "") + "cresc}\n";
+      ret.tex_ = embed;
+    }
+  else
+    {
+      if (wid > 32 * 6 PT)
+       {
+         warning (_("Crescendo too long (") + print_dimen (wid) 
+                  +_( ") shrinking (ugh)"));
+         wid = 32*6 PT;
+       }
+      int idx = int (rint (wid / 6 PT));
+      if (!idx) idx ++;
+      wid = idx*6 PT;
+      String idxstr = (decresc)? "decrescendosym" : "crescendosym";
+      ret=(*symtables_p_)("param")->lookup (idxstr);
+      
+      Array<String> a;
+      a.push (idx);
+      ret.tex_ = substitute_args (ret.tex_, a);
+    }
+  
   ret.dim_.x() = Interval (0,wid);
   return ret;
 }
@@ -209,27 +232,32 @@ Lookup::stem (Real y1,Real y2) const
 Atom
 Lookup::vbrace (Real &y) const
 {
-  if (y < 2* 20 PT)
+  Atom brace = (*symtables_p_)("param")->lookup ("brace");
+  Interval ydims = brace.dim_[Y_AXIS];
+  Real min_y = ydims[LEFT];
+  Real max_y = ydims[RIGHT];
+  Real step = 2.0 PT;
+  if (y < min_y)
     {
       warning (_("piano brace too small (") + print_dimen (y)+ ")");
-      y = 2*20 PT;
+      y = min_y;
     }
-  if (y > 67 * 2 PT)
+  if (y > max_y)
     {
       warning (_("piano brace too big (") + print_dimen (y)+ ")");
-      y = 67 *2 PT;
+      y = max_y;
     }
 
-  int idx = int (rint ((y/2.0 - 20) + 148));
-
-  Atom s = (*symtables_p_)("param")->lookup ("brace");
+  
+  int idx = int (rint ((y- min_y)/step)) + 1;
+  
   {
     Array<String> a;
     a.push (idx);
-    s.tex_ = substitute_args (s.tex_,a);
-    s.dim_.y() = Interval (-y/2,y/2);
+    brace.tex_ = substitute_args (brace.tex_,a);
+    brace.dim_[Y_AXIS] = Interval (-y/2,y/2);
   }
 
-
-  return s;
+  return brace;
 }