source file of the GNU LilyPond music typesetter
- (c) 1996--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <math.h>
#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 "break-align-item.hh"
+#include "system.hh"
#include "group-interface.hh"
void
*/
for (int a = X_AXIS; a < NO_AXES; a ++)
{
- if (Spanner* parent = dynamic_cast<Spanner*> (parent_l ((Axis)a)))
+ if (Spanner* parent = dynamic_cast<Spanner*> (get_parent ((Axis)a)))
{
if (!parent->spanned_rank_iv ().contains_b (this->spanned_rank_iv ()))
{
spanned_drul_[d] =i;
/**
- We check for Line_of_score to prevent the column -> line_of_score
+ We check for System to prevent the column -> line_of_score
-> column -> line_of_score -> etc situation */
- if (d== LEFT && !dynamic_cast<Line_of_score*> (this))
+ if (d== LEFT && !dynamic_cast<System*> (this))
{
set_parent (i, X_AXIS);
}
*/
if (dynamic_cast<Paper_column*> (i))
{
- Pointer_group_interface::add_element (i, "bounded-by-me",this);
+ Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);
}
}
{
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 r-l;
}
-Line_of_score *
+System *
Spanner::line_l () const
{
if (!spanned_drul_[LEFT] || !spanned_drul_[RIGHT])
Grob*
-Spanner::find_broken_piece (Line_of_score*l) const
+Spanner::find_broken_piece (System*l) const
{
int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare);
{
/*
We'd be fucked if this is called before spanned_drul_[] is inited. */
- if (status_i_ == ORPHAN)
+ if (status_c_ == ORPHAN)
return SCM_EOL;
Direction d = LEFT;
return SCM_EOL;
}
+
+/*
+ Set left or right bound to IT.
+
+ Warning: caller should ensure that subsequent calls put in ITems
+ that are left-to-right ordered.
+ */
void
-add_bound_item (Spanner* sp, Item*it)
+add_bound_item (Spanner* sp, Grob*it)
{
if (!sp->get_bound (LEFT))
sp->set_bound (LEFT, it);
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 (gh_car (extremal_pair)));
- Item * i2 = dynamic_cast<Item*> (unsmob_grob (gh_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 ());
- }
-}
-/*
- Extends EXTREMAL_PAIR to include every grob in VALUE
- */
-static void
-extend_spanner_over_elements (SCM value, SCM extremal_pair)
+MAKE_SCHEME_CALLBACK (Spanner,set_spacing_rods,1);
+SCM
+Spanner::set_spacing_rods (SCM smob)
{
- if (gh_pair_p (value))
- {
- extend_spanner_over_elements (gh_car (value), extremal_pair);
- extend_spanner_over_elements (gh_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);
- }
+ Grob*me = unsmob_grob (smob);
+
+ Rod r;
+ Spanner*sp = dynamic_cast<Spanner*> (me);
+ r.item_l_drul_[LEFT] = sp->get_bound (LEFT);
+ r.item_l_drul_[RIGHT] = sp->get_bound (RIGHT);
+ r.distance_f_ =
+ gh_scm2double (me->get_grob_property ("minimum-length"))
+ * 1.0;
+
+ r.add_to_cols ();
+ return SCM_UNSPECIFIED;
}
-/*
- 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 staffsymbol in S
-*/
-void
-extend_spanner_over_elements (Grob*s)
+Spanner*
+unsmob_spanner (SCM s )
{
- 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 (gh_car (pair));
- Grob* p2 = unsmob_grob (gh_cdr (pair));
- sp->set_bound (LEFT,p1);
- sp->set_bound (RIGHT, p2);
+ 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");