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 ()
20 set_elt_property ("dynamic-drul", gh_cons (SCM_BOOL_F, SCM_BOOL_F));
27 Crescendo::do_brew_molecule () const
29 Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
30 Real extra_left = get_broken_left_end_align ();
32 SCM dir = get_elt_property("grow-direction");
33 SCM dyns = get_elt_property ("dynamic-drul");
35 if (!isdir_b (dir) || !gh_pair_p (dyns))
37 Crescendo * me = (Crescendo*)this;
38 me->set_elt_property ("transparent", SCM_BOOL_T);
44 Direction gd = to_dir (dir);
46 bool dynleft= to_boolean (gh_car (dyns));
47 bool dynright = to_boolean (gh_cdr (dyns));
50 extra_left += absdyn_dim;
54 Real width = spanner_length()- get_broken_left_end_align ();
67 warning (_ ("crescendo") + " " + _ ("too small"));
71 Drul_array<bool> broken;
75 Paper_column* s = dynamic_cast<Paper_column*>(get_bound (d)); // UGH
76 broken[d] = (!s->musical_b ());
78 while (flip (&d) != LEFT);
84 SCM s = get_elt_property ("start-text");
87 Molecule start_text (lookup_l ()->text ("italic",
90 m.add_molecule (start_text);
92 pad = paper_l ()->get_var ("interline") / 2;
94 width -= start_text.extent ()[X_AXIS].length ();
100 s = get_elt_property ("spanner");
102 if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
104 Real thick = paper_l ()->get_var ("crescendo_dash_thickness");
105 Real dash = paper_l ()->get_var ("crescendo_dash");
107 at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
108 gh_double2scm (thick),
109 gh_double2scm (dash),
110 gh_double2scm (width),
115 bool continued = broken[Direction (-gd)];
116 height = paper_l()->get_var ("crescendo_height");
117 Real thick = paper_l ()->get_var ("crescendo_thickness");
119 const char* hairpin = (gd < 0)? "decrescendo" : "crescendo";
121 at = gh_list (ly_symbol2scm (hairpin),
122 gh_double2scm (thick),
123 gh_double2scm (width),
124 gh_double2scm (height),
125 gh_double2scm (continued ? height/2 : 0.0),
128 Box b (Interval (0, width), Interval (-2*height, 2*height));
129 Molecule span (b, at);
131 m.add_at_edge (X_AXIS, RIGHT, span, pad);
132 m.translate_axis (extra_left, X_AXIS);