X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhairpin.cc;h=f773673f4c6fbc0f07ace4aed46860480fe7d5e0;hb=ea9e5d2536fd8234d1c7e48acc26e161d1df90d4;hp=6471957ecf240180bfe8f151d68f04b6e8fb89fc;hpb=a2991295b2c1fb36bec19de207161855ca3c1756;p=lilypond.git diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 6471957ecf..f773673f4c 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -3,17 +3,20 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2001 Han-Wen Nienhuys + (c) 1997--2003 Han-Wen Nienhuys */ +#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); @@ -23,10 +26,8 @@ Hairpin::brew_molecule (SCM smob) Grob *me= unsmob_grob (smob); Spanner *spanner = dynamic_cast (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; @@ -35,7 +36,11 @@ Hairpin::brew_molecule (SCM smob) 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 broken; @@ -70,12 +75,15 @@ Hairpin::brew_molecule (SCM smob) make the padding a little smaller, here. */ Interval e =b->extent (common, X_AXIS); + 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; } } @@ -87,14 +95,14 @@ Hairpin::brew_molecule (SCM smob) 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) @@ -107,33 +115,26 @@ Hairpin::brew_molecule (SCM smob) 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 = gh_list (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"); +