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"
12 #include "dimensions.hh"
13 #include "paper-def.hh"
15 #include "paper-column.hh"
18 Crescendo::Crescendo (SCM s)
21 set_elt_property ("dynamic-drul", gh_cons (SCM_BOOL_F, SCM_BOOL_F));
28 Crescendo::do_brew_molecule () const
30 Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
31 Real extra_left = get_broken_left_end_align ();
33 SCM dir = get_elt_property("grow-direction");
34 SCM dyns = get_elt_property ("dynamic-drul");
36 if (!isdir_b (dir) || !gh_pair_p (dyns))
38 Crescendo * me = (Crescendo*)this;
39 me->set_elt_property ("transparent", SCM_BOOL_T);
45 Direction gd = to_dir (dir);
47 bool dynleft= to_boolean (gh_car (dyns));
48 bool dynright = to_boolean (gh_cdr (dyns));
51 extra_left += absdyn_dim;
55 Real width = spanner_length()- get_broken_left_end_align ();
68 warning (_ ("crescendo") + " " + _ ("too small"));
72 Drul_array<bool> broken;
76 Paper_column* s = dynamic_cast<Paper_column*>(get_bound (d)); // UGH
77 broken[d] = (!s->musical_b ());
79 while (flip (&d) != LEFT);
85 SCM s = get_elt_property ("start-text");
88 Molecule start_text (lookup_l ()->text ("italic",
91 m.add_molecule (start_text);
93 pad = paper_l ()->get_var ("interline") / 2;
95 width -= start_text.extent (X_AXIS).length ();
101 s = get_elt_property ("spanner");
103 if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
105 Real thick = paper_l ()->get_var ("crescendo_dash_thickness");
106 Real dash = paper_l ()->get_var ("crescendo_dash");
108 at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
109 gh_double2scm (thick),
110 gh_double2scm (dash),
111 gh_double2scm (width),
116 bool continued = broken[Direction (-gd)];
117 height = paper_l()->get_var ("crescendo_height");
118 Real thick = paper_l ()->get_var ("crescendo_thickness");
120 const char* hairpin = (gd < 0)? "decrescendo" : "crescendo";
122 at = gh_list (ly_symbol2scm (hairpin),
123 gh_double2scm (thick),
124 gh_double2scm (width),
125 gh_double2scm (height),
126 gh_double2scm (continued ? height/2 : 0.0),
129 Box b (Interval (0, width), Interval (-2*height, 2*height));
130 Molecule span (b, at);
132 m.add_at_edge (X_AXIS, RIGHT, span, pad);
133 m.translate_axis (extra_left, X_AXIS);