source file of the GNU LilyPond music typesetter
- (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "separating-group-spanner.hh"
-#include "single-malt-grouping-item.hh"
-#include "p-col.hh"
+#include "separation-item.hh"
+#include "paper-column.hh"
#include "paper-def.hh"
#include "dimensions.hh"
+#include "group-interface.hh"
-static Rod
-make_rod (Single_malt_grouping_item *l, Single_malt_grouping_item *r)
+static void
+do_rod (Item *l, Item *r)
{
Rod rod;
+
+ Interval li (Separation_item::my_width (l));
+ Interval ri (Separation_item::my_width (r));
+
rod.item_l_drul_[LEFT] =l;
rod.item_l_drul_[RIGHT]=r;
- Interval li (l->my_width ());
- Interval ri (r->my_width ());
-
if (li.empty_b () || ri.empty_b ())
rod.distance_f_ = 0;
else
rod.distance_f_ = li[RIGHT] - ri[LEFT];
- return rod;
+ rod.columnize ();
+ rod.add_to_cols ();
}
-
-Array<Rod>
-Separating_group_spanner::get_rods () const
+MAKE_SCHEME_CALLBACK(Separating_group_spanner,set_spacing_rods,1);
+SCM
+Separating_group_spanner::set_spacing_rods (SCM smob)
{
- Array<Rod> a;
+ Score_element*me = unsmob_element (smob);
- for (int i=0; i < spacing_unit_l_arr_.size () -1; i++)
+ for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s))
{
- Single_malt_grouping_item *l =spacing_unit_l_arr_[i];
- Single_malt_grouping_item *lb
- = dynamic_cast<Single_malt_grouping_item*>(l->find_prebroken_piece (RIGHT));
- Single_malt_grouping_item *r = spacing_unit_l_arr_[i+1];
- Single_malt_grouping_item *rb
- = dynamic_cast<Single_malt_grouping_item*>(r->find_prebroken_piece (LEFT));
+ /*
+ Order of elements is reversed!
+ */
+ SCM elt = gh_cadr (s);
+ SCM next_elt = gh_car (s);
+
+ Item *l = dynamic_cast<Item*> (unsmob_element (elt));
+ Item *r = dynamic_cast<Item*> (unsmob_element ( next_elt));
+
+ if (!r || !l)
+ continue;
+
+ Item *lb
+ = dynamic_cast<Item*>(l->find_prebroken_piece (RIGHT));
+
+ Item *rb
+ = dynamic_cast<Item*>(r->find_prebroken_piece (LEFT));
- a.push (make_rod(spacing_unit_l_arr_[i], spacing_unit_l_arr_[i+1]));
+ do_rod(l, r);
if (lb)
{
- Rod rod(make_rod (lb, r));
- rod.distance_f_ += padding_f_;
- a.push (rod);
+ do_rod (lb, r);
}
if (rb)
{
- a.push (make_rod (l, rb));
+ do_rod (l, rb);
}
if (lb && rb)
{
- Rod rod(make_rod (lb, rb));
- rod.distance_f_ += padding_f_;
- a.push (rod);
+ do_rod (lb, rb);
+
}
}
-
- return a;
+
+ /*
+ We've done our job, so we get lost.
+ */
+ for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
+ {
+ Item * it =dynamic_cast<Item*>(unsmob_element (gh_car (s)));
+ if (it && it->broken_b ())
+ {
+ it->find_prebroken_piece (LEFT) ->suicide ();
+ it->find_prebroken_piece (RIGHT)->suicide ();
+ }
+ it->suicide ();
+ }
+ me->suicide ();
+ return SCM_UNSPECIFIED ;
}
void
-Separating_group_spanner::add_spacing_unit (Single_malt_grouping_item*i)
+Separating_group_spanner::add_spacing_unit (Score_element* me ,Item*i)
{
- spacing_unit_l_arr_.push (i);
- add_dependency (i);
+ Pointer_group_interface::add_element (me, "elements",i);
+ me->add_dependency (i);
}
+
void
-Separating_group_spanner::do_substitute_element_pointer (Score_element*o,
- Score_element*n)
+Separating_group_spanner::set_interface (Score_element*)
{
- if (dynamic_cast<Single_malt_grouping_item *> (o))
- {
- Single_malt_grouping_item*ns = dynamic_cast<Single_malt_grouping_item *> (n);
- spacing_unit_l_arr_.substitute (dynamic_cast<Single_malt_grouping_item *> (o), ns);
- }
-}
-Separating_group_spanner::Separating_group_spanner()
-{
- set_elt_property (break_helper_only_scm_sym, SCM_BOOL_T);
- padding_f_ =0.0;
}