X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcrescendo.cc;h=c21897facaee943190f1950b9304f38845ce23fc;hb=9661ba1fb275f3e14f8a69f2cee2f02a2f893e48;hp=3f0f16b637dd1423e6b70eb866188c3f200da3c0;hpb=ffe548cfbb3c3b37c8969f49b5aba04ef998d080;p=lilypond.git diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 3f0f16b637..c21897faca 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -8,49 +8,48 @@ #include "molecule.hh" #include "crescendo.hh" +#include "spanner.hh" #include "lookup.hh" #include "dimensions.hh" #include "paper-def.hh" #include "debug.hh" #include "paper-column.hh" -#include "atom.hh" -Crescendo::Crescendo () +void +Crescendo::set_interface (Score_element*s) { - set_elt_property ("dynamic-drul", gh_cons (SCM_BOOL_F, SCM_BOOL_F)); + s->set_elt_property ("dynamic-drul", gh_cons (SCM_EOL, SCM_EOL)); } -Molecule -Crescendo::do_brew_molecule () const +MAKE_SCHEME_CALLBACK(Crescendo,brew_molecule); +SCM +Crescendo::brew_molecule (SCM smob) { - Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten"); - Real extra_left = get_broken_left_end_align (); + Score_element *me= unsmob_element (smob); + Spanner * sp = dynamic_cast(me); + Real absdyn_dim = me->paper_l ()-> get_var ("crescendo_shorten"); + Real extra_left = sp->get_broken_left_end_align (); - SCM dir = get_elt_property("grow-direction"); - SCM dyns = get_elt_property ("dynamic-drul"); + SCM dir = me->get_elt_property("grow-direction"); + SCM dyns = me->get_elt_property ("dynamic-drul"); if (!isdir_b (dir) || !gh_pair_p (dyns)) { - Crescendo * me = (Crescendo*)this; - me->set_elt_property ("transparent", SCM_BOOL_T); - Molecule m; - - return m; + me->suicide (); + return SCM_EOL; } Direction gd = to_dir (dir); - bool dynleft= to_boolean (gh_car (dyns)); - bool dynright = to_boolean (gh_cdr (dyns)); + bool dynleft= unsmob_element (gh_car (dyns)); + bool dynright = unsmob_element (gh_cdr (dyns)); if (dynleft) extra_left += absdyn_dim; - - - Real width = spanner_length()- get_broken_left_end_align (); + Real width = sp->spanner_length()- sp->get_broken_left_end_align (); if (dynleft) { @@ -69,32 +68,68 @@ Crescendo::do_brew_molecule () const 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); + do + { + Paper_column* s = dynamic_cast(sp->get_bound (d)); // UGH + broken[d] = (!s->musical_b ()); + } + while (flip (&d) != LEFT); + + Molecule m; + + Real pad = 0; + SCM s = me->get_elt_property ("start-text"); + if (gh_string_p (s)) + { + Molecule start_text (me->lookup_l ()->text ("italic", + ly_scm2string (s), + me->paper_l ())); + m.add_molecule (start_text); - 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"; + pad = me->paper_l ()->get_var ("interline") / 2; - Box b (Interval (0, width), - Interval (-2*height, 2*height)); + width -= start_text.extent (X_AXIS).length (); + width -= pad; + width = width >? 0; + } - 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); + SCM at; + s =me->get_elt_property ("spanner"); + Real height; + if (gh_string_p (s) && ly_scm2string (s) == "dashed-line") + { + Real thick = me->paper_l ()->get_var ("crescendo_dash_thickness"); + Real dash = me->paper_l ()->get_var ("crescendo_dash"); + height = thick; + at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()), + gh_double2scm (thick), + gh_double2scm (dash), + gh_double2scm (width), + SCM_UNDEFINED); + } + else + { + bool continued = broken[Direction (-gd)]; + height = me->paper_l()->get_var ("crescendo_height"); + Real thick = me->paper_l ()->get_var ("crescendo_thickness"); + + const char* hairpin = (gd < 0)? "decrescendo" : "crescendo"; + + at = gh_list (ly_symbol2scm (hairpin), + gh_double2scm (thick), + gh_double2scm (width), + gh_double2scm (height), + gh_double2scm (continued ? height/2 : 0.0), + SCM_UNDEFINED); + } + Box b (Interval (0, width), Interval (-2*height, 2*height)); + Molecule span (b, at); - Molecule m (b, at); - + m.add_at_edge (X_AXIS, RIGHT, span, pad); m.translate_axis (extra_left, X_AXIS); - return m; + + return m.create_scheme (); }