(c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
-#include "spanner.hh"
-
-
#include "pointer-group-interface.hh"
#include "libc-extension.hh"
#include "paper-column.hh"
Spanner::set_spacing_rods (SCM smob)
{
Grob *me = unsmob_grob (smob);
-
- Rod r;
- Spanner *sp = dynamic_cast<Spanner *> (me);
- r.item_drul_[LEFT] = sp->get_bound (LEFT);
- r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
-
SCM num_length = me->get_property ("minimum-length");
if (scm_is_number (num_length))
{
+ Rod r;
+ Spanner *sp = dynamic_cast<Spanner *> (me);
+
+
+ System *root = get_root_system (me);
+ vector<Item*> cols (root->broken_col_range (sp->get_bound (LEFT)->get_column (),
+ sp->get_bound (RIGHT)->get_column ()));
+
+ if (cols.size ())
+ {
+ Rod r ;
+ r.item_drul_[LEFT] = sp->get_bound (LEFT);
+ 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 dynamic_cast<Spanner *> (unsmob_grob (s));
}
+MAKE_SCHEME_CALLBACK(Spanner, bounds_width, 1);
+SCM
+Spanner::bounds_width (SCM grob)
+{
+ Spanner *me = unsmob_spanner (grob);
+
+
+ Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
+
+ 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);
+}
+
ADD_INTERFACE (Spanner,
- "spanner-interface",
"Some objects are horizontally spanned between objects. For\n"
"example, slur, beam, tie, etc. These grobs form a subtype called\n"
"@code{Spanner}. All spanners have two span-points (these must be\n"
"@code{Item} objects), one on the left and one on the right. The left bound is\n"
"also the X-reference point of the spanner.\n",
- "minimum-length");
+
+ "minimum-length "
+ );