X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcrescendo.cc;h=481d30bca713b4c7335cf3542176dfec5a55b89a;hb=a6193f6f613e0b2ff519b804d28f99fcd6ec9b92;hp=1b25d8439f1b8c831fab6a295017527343806a02;hpb=90d3ec050c58d6fa91f668dd6ca1ae8f16df20c3;p=lilypond.git diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 1b25d8439f..481d30bca7 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -3,66 +3,96 @@ 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 "dimensions.hh" #include "paper-def.hh" #include "debug.hh" +#include "paper-column.hh" +#include "atom.hh" -Crescendo::Crescendo() +Crescendo::Crescendo () { - grow_dir_i_ =0; - dir_i_ = -1 ; - left_dyn_b_ = right_dyn_b_ =false; - inside_staff_b_ = false; + set_elt_property ("dynamic-drul", gh_cons (SCM_BOOL_F, SCM_BOOL_F)); } -Interval -Crescendo::symbol_height()const + + +Molecule* +Crescendo::do_brew_molecule_p () const { - return get_symbol().dim.y; -} + Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten"); + Real extra_left = get_broken_left_end_align (); -static Real absdyn_dim = 10 PT; // ugh + SCM dir = get_elt_property("grow-direction"); + SCM dyns = get_elt_property ("dynamic-drul"); -Symbol -Crescendo::get_symbol()const -{ - Real w_dim = width().length(); - if ( left_dyn_b_ ) { - w_dim -= absdyn_dim; + if (!isdir_b (dir) || !gh_pair_p (dyns)) + { +Crescendo * me = (Crescendo*)this; + me->set_elt_property ("transparent", SCM_BOOL_T); + return new Molecule; } - if ( right_dyn_b_ ) { - w_dim -= absdyn_dim; + + Direction gd = to_dir (dir); + + bool dynleft= to_boolean (gh_car (dyns)); + bool dynright = to_boolean (gh_cdr (dyns)); + + if (dynleft) + extra_left += absdyn_dim; + + + + Real width = spanner_length()- get_broken_left_end_align (); + + if (dynleft) + { + width -= absdyn_dim; } - - if (w_dim < 0) { - warning("Crescendo too small"); - w_dim = 0; + if (dynright) + { + width -= absdyn_dim; } -// Real lookup_wid = w_dim * 0.9; // make it slightly smaller. - return Symbol( paper()->lookup_l()->hairpin( w_dim, grow_dir_i_ < 0) ); -} + if (width < 0) + { + warning (_ ("crescendo") + " " + _ ("too small")); + width = 0; + } -Molecule* -Crescendo::brew_molecule_p() const -{ - Molecule* m_p =0; - Real x_off_dim=0.0; - if ( left_dyn_b_) - x_off_dim += absdyn_dim; - - m_p = new Molecule; - Symbol s(get_symbol()); - m_p->add(Atom(s)); - m_p->translate(Offset(x_off_dim, pos_i_ * paper()->internote_f())); - return m_p; + Drul_array broken; + Direction d = LEFT; + do { + Paper_column* s = dynamic_cast(spanned_drul_[d]); // UGH + broken[d] = (!s->musical_b ()); + } while (flip (&d) != LEFT); + + + bool continued = broken[Direction (-gd)]; + Real height = paper_l()->get_var ("crescendo_height"); + Real thick = paper_l ()->get_var ("crescendo_thickness"); + + const char* hairpin = (gd < 0)? "decrescendo" : "crescendo"; + Molecule * m + = new Molecule; + m->dim_.x () = Interval (0, width); + m->dim_.y () = Interval (-2*height, 2*height); + + SCM at = gh_list (ly_symbol2scm (hairpin), + gh_double2scm (thick), + gh_double2scm (width), + gh_double2scm (height), + gh_double2scm (continued ? height/2 : 0.0), + SCM_UNDEFINED); + + m->add_atom (at); + m->translate_axis (extra_left, X_AXIS); + return m; } -IMPLEMENT_STATIC_NAME(Crescendo); -IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner); +