source file of the GNU LilyPond music typesetter
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "molecule.hh"
-#include "dimen.hh"
#include "crescendo.hh"
-#include "lookup.hh"
+#include "spanner.hh"
+#include "font-interface.hh"
+#include "dimensions.hh"
#include "paper-def.hh"
#include "debug.hh"
-#include "score-column.hh"
+#include "paper-column.hh"
-Crescendo::Crescendo()
-{
- grow_dir_ =0;
- dir_ = DOWN;
- dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
-}
+MAKE_SCHEME_CALLBACK (Crescendo, brew_molecule, 1);
-Interval
-Crescendo::symbol_height() const
+SCM
+Crescendo::brew_molecule (SCM smob)
{
- return get_symbol().dim_[Y_AXIS];
-}
+ Score_element *me= unsmob_element (smob);
+ Spanner *span = dynamic_cast<Spanner*>(me);
-static Real absdyn_dim = 10 PT; // ugh
+ Real line = me->paper_l ()->get_var ("stafflinethickness");
+
+ Real broken_left = span->get_broken_left_end_align ();
-Atom
-Crescendo::get_symbol() const
-{
- Real w_dim = width().length ();
- if (dyn_b_drul_[LEFT])
- {
- w_dim -= absdyn_dim;
- }
- if (dyn_b_drul_[RIGHT])
+ SCM s = me->get_elt_property("grow-direction");
+ if (!isdir_b (s))
{
- w_dim -= absdyn_dim;
+ me->suicide ();
+ return SCM_EOL;
}
+
+ Direction grow_dir = to_dir (s);
- if (w_dim < 0)
+ Real width = span->spanner_length ();
+ width -= span->get_broken_left_end_align ();
+
+ if (width < 0)
{
- warning (_("Crescendo too small"));
- w_dim = 0;
+ warning (_ ((grow_dir < 0) ? "decrescendo too small"
+ : "crescendo too small"));
+ width = 0;
}
Drul_array<bool> broken;
Direction d = LEFT;
- do {
- Score_column* s = (Score_column* )spanned_drul_[d] ; // UGH
- broken[d] = (!s->musical_b());
- } while ((d *= -1) != LEFT);
+ do
+ {
+ Paper_column* s = dynamic_cast<Paper_column*> (span->get_bound (d)); // UGH
+ broken[d] = (!s->musical_b ());
+ }
+ while (flip (&d) != LEFT);
+ bool continued = broken[Direction (-grow_dir)];
+ Real height = gh_scm2double (me->get_elt_property ("height"));
+ Real thick = line * gh_scm2double (me->get_elt_property ("thickness"));
+
+ const char* type = (grow_dir < 0) ? "decrescendo" : "crescendo";
+ SCM hairpin = gh_list (ly_symbol2scm (type),
+ gh_double2scm (thick),
+ gh_double2scm (width),
+ gh_double2scm (height),
+ gh_double2scm (continued ? height/2 : 0.0),
+ SCM_UNDEFINED);
- bool continued = broken[(Direction)-grow_dir_];
- return Atom (paper()->lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued));
-}
-
-Molecule*
-Crescendo::brew_molecule_p() const
-{
- Molecule* m_p =0;
- Real x_off_dim=0.0;
- if (dyn_b_drul_[LEFT])
- x_off_dim += absdyn_dim;
+ Box b (Interval (0, width), Interval (-2*height, 2*height));
+ Molecule mol (b, hairpin);
+ mol.translate_axis (broken_left, X_AXIS);
- m_p = new Molecule;
- Atom s (get_symbol());
- m_p->add (Atom (s));
- m_p->translate (Offset (x_off_dim, y_));
- return m_p;
+ return mol.smobbed_copy ();
}
-IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);