summaryrefslogtreecommitdiff
path: root/lily/spanner.cc
diff options
context:
space:
mode:
authorMike Solomon <mike@apollinemike.com>2011-03-16 15:07:34 -0400
committerMike Solomon <mike@apollinemike.com>2011-03-16 15:07:34 -0400
commita339f8b9865b0f02febd351ba494129d414fb568 (patch)
tree99a12240e9af206155e671356f104e3205966038 /lily/spanner.cc
parent84bdcba4e72ed9161fa6091441a41a02d81069aa (diff)
Fixes Issue 1504, allowing feather beam line breaking.
Makes it such that the degree of feathering at the end of a system is preserved at the beginning of the next system. Adds a normalized-endpoints property to Spanner, which calculates the portion of a spanner (normalized from 0 to 1) taken up by any broken child.
Diffstat (limited to 'lily/spanner.cc')
-rw-r--r--lily/spanner.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/lily/spanner.cc b/lily/spanner.cc
index 6083c67461..d3fd5a0955 100644
--- a/lily/spanner.cc
+++ b/lily/spanner.cc
@@ -398,6 +398,53 @@ Spanner::set_spacing_rods (SCM smob)
return SCM_UNSPECIFIED;
}
+MAKE_SCHEME_CALLBACK (Spanner, calc_normalized_endpoints, 1);
+SCM
+Spanner::calc_normalized_endpoints (SCM smob)
+{
+ Spanner *me = unsmob_spanner (smob);
+ SCM result = SCM_EOL;
+
+ Spanner *orig = dynamic_cast<Spanner *> (me->original ());
+
+ orig = orig ? orig : me;
+
+ if (orig->is_broken ())
+ {
+ Real total_width = 0.0;
+ vector<Real> span_data;
+
+ if (!orig->is_broken ())
+ span_data.push_back (orig->spanner_length ());
+ else
+ for (vsize i = 0; i < orig->broken_intos_.size (); i++)
+ span_data.push_back (orig->broken_intos_[i]->spanner_length ());
+
+ vector<Interval> unnormalized_endpoints;
+
+ for (vsize i = 0; i < span_data.size (); i++)
+ {
+ unnormalized_endpoints.push_back (Interval (total_width, total_width + span_data[i]));
+ total_width += span_data[i];
+ }
+
+ for (vsize i = 0; i < unnormalized_endpoints.size (); i++)
+ {
+ SCM t = ly_interval2scm (1 / total_width * unnormalized_endpoints[i]);
+ orig->broken_intos_[i]->set_property ("normalized-endpoints", t);
+ if (me->get_break_index () == i)
+ result = t;
+ }
+ }
+ else
+ {
+ result = scm_cons (scm_from_double (0.0), scm_from_double (1.0));
+ orig->set_property ("normalized-endpoints", result);
+ }
+
+ return result;
+}
+
Spanner *
unsmob_spanner (SCM s)
{
@@ -479,6 +526,7 @@ ADD_INTERFACE (Spanner,
" point of the spanner.",
/* properties */
+ "normalized-endpoints "
"minimum-length "
"to-barline "
);