Slice parent_rank_slice;
parent_rank_slice.set_full ();
-
+
/*
Check if our parent in X-direction spans equally wide
or wider than we do.
if (Spanner *parent = dynamic_cast<Spanner *> (get_parent ((Axis)a)))
parent_rank_slice.intersect (parent->spanned_rank_interval ());
}
-
+
for (vsize i = 1; i < break_points.size (); i++)
{
Drul_array<Item *> bounds;
bool ok = parent_rank_slice.contains (bounds[LEFT]->get_column ()->get_rank ());
ok = ok && parent_rank_slice.contains (bounds[RIGHT]->get_column ()->get_rank ());
-
+
if (!ok)
{
programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner. Ignoring orphaned part",
name ().c_str ()));
continue;
}
-
-
+
+
Spanner *span = dynamic_cast<Spanner *> (clone ());
span->set_bound (LEFT, bounds[LEFT]);
span->set_bound (RIGHT, bounds[RIGHT]);
Real
Spanner::spanner_length () const
{
- Real l = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS);
- Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS);
+ Interval lr;
- if (r < l)
+ Drul_array<SCM> bounds (get_property ("left-bound-info"),
+ get_property ("right-bound-info"));
+
+ Direction d = LEFT;
+ do
+ lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"),
+ bounds[d], SCM_BOOL_F), -d);
+ while (flip (&d) != LEFT);
+
+ if (lr.is_empty ())
+ {
+ do
+ lr[d] = spanned_drul_[d]->relative_coordinate (0, X_AXIS);
+ while (flip (&d) != LEFT);
+ }
+
+ if (lr.is_empty ())
programming_error ("spanner with negative length");
- return r - l;
+ return lr.length ();
}
System *
sp->get_bound (RIGHT));
if (!bounds[LEFT] || !bounds[RIGHT])
return SCM_UNSPECIFIED;
-
+
vector<Item*> cols (root->broken_col_range (bounds[LEFT]->get_column (),
bounds[RIGHT]->get_column ()));
r.item_drul_[RIGHT] = cols[0]->find_prebroken_piece (LEFT);
r.distance_ = robust_scm2double (num_length, 0);
r.add_to_cols ();
-
+
r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT);
r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
r.add_to_cols ();
}
-
+
r.distance_ = robust_scm2double (num_length, 0);
r.item_drul_[LEFT] = sp->get_bound (LEFT);
r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
r.add_to_cols ();
}
-
+
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)
{
Interval w (me->get_bound (LEFT)->relative_coordinate (common, X_AXIS),
me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS));
-
+
w -= me->relative_coordinate (common, X_AXIS);
return ly_interval2scm (w);
Spanner::kill_zero_spanned_time (SCM grob)
{
Spanner *me = unsmob_spanner (grob);
- Interval_t<Moment> moments = me->spanned_time ();
/*
Remove the line or hairpin at the start of the line. For
piano voice indicators, it makes no sense to have them at
--hwn.
*/
- if (moments.length () == Moment (0, 0))
- me->suicide ();
+ if (me->get_bound (LEFT)->break_status_dir ())
+ {
+ Interval_t<Moment> moments = me->spanned_time ();
+ moments [LEFT].grace_part_ = 0;
+ if (moments.length () == Moment (0, 0))
+ me->suicide ();
+ }
return SCM_UNSPECIFIED;
}
" point of the spanner.",
/* properties */
+ "normalized-endpoints "
"minimum-length "
+ "spanner-broken "
+ "spanner-id "
"to-barline "
);
-