source file of the GNU LilyPond music typesetter
- (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "staff-symbol-referencer.hh"
#include "molecule.hh"
+#include "line-interface.hh"
#include "hairpin.hh"
#include "spanner.hh"
#include "font-interface.hh"
#include "dimensions.hh"
#include "paper-def.hh"
-#include "debug.hh"
+#include "warn.hh"
#include "paper-column.hh"
+#include "lookup.hh"
MAKE_SCHEME_CALLBACK (Hairpin, brew_molecule, 1);
Grob *me= unsmob_grob (smob);
Spanner *spanner = dynamic_cast<Spanner*> (me);
- Real line = me->paper_l ()->get_var ("stafflinethickness");
-
SCM s = me->get_grob_property ("grow-direction");
- if (!isdir_b (s))
+ if (!is_direction (s))
{
me->suicide ();
return SCM_EOL;
Direction grow_dir = to_dir (s);
- /* Ugh, must be same as Text_spanner::brew_molecule. */
+ /* Ugh, must be same as Text_spanner::brew_molecule. */
+
+ /*
+ Ugh. property name is not general.
+ */
Real padding = gh_scm2double (me->get_grob_property ("if-text-padding"));
Drul_array<bool> broken;
make the padding a little smaller, here.
*/
Interval e =b->extent (common, X_AXIS);
- if (e.empty_b ())
+ if (e.is_empty ())
e = Interval (0,0) + b->relative_coordinate (common, X_AXIS);
x_points[d] = e.center () - d * padding /3; // ugh.
else
{
Interval e =b->extent (common, X_AXIS);
- if (!e.empty_b ())
+ if (!e.is_empty ())
x_points[d] = e[-d] - d*padding;
}
}
if (width < 0)
{
- warning (_ ((grow_dir < 0) ? "decrescendo too small"
+ me->warning (_ ((grow_dir < 0) ? "decrescendo too small"
: "crescendo too small"));
width = 0;
}
bool continued = broken[Direction (-grow_dir)];
- Real height = gh_scm2double (me->get_grob_property ("height"));
- Real thick = line * gh_scm2double (me->get_grob_property ("thickness"));
+ Real height = robust_scm2double (me->get_grob_property ("height"), 0.2) *
+ Staff_symbol_referencer::staff_space (me);
Real starth, endh;
if (grow_dir < 0)
starth = continued ? height/2 : 0.0;
endh = height;
}
-
+
/*
- TODO: junk this and, make a general
+ should do relative to staff-symbol staff-space?
+ */
- Lookup::line (XY1, XY2).
- */
- SCM hairpin = scm_listify (ly_symbol2scm ("hairpin"),
- gh_double2scm (thick),
- gh_double2scm (width),
- gh_double2scm (starth),
- gh_double2scm (endh),
- SCM_UNDEFINED);
+ Molecule mol;
+ mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh));
+ mol.add_molecule (Line_interface::line (me,
+ Offset (0, -starth),
+ Offset (width, -endh)));
- /*
- We make the hairpin too large in Y direction, so it stays at
- proper distance from the staff.
- */
- Interval yext = 2* height * Interval (-1,1);
- Box b (Interval (0, width), yext);
- Molecule mol (b, hairpin);
-
mol.translate_axis (x_points[LEFT]
- bounds[LEFT]->relative_coordinate (common, X_AXIS),
X_AXIS);
-
return mol.smobbed_copy ();
}
+ADD_INTERFACE (Hairpin, "hairpin-interface",
+ "hairpin crescendo.",
+ "grow-direction height if-text-padding");
+