2 crescendo.cc -- implement Crescendo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "crescendo.hh"
13 #include "dimensions.hh"
14 #include "paper-def.hh"
16 #include "paper-column.hh"
19 Crescendo::set_interface (Score_element*s)
21 s->set_elt_pointer ("dynamic-drul", gh_cons (SCM_UNDEFINED, SCM_UNDEFINED));
26 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Crescendo,brew_molecule);
28 Crescendo::brew_molecule (SCM smob)
30 Score_element *me= unsmob_element (smob);
31 Spanner * sp = dynamic_cast<Spanner*>(me);
32 Real absdyn_dim = me->paper_l ()-> get_var ("crescendo_shorten");
33 Real extra_left = sp->get_broken_left_end_align ();
35 SCM dir = me->get_elt_property("grow-direction");
36 SCM dyns = me->get_elt_property ("dynamic-drul");
38 if (!isdir_b (dir) || !gh_pair_p (dyns))
44 Direction gd = to_dir (dir);
46 bool dynleft= unsmob_element (gh_car (dyns));
47 bool dynright = unsmob_element (gh_cdr (dyns));
50 extra_left += absdyn_dim;
52 Real width = sp->spanner_length()- sp->get_broken_left_end_align ();
65 warning (_ ("crescendo") + " " + _ ("too small"));
69 Drul_array<bool> broken;
73 Paper_column* s = dynamic_cast<Paper_column*>(sp->get_bound (d)); // UGH
74 broken[d] = (!s->musical_b ());
76 while (flip (&d) != LEFT);
82 SCM s = me->get_elt_property ("start-text");
85 Molecule start_text (me->lookup_l ()->text ("italic",
88 m.add_molecule (start_text);
90 pad = me->paper_l ()->get_var ("interline") / 2;
92 width -= start_text.extent (X_AXIS).length ();
98 s =me->get_elt_property ("spanner");
100 if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
102 Real thick = me->paper_l ()->get_var ("crescendo_dash_thickness");
103 Real dash = me->paper_l ()->get_var ("crescendo_dash");
105 at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
106 gh_double2scm (thick),
107 gh_double2scm (dash),
108 gh_double2scm (width),
113 bool continued = broken[Direction (-gd)];
114 height = me->paper_l()->get_var ("crescendo_height");
115 Real thick = me->paper_l ()->get_var ("crescendo_thickness");
117 const char* hairpin = (gd < 0)? "decrescendo" : "crescendo";
119 at = gh_list (ly_symbol2scm (hairpin),
120 gh_double2scm (thick),
121 gh_double2scm (width),
122 gh_double2scm (height),
123 gh_double2scm (continued ? height/2 : 0.0),
126 Box b (Interval (0, width), Interval (-2*height, 2*height));
127 Molecule span (b, at);
129 m.add_at_edge (X_AXIS, RIGHT, span, pad);
130 m.translate_axis (extra_left, X_AXIS);
132 return m.create_scheme ();