+1.3.95.jcn2
+===========
+
+* Dropped text support and padding of crescendo symbol. Horizontal
+ alignment of dynamics is handled by side-support, Text crescendos
+ use the generic Text spanner.
+
1.3.95.jcn1
===========
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=95
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
#include "debug.hh"
#include "paper-column.hh"
-void
-Crescendo::set_interface (Score_element*s)
-{
- s->set_elt_property ("dynamic-drul", gh_cons (SCM_EOL, SCM_EOL));
-}
-
-
-
-MAKE_SCHEME_CALLBACK(Crescendo,brew_molecule,1);
-
-/*
-
- TODO:
-
- * should span the crescendo on any dynamic-text items, and
- calculate their dimensions to determine shortening; junk shortening
- code and related elt props.
-
- * separate the dashed-line version and the hairpin version into two
- brew_molecule functions.
+MAKE_SCHEME_CALLBACK (Crescendo, brew_molecule, 1);
- * generalise dashed-line into generic text spanner, for ottava, accelerando, etc.
-
-
-*/
SCM
Crescendo::brew_molecule (SCM smob)
{
Score_element *me= unsmob_element (smob);
- Spanner * sp = dynamic_cast<Spanner*>(me);
- Real ss = me->paper_l ()->get_var ("staffspace");
- Real sl = me->paper_l ()->get_var ("stafflinethickness");
+ Spanner *span = dynamic_cast<Spanner*>(me);
+ Real staff_space = me->paper_l ()->get_var ("staffspace");
+ Real line = me->paper_l ()->get_var ("stafflinethickness");
- Real absdyn_dim = gh_scm2double (me->get_elt_property ("shorten-for-letter"));
- Real extra_left = sp->get_broken_left_end_align ();
+ Real broken_left = span->get_broken_left_end_align ();
- SCM dir = me->get_elt_property("grow-direction");
- SCM dyns = me->get_elt_property ("dynamic-drul");
-
- if (!isdir_b (dir) || !gh_pair_p (dyns))
+ SCM s = me->get_elt_property("grow-direction");
+ if (!isdir_b (s))
{
me->suicide ();
return SCM_EOL;
}
- Direction gd = to_dir (dir);
+ Direction grow_dir = to_dir (s);
- bool dynleft= unsmob_element (gh_car (dyns));
- bool dynright = unsmob_element (gh_cdr (dyns));
-
- if (dynleft)
- extra_left += absdyn_dim;
-
- Real width = sp->spanner_length()- sp->get_broken_left_end_align ();
-
- if (dynleft)
- {
- width -= absdyn_dim;
- }
- if (dynright)
- {
- width -= absdyn_dim;
- }
+ Real width = span->spanner_length ();
+ width -= span->get_broken_left_end_align ();
if (width < 0)
{
- warning (_ ("crescendo") + " " + _ ("too small"));
+ warning (_ ((grow_dir < 0) ? "decrescendo too small"
+ : "crescendo too small"));
width = 0;
}
Direction d = LEFT;
do
{
- Paper_column* s = dynamic_cast<Paper_column*>(sp->get_bound (d)); // UGH
+ Paper_column* s = dynamic_cast<Paper_column*> (span->get_bound (d)); // UGH
broken[d] = (!s->musical_b ());
}
while (flip (&d) != LEFT);
-
- Molecule m;
+ bool continued = broken[Direction (-grow_dir)];
+ Real height = staff_space * gh_scm2double (me->get_elt_property ("height"));
+ Real thick = line * gh_scm2double (me->get_elt_property ("thickness"));
- Real pad = 0;
- SCM s = me->get_elt_property ("start-text");
- if (gh_string_p (s))
- {
- Molecule start_text (me->lookup_l ()->text ("italic",
- ly_scm2string (s),
- me->paper_l ()));
- m.add_molecule (start_text);
-
- pad = me->paper_l ()->get_var ("staffspace") / 2; // ugh.
-
- width -= start_text.extent (X_AXIS).length ();
- width -= pad;
- width = width >? 0;
- }
-
- SCM at;
- s =me->get_elt_property ("spanner");
- Real height;
-
- if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
- {
- Real thick = gh_scm2double (me->get_elt_property ("dash-thickness")) * sl ;
- Real dash = gh_scm2double (me->get_elt_property ("dash-length")) * ss;
-
- height = thick;
- at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
- gh_double2scm (thick),
- gh_double2scm (dash),
- gh_double2scm (width),
- SCM_UNDEFINED);
- }
- else
- {
- bool continued = broken[Direction (-gd)];
- height = ss * gh_scm2double (me->get_elt_property ("height"));
- Real thick = sl * gh_scm2double (me->get_elt_property ("thickness"));
-
- const char* hairpin = (gd < 0)? "decrescendo" : "crescendo";
-
- at = gh_list (ly_symbol2scm (hairpin),
+ 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);
- }
- Box b (Interval (0, width), Interval (-2*height, 2*height));
- Molecule span (b, at);
- m.add_at_edge (X_AXIS, RIGHT, span, pad);
- m.translate_axis (extra_left, X_AXIS);
+ Box b (Interval (0, width), Interval (-2*height, 2*height));
+ Molecule mol (b, hairpin);
+ mol.translate_axis (broken_left, X_AXIS);
- return m.create_scheme ();
+ return mol.create_scheme ();
}
else
{
current_cresc_req_ = accepted_spanreqs_drul_[START];
- cresc_p_ = new Spanner (get_property ("Crescendo"));
- Crescendo::set_interface (cresc_p_);
- cresc_p_->set_elt_property
- ("grow-direction",
- gh_int2scm ((accepted_spanreqs_drul_[START]->span_type_str_ == "crescendo")
- ? BIGGER : SMALLER));
-
- SCM s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Text").ch_C());
- if (gh_string_p (s))
- {
- cresc_p_->set_elt_property ("start-text", s);
- daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
- + "Text", SCM_UNDEFINED);
- }
-
- s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Spanner").ch_C());
-
/*
TODO: Use symbols.
*/
- if (gh_string_p (s)) //&& ly_scm2string (s) != "hairpin")
+ SCM s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Spanner").ch_C());
+
+ if (!gh_string_p (s) || ly_scm2string (s) == "hairpin")
{
- cresc_p_->set_elt_property ("spanner", s);
+ cresc_p_ = new Spanner (get_property ("Crescendo"));
+ cresc_p_->set_elt_property ("grow-direction",
+ gh_int2scm ((accepted_spanreqs_drul_[START]->span_type_str_ == "crescendo")
+ ? BIGGER : SMALLER));
+
+ }
+ /*
+ This is a convenient (and legacy) interface to TextSpanners
+ for use in (de)crescendi.
+ Hmm.
+ */
+ else
+ {
+ cresc_p_ = new Spanner (get_property ("TextSpanner"));
+ cresc_p_->set_elt_property ("type", s);
daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
+ "Spanner", SCM_UNDEFINED);
+ s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Text").ch_C());
+ if (gh_string_p (s))
+ {
+ cresc_p_->set_elt_property ("edge-text",
+ gh_cons (s, ly_str02scm ("")));
+ daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
+ + "Text", SCM_UNDEFINED);
+ }
}
-
+
Score_element *cc = unsmob_element (get_property ("currentMusicalColumn"));
cresc_p_->set_bound (LEFT, cc);
-
- /*
- We know how wide the text is, if we can be sure that the
- text already has relevant pointers into the paperdef,
- and it has its font-size property set.
-
- Since font-size may be set by a context higher up, we
- can not be sure of the size.
-
-
- We shouldn't try to do this stuff here, the Item should
- do it when the score is finished. We could maybe
- set a callback to have the Item do the alignment if
- it is not a special symbol, like Crescendo.
- */
-
-
if (text_p_)
{
- index_set_cell (cresc_p_->get_elt_property ("dynamic-drul"),
- LEFT, text_p_->self_scm ());
-
- if (finished_cresc_p_
- // I don't see why, but we need this check
- && gh_pair_p (finished_cresc_p_->get_elt_property ("dynamic-drul")))
- index_set_cell (finished_cresc_p_->get_elt_property ("dynamic-drul"),
- RIGHT, text_p_->self_scm ());
+ Side_position::set_direction (text_p_, LEFT);
+ Side_position::set_axis (text_p_, X_AXIS);
+ Side_position::add_support (text_p_, cresc_p_);
}
Axis_group_interface::add_element (line_spanner_, cresc_p_);
struct Crescendo
{
public:
- DECLARE_SCHEME_CALLBACK(brew_molecule, (SCM ));
- static void set_interface(Score_element*);
+ DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
static bool has_interface (Score_element*);
};
Score_element *me = unsmob_element (smob);
Interval iv;
- //Score_element *common = me;
- Score_element *common = 0;
+ Score_element *common = me;
for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
{
Score_element *arpeggio = unsmob_element (gh_car (s));
- if (common)
- common = arpeggio->common_refpoint (common, Y_AXIS);
- else
- common = arpeggio;
+ common = common->common_refpoint (arpeggio, Y_AXIS);
}
- if (0) //common)
- for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
- {
- Score_element *arpeggio = unsmob_element (gh_car (s));
- // this dumps core: someone has no y-parent
- Real c = common->relative_coordinate (arpeggio, Y_AXIS);
- //iv.unite (Arpeggio::head_positions (stem));
- iv.unite (Interval (c, c));
- }
- else
- iv = Interval (-23, 5);
+ for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
+ {
+ Score_element *arpeggio = unsmob_element (gh_car (s));
+ Real c = arpeggio->relative_coordinate (common, Y_AXIS);
+ Interval height = arpeggio->extent (Y_AXIS);
+ iv.unite (height + c);
+ }
+ iv *= 0.5;
Molecule mol;
Molecule arpeggio = me->paper_l ()->lookup_l (0)->afm_find ("scripts-arpeggio");
a.translate_axis (i * staff_space, Y_AXIS);
mol.add_molecule (a);
}
- mol.translate (Offset (-2 * staff_space, 0));
+ // huh?
+ Real dy = me->relative_coordinate (common, Y_AXIS);
+ mol.translate (Offset (-2 * staff_space, -2*dy));
return mol.create_scheme ();
}