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));
27 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Crescendo)
29 Crescendo::do_brew_molecule () const
31 Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
32 Real extra_left = get_broken_left_end_align ();
34 SCM dir = get_elt_property("grow-direction");
35 SCM dyns = get_elt_property ("dynamic-drul");
37 if (!isdir_b (dir) || !gh_pair_p (dyns))
39 Crescendo * me = (Crescendo*)this;
46 Direction gd = to_dir (dir);
48 bool dynleft= to_boolean (gh_car (dyns));
49 bool dynright = to_boolean (gh_cdr (dyns));
52 extra_left += absdyn_dim;
56 Real width = spanner_length()- get_broken_left_end_align ();
69 warning (_ ("crescendo") + " " + _ ("too small"));
73 Drul_array<bool> broken;
77 Paper_column* s = dynamic_cast<Paper_column*>(get_bound (d)); // UGH
78 broken[d] = (!s->musical_b ());
80 while (flip (&d) != LEFT);
86 SCM s = get_elt_property ("start-text");
89 Molecule start_text (lookup_l ()->text ("italic",
92 m.add_molecule (start_text);
94 pad = paper_l ()->get_var ("interline") / 2;
96 width -= start_text.extent (X_AXIS).length ();
102 s = get_elt_property ("spanner");
104 if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
106 Real thick = paper_l ()->get_var ("crescendo_dash_thickness");
107 Real dash = paper_l ()->get_var ("crescendo_dash");
109 at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
110 gh_double2scm (thick),
111 gh_double2scm (dash),
112 gh_double2scm (width),
117 bool continued = broken[Direction (-gd)];
118 height = paper_l()->get_var ("crescendo_height");
119 Real thick = paper_l ()->get_var ("crescendo_thickness");
121 const char* hairpin = (gd < 0)? "decrescendo" : "crescendo";
123 at = gh_list (ly_symbol2scm (hairpin),
124 gh_double2scm (thick),
125 gh_double2scm (width),
126 gh_double2scm (height),
127 gh_double2scm (continued ? height/2 : 0.0),
130 Box b (Interval (0, width), Interval (-2*height, 2*height));
131 Molecule span (b, at);
133 m.add_at_edge (X_AXIS, RIGHT, span, pad);
134 m.translate_axis (extra_left, X_AXIS);