X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcrescendo.cc;h=9bfbf02eff6c8aaff9edc2fca3730cedb13d7d98;hb=c802622f935af83bb791ded58056428d6be31d0a;hp=400b6709a05b68821543ff39e10f35e409a056f0;hpb=1ff8f1c7e0baac008490e9e62995df70e0ed5128;p=lilypond.git diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 400b6709a0..9bfbf02eff 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -3,77 +3,75 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ #include "molecule.hh" -#include "dimen.hh" #include "crescendo.hh" -#include "lookup.hh" +#include "spanner.hh" +#include "font-interface.hh" +#include "dimensions.hh" #include "paper-def.hh" #include "debug.hh" -#include "score-column.hh" +#include "paper-column.hh" -Crescendo::Crescendo() -{ - grow_dir_ =0; - dir_ = DOWN; - dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false; -} +MAKE_SCHEME_CALLBACK (Crescendo, brew_molecule, 1); -Interval -Crescendo::symbol_height() const +SCM +Crescendo::brew_molecule (SCM smob) { - return get_symbol().dim_[Y_AXIS]; -} + Score_element *me= unsmob_element (smob); + Spanner *span = dynamic_cast(me); -static Real absdyn_dim = 10 PT; // ugh + Real line = me->paper_l ()->get_var ("stafflinethickness"); + + Real broken_left = span->get_broken_left_end_align (); -Atom -Crescendo::get_symbol() const -{ - Real w_dim = width().length (); - if (dyn_b_drul_[LEFT]) - { - w_dim -= absdyn_dim; - } - if (dyn_b_drul_[RIGHT]) + SCM s = me->get_elt_property("grow-direction"); + if (!isdir_b (s)) { - w_dim -= absdyn_dim; + me->suicide (); + return SCM_EOL; } + + Direction grow_dir = to_dir (s); - if (w_dim < 0) + Real width = span->spanner_length (); + width -= span->get_broken_left_end_align (); + + if (width < 0) { - warning (_("Crescendo too small")); - w_dim = 0; + warning (_ ((grow_dir < 0) ? "decrescendo too small" + : "crescendo too small")); + width = 0; } Drul_array broken; Direction d = LEFT; - do { - Score_column* s = (Score_column* )spanned_drul_[d] ; // UGH - broken[d] = (!s->musical_b()); - } while (flip(&d) != LEFT); + do + { + Paper_column* s = dynamic_cast (span->get_bound (d)); // UGH + broken[d] = (!s->musical_b ()); + } + while (flip (&d) != LEFT); + bool continued = broken[Direction (-grow_dir)]; + Real height = gh_scm2double (me->get_elt_property ("height")); + Real thick = line * gh_scm2double (me->get_elt_property ("thickness")); + + const char* type = (grow_dir < 0) ? "decrescendo" : "crescendo"; + SCM hairpin = gh_list (ly_symbol2scm (type), + gh_double2scm (thick), + gh_double2scm (width), + gh_double2scm (height), + gh_double2scm (continued ? height/2 : 0.0), + SCM_UNDEFINED); - bool continued = broken[(Direction)-grow_dir_]; - return Atom (paper()->lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued)); -} - -Molecule* -Crescendo::brew_molecule_p() const -{ - Molecule* m_p =0; - Real x_off_dim=0.0; - if (dyn_b_drul_[LEFT]) - x_off_dim += absdyn_dim; + Box b (Interval (0, width), Interval (-2*height, 2*height)); + Molecule mol (b, hairpin); + mol.translate_axis (broken_left, X_AXIS); - m_p = new Molecule; - Atom s (get_symbol()); - m_p->add (Atom (s)); - m_p->translate (Offset (x_off_dim, y_)); - return m_p; + return mol.smobbed_copy (); } -IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);