]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
release: 1.5.36
[lilypond.git] / lily / lookup.cc
index 036ba8895944abbbd2dd12bed515371f0d2aa64b..2d832c965b9cdf6694fdb905e4ee07e7d30250b8 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
   Jan Nieuwenhuizen <janneke@gnu.org>
 
@@ -46,7 +46,6 @@ Lookup::beam (Real slope, Real width, Real thick)
 }
 
 
-
 Molecule
 Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 {
@@ -67,9 +66,6 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash)
   return   Molecule (box, at);
 }
 
-
-
-
 Molecule
 Lookup::blank (Box b) 
 {
@@ -90,6 +86,7 @@ Lookup::filledbox (Box b)
   return Molecule (b,at);
 }
 
+
 Molecule
 Lookup::frame (Box b, Real thick)
 {
@@ -107,7 +104,6 @@ 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));
        }
       while (flip (&d) != LEFT);
@@ -125,11 +121,14 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
 {
   Real alpha = (curve.control_[3] - curve.control_[0]).arg ();
   Bezier back = curve;
-
+  Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI/2)) * 0.5;
   back.reverse ();
-  back.control_[1] += curvethick * complex_exp (Offset (0, alpha + M_PI/2));
-  back.control_[2] += curvethick * complex_exp (Offset (0, alpha + M_PI/2));  
+  back.control_[1] += perp;
+  back.control_[2] += perp;
 
+  curve.control_[1] -= perp;
+  curve.control_[2] -= perp;
+  
   SCM scontrols[8];
 
   for (int i=4; i--;)
@@ -152,11 +151,18 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
                     ly_quote_scm (list),
                     gh_double2scm (linethick),
                     SCM_UNDEFINED));
+  Box b(curve.extent (X_AXIS),
+       curve.extent (Y_AXIS));
+
+  b[X_AXIS].unite (back.extent (X_AXIS));
+  b[Y_AXIS].unite (back.extent (Y_AXIS));
 
-  Box b (curve.extent (X_AXIS), curve.extent (Y_AXIS));
   return Molecule (b, at);
 }
 
+/*
+  TODO: junk me.
+ */
 Molecule
 Lookup::accordion (SCM s, Real staff_space, Font_metric *fm) 
 {
@@ -373,3 +379,49 @@ Lookup::repeat_slash (Real w, Real s, Real t)
 
   return Molecule (b, slashnodot); //  http://slashnodot.org
 }
+
+
+
+Molecule
+Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude)
+{
+  Box b;
+  Axis other = Axis((a+1)%2);
+  b[a] = iv;
+  b[other] = Interval(-1, 1) * thick * 0.5;
+  
+  Molecule m =  filledbox (b);
+
+  b[a] = Interval (iv[UP] - thick, iv[UP]);
+  Interval oi = Interval (-thick/2, thick/2 + protude) ;
+  oi *=  d;
+  b[other] = oi;
+  m.add_molecule (filledbox (b));
+  b[a] = Interval (iv[DOWN], iv[DOWN]  +thick);
+  m.add_molecule (filledbox(b));
+
+  return m;
+}
+
+SCM
+ly_bracket (SCM a, SCM iv, SCM d, SCM t, SCM p)
+{
+  SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
+  SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG1, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(ly_dir_p (d), a, SCM_ARG1, __FUNCTION__, "direction") ;
+  SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG1, __FUNCTION__, "number") ;
+  SCM_ASSERT_TYPE(gh_number_p(p), a, SCM_ARG1, __FUNCTION__, "number") ;
+
+
+  return Lookup::bracket ((Axis)gh_scm2int (a), ly_scm2interval (iv),
+                 (Direction)gh_scm2int (d), gh_scm2double (t), gh_scm2double (p)).smobbed_copy ();
+}
+  
+static void
+lookup_init ()
+{
+  scm_c_define_gsubr ("ly-bracket", 5, 0, 0, (Scheme_function_unknown) ly_bracket);
+}
+
+ADD_SCM_INIT_FUNC (lookup,lookup_init);
+