]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
* input/regression/rehearsal-mark-number.ly: new file.
[lilypond.git] / lily / lookup.cc
index 0f7d9b8d767c47ac2d6c51b262afa085a0c417c6..0e8a40acb8bd597f10739d5b72ffeebe10319ebc 100644 (file)
@@ -40,22 +40,20 @@ Lookup::dot (Offset p, Real radius)
 }
 
 Molecule 
-Lookup::beam (Real slope, Real width, Real thick) 
+Lookup::beam (Real slope, Real width, Real thick, Real blot
 {
   Real height = slope * width; 
   Real min_y = (0 <? height) - thick/2;
   Real max_y = (0 >? height) + thick/2;
 
-  
-
   Box b (Interval (0, width),
         Interval (min_y, max_y));
-
   
   SCM at = scm_list_n (ly_symbol2scm ("beam"),
                    gh_double2scm (width),
                    gh_double2scm (slope),
                    gh_double2scm (thick),
+                   gh_double2scm (blot),
                    SCM_UNDEFINED);
   return Molecule (b, at);
 }
@@ -81,19 +79,19 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 }
 
 Molecule
-Lookup::line (Real th, Offset f, Offset t)
+Lookup::line (Real th, Offset from, Offset to)
 {
   SCM at = scm_list_n (ly_symbol2scm ("draw-line"),
                        gh_double2scm (th), 
-                       gh_double2scm (f[X_AXIS]),
-                       gh_double2scm (f[Y_AXIS]),
-                       gh_double2scm (t[X_AXIS]),
-                       gh_double2scm (t[Y_AXIS]),
+                       gh_double2scm (from[X_AXIS]),
+                       gh_double2scm (from[Y_AXIS]),
+                       gh_double2scm (to[X_AXIS]),
+                       gh_double2scm (to[Y_AXIS]),
                        SCM_UNDEFINED);
 
   Box box;
-  box.add_point (f);
-  box.add_point (t);
+  box.add_point (from);
+  box.add_point (to);
 
   box[X_AXIS].widen (th/2);
   box[Y_AXIS].widen (th/2);  
@@ -101,6 +99,34 @@ Lookup::line (Real th, Offset f, Offset t)
   return Molecule (box, at);
 }
 
+Molecule
+Lookup::dashed_line (Real thick, Offset from, Offset to,
+                    Real dash_period, Real dash_fraction)
+{
+  dash_fraction = (dash_fraction >? 0) <? 1.0;
+  Real on = dash_fraction * dash_period + thick; 
+  Real off = dash_period - on;
+  
+  SCM at = scm_list_n (ly_symbol2scm ("dashed-line"),
+                       gh_double2scm (thick), 
+                       gh_double2scm (on),
+                       gh_double2scm (off),
+                       gh_double2scm (to[X_AXIS] - from[X_AXIS]),
+                       gh_double2scm (to[Y_AXIS] - from[Y_AXIS]),
+                       SCM_UNDEFINED);
+  
+  Box box;
+  box.add_point (Offset (0,0));
+  box.add_point (to - from);
+
+  box[X_AXIS].widen (thick/2);
+  box[Y_AXIS].widen (thick/2);  
+
+  Molecule m = Molecule (box, at);
+  m.translate (from);
+  return m;
+}
+
 Molecule
 Lookup::horizontal_line (Interval w, Real th)
 {
@@ -126,7 +152,7 @@ Lookup::blank (Box b)
 }
 
 Molecule
-Lookup::filledbox (Box b) 
+Lookup::filled_box (Box b) 
 {
   SCM  at  = (scm_list_n (ly_symbol2scm ("filledbox"),
                     gh_double2scm (-b[X_AXIS][LEFT]),
@@ -166,7 +192,7 @@ Lookup::filledbox (Box b)
  *       Box extent(X_AXIS)
  */
 Molecule
-Lookup::roundfilledbox (Box b, Real blotdiameter)
+Lookup::round_filled_box (Box b, Real blotdiameter)
 {
   if (b.x ().length () < blotdiameter)
     {
@@ -179,7 +205,7 @@ Lookup::roundfilledbox (Box b, Real blotdiameter)
       blotdiameter = b.y ().length ();
     }
 
-  SCM at = (scm_list_n (ly_symbol2scm ("roundfilledbox"),
+  SCM at = (scm_list_n (ly_symbol2scm ("round-filled-box"),
                        gh_double2scm (-b[X_AXIS][LEFT]),
                        gh_double2scm (b[X_AXIS][RIGHT]),
                        gh_double2scm (-b[Y_AXIS][DOWN]),
@@ -190,24 +216,6 @@ Lookup::roundfilledbox (Box b, Real blotdiameter)
   return Molecule (b,at);
 }
 
-LY_DEFINE(ly_round_filled_box, "ly:round-filled-box",
-         2, 0,0,
-         (SCM b, SCM blot),
-         "Make a box with rounded corners. B is a pair of number-pairs, and BLOT a number")
-{
-  SCM_ASSERT_TYPE(gh_number_p (blot), blot, SCM_ARG2, __FUNCTION__, "number") ;
-  SCM_ASSERT_TYPE(gh_pair_p (b), b, SCM_ARG4, __FUNCTION__, "pair") ;
-
-  SCM_ASSERT_TYPE(ly_number_pair_p (gh_car (b)), gh_car (b), SCM_ARG1, __FUNCTION__, "number-pair") ;
-  SCM_ASSERT_TYPE(ly_number_pair_p (gh_cdr (b)), gh_cdr (b), SCM_ARG1, __FUNCTION__, "number-pair") ;
-
-  Interval x (ly_scm2interval (gh_car (b)));
-  Interval y (ly_scm2interval (gh_cdr (b)));
-  
-  return Lookup::roundfilledbox (Box (x,y),
-                                gh_scm2double (blot)).smobbed_copy();
-  
-}
          
 
 /*
@@ -343,8 +351,14 @@ Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
   return polygon;
 }
 
+
+/*
+  TODO: deprecate?
+
+  should use rounded corners.
+ */
 Molecule
-Lookup::frame (Box b, Real thick)
+Lookup::frame (Box b, Real thick, Real blot)
 {
   Molecule m;
   Direction d = LEFT;
@@ -358,12 +372,11 @@ Lookup::frame (Box b, Real thick)
          edges[o][DOWN] = b[o][DOWN] - thick/2;
          edges[o][UP] = b[o][UP] + thick/2;      
          
-         m.add_molecule (filledbox (edges));
+         m.add_molecule (round_filled_box (edges, blot));
        }
       while (flip (&d) != LEFT);
     }
   return m;
-  
 }
 
 /*
@@ -400,7 +413,7 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
     }
   
   
-  SCM at = (scm_list_n (ly_symbol2scm ("bezier-bow"),
+  SCM at = (scm_list_n (ly_symbol2scm ("bezier-sandwich"),
                     ly_quote_scm (list),
                     gh_double2scm (linethick),
                     SCM_UNDEFINED));
@@ -713,23 +726,24 @@ Lookup::repeat_slash (Real w, Real s, Real t)
   return Molecule (b, slashnodot); //  http://slashnodot.org
 }
 
+
 Molecule
-Lookup::bracket (Axis a, Interval iv, Real thick, Real protude)
+Lookup::bracket (Axis a, Interval iv, Real thick, Real protude, Real blot)
 {
   Box b;
   Axis other = Axis((a+1)%2);
   b[a] = iv;
   b[other] = Interval(-1, 1) * thick * 0.5;
   
-  Molecule m =  filledbox (b);
+  Molecule m =  round_filled_box (b, blot);
 
   b[a] = Interval (iv[UP] - thick, iv[UP]);
   Interval oi = Interval (-thick/2, thick/2 + fabs (protude)) ;
   oi *=  sign (protude);
   b[other] = oi;
-  m.add_molecule (filledbox (b));
+  m.add_molecule (round_filled_box (b, blot));
   b[a] = Interval (iv[DOWN], iv[DOWN]  +thick);
-  m.add_molecule (filledbox(b));
+  m.add_molecule (round_filled_box (b,blot));
 
   return m;
 }
@@ -760,14 +774,30 @@ LY_DEFINE(ly_bracket ,"ly:bracket",
          "given by @var{iv}. The wings protude by an amount of @var{p}, which "
          "may be negative. The thickness is given by @var{t}.")
 {
-  SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
-  SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
+  SCM_ASSERT_TYPE(is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
   SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG3, __FUNCTION__, "number") ;
   SCM_ASSERT_TYPE(gh_number_p (p), a, SCM_ARG4, __FUNCTION__, "number") ;
 
 
   return Lookup::bracket ((Axis)gh_scm2int (a), ly_scm2interval (iv),
                          gh_scm2double (t),
-                         gh_scm2double (p)).smobbed_copy ();
+                         gh_scm2double (p),
+                         gh_scm2double (t)).smobbed_copy ();
 }
-  
+
+
+
+LY_DEFINE(ly_filled_box ,"ly:round-filled-box",
+         3, 0, 0,
+         (SCM xext, SCM yext, SCM blot),
+         "Make a filled-box of dimensions @var{xext}, @var{yext} and roundness @var{blot}.")
+{
+  SCM_ASSERT_TYPE(is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(gh_number_p (blot), blot, SCM_ARG3, __FUNCTION__, "number") ;
+
+  return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)),
+                                  gh_scm2double (blot)).smobbed_copy ();
+}
+