#include <libc-extension.hh>
-#include "debug.hh"
+#include "warn.hh"
#include "spanner.hh"
#include "paper-column.hh"
#include "paper-score.hh"
#include "molecule.hh"
#include "paper-outputter.hh"
#include "paper-column.hh"
-#include "line-of-score.hh"
-
+#include "system.hh"
#include "group-interface.hh"
void
{
spanned_drul_[LEFT]=0;
spanned_drul_[RIGHT]=0;
+ Group_interface::add_thing (this, ly_symbol2scm ("interfaces"), ly_symbol2scm ("spanner-interface"));
+
+
}
Spanner::Spanner (Spanner const &s)
return SCM_EOL;
}
-void
-add_bound_item (Spanner* sp, Item*it)
-{
- if (!sp->get_bound (LEFT))
- sp->set_bound (LEFT, it);
- else
- sp->set_bound (RIGHT, it);
-}
/*
- Extends EXTREMAL_PAIR to include IT
- */
-static void
-extend_spanner_over_item (Item *it, SCM extremal_pair)
-{
- if (!it)
- return;
- Item * col = it->column_l ();
- Item * i1 = dynamic_cast<Item*> (unsmob_grob (ly_car (extremal_pair)));
- Item * i2 = dynamic_cast<Item*> (unsmob_grob (ly_cdr (extremal_pair)));
- int r = Paper_column::rank_i (col);
- if (!i1 || r < Paper_column::rank_i (i1->column_l ()))
- {
- gh_set_car_x (extremal_pair, it->self_scm ());
- }
- if (!i2 || r > Paper_column::rank_i (i2->column_l ()))
- {
- gh_set_cdr_x (extremal_pair, it->self_scm ());
- }
-}
+ Set left or right bound to IT.
-/*
- Extends EXTREMAL_PAIR to include every grob in VALUE
+ Warning: caller should ensure that subsequent calls put in ITems
+ that are left-to-right ordered.
*/
-static void
-extend_spanner_over_elements (SCM value, SCM extremal_pair)
-{
- if (gh_pair_p (value))
- {
- extend_spanner_over_elements (ly_car (value), extremal_pair);
- extend_spanner_over_elements (ly_cdr (value), extremal_pair);
- }
- else if (unsmob_grob (value))
- {
- if (Spanner * sp = dynamic_cast<Spanner*> (unsmob_grob (value)))
- {
- extend_spanner_over_item (sp->get_bound (LEFT), extremal_pair);
- extend_spanner_over_item (sp->get_bound (RIGHT), extremal_pair);
- }
- else if (Item * it= dynamic_cast<Item*> (unsmob_grob (value)))
- extend_spanner_over_item (it, extremal_pair);
- }
-}
-
-
-/*
- Make sure that the left and right bounds encompasses all objects it
- points to.
-
- TODO: maybe be more specific. Most probably fucks up if someone sets
- a pointer to the staff symbol in S
-*/
void
-extend_spanner_over_elements (Grob*s)
+add_bound_item (Spanner* sp, Grob*it)
{
- Spanner*sp = dynamic_cast<Spanner*> (s);
-
- SCM s1 = sp->get_bound (LEFT) ? sp->get_bound (LEFT)->self_scm () : SCM_EOL;
- SCM s2 = sp->get_bound (RIGHT) ? sp->get_bound (RIGHT)->self_scm () : SCM_EOL;
-
- SCM pair = gh_cons (s1,s2);
- extend_spanner_over_elements (sp->mutable_property_alist_, pair);
-
- Grob *p1 = unsmob_grob (ly_car (pair));
- Grob* p2 = unsmob_grob (ly_cdr (pair));
- sp->set_bound (LEFT,p1);
- sp->set_bound (RIGHT, p2);
+ if (!sp->get_bound (LEFT))
+ sp->set_bound (LEFT, it);
+ else
+ sp->set_bound (RIGHT, it);
}
{
return dynamic_cast<Spanner*> (unsmob_grob (s));
}
+
+ADD_INTERFACE(Spanner,
+ "spanner-interface",
+ "
+Other grobs have a shape that depends on the horizontal spacing. For
+example, slur, beam, tie, etc. These grobs form a subtype called
+@code{Spanner}. All spanners have two span-points (these must be
+@code{Item}s), one on the left and one on the right. The left bound is
+also the X-reference point of the spanner.
+",
+ "minimum-length");