modify the #'elements property, so return reordered array.
+2004-03-22 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/break-align-interface.cc (ordered_elements): we cannot
+ modify the #'elements property, so return reordered array.
+
2004-03-23 Heikki Junes <hjunes@cc.hut.fi>
* buildscripts/lilypond.words.py: remove.
Grob * common = common_refpoint_of_list (elts, me, a);
Real my_coord = me->relative_coordinate (common, a);
- Interval r (relative_group_extent (a, common,elts));
+ Interval r (relative_group_extent (a, common, elts));
return ly_interval2scm (r - my_coord);
}
{
interval_a_[X_AXIS].widen (x);
interval_a_[Y_AXIS].widen (y);
-
}
}
-void
-Break_align_interface::order_elements (Grob *grob)
+/*
+ This is tricky: we cannot modify 'elements, since callers are
+ iterating the same list. Reordering the list in-place, or resetting
+ 'elements will skip elements in the loops of callers.
+
+ So we return the correct order as an array.
+ */
+Link_array<Grob>
+Break_align_interface::ordered_elements (Grob *grob)
{
Item *me = dynamic_cast<Item*> (grob);
SCM elts = me->get_property ("elements");
SCM order_vec = me->get_property ("break-align-orders");
if (!gh_vector_p (order_vec)
|| gh_vector_length (order_vec) < 3)
- return ;
-
+ return Pointer_group_interface__extract_grobs (me, (Grob*)0,
+ "elements");
SCM order = scm_vector_ref (order_vec,
gh_int2scm (me->break_status_dir() + 1));
+
/*
- Copy in order specified in BREAK-ALIGN-ORDER. We use
- Pointer_group_interface__extract_grobs (which reverses the list)
- down the line, so it's ok to prepend onto newlist.
- */
- SCM new_list = SCM_EOL;
+ Copy in order specified in BREAK-ALIGN-ORDER.
+ */
+ Link_array<Grob> new_elts;
for (; gh_pair_p (order); order = ly_cdr (order))
{
SCM sym = gh_car (order);
-
- SCM *tail = &elts;
- for (; gh_pair_p (*tail); tail = SCM_CDRLOC(*tail))
+
+ for (SCM s =elts; gh_pair_p (s); s = gh_cdr (s))
{
- Grob * g = unsmob_grob (gh_car (*tail));
- if (sym == g->get_property ("break-align-symbol"))
+ Grob *g = unsmob_grob (gh_car (s));
+ if (g && sym == g->get_property ("break-align-symbol"))
{
- SCM new_pair = *tail;
- *tail = gh_cdr (*tail);
- if (gh_pair_p (*tail))
- tail = SCM_CDRLOC(*tail);
-
- gh_set_cdr_x (new_pair, new_list);
- new_list = new_pair;
- break;
+ new_elts.push (g);
+ elts = scm_delq (g->self_scm (), elts);
}
}
}
-
- new_list = scm_reverse_x (elts, new_list);
- me->set_property ("elements", new_list);
+ return new_elts;
}
void
{
Item * me = dynamic_cast<Item*> (grob);
- order_elements (me);
- Link_array<Grob> elems
- = Pointer_group_interface__extract_grobs (me, (Grob*)0,
- "elements");
+ Link_array<Grob> elems = ordered_elements (me);
Array<Interval> extents;
int last_nonempty = -1;
{
public:
static void do_alignment (Grob*);
- static void new_do_alignment (Grob*);
- static void order_elements (Grob *me);
+ static Link_array<Grob> ordered_elements (Grob *me);
static bool has_interface (Grob*);
static void add_element (Grob*me, Grob*add);
DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis));
SCM sml = me->get_property ("use-breve-rest");
if (measures == 1)
{
- if (sml == SCM_BOOL_T)
+ if (to_boolean (sml))
{
Stencil s = musfont->find_by_name (Rest::glyph_name (me, -1, ""));
Item * lb = l->find_prebroken_piece (RIGHT);
Item * rb = r->find_prebroken_piece (LEFT);
- Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
+ Item* combinations[4][2] = {{l,r},
+ {lb,r},
+ {l,rb},
+ {lb,rb}};
Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length ();
for (int i=0; i < 4; i++)
{
- Item * l = combinations[i][0];
+ Item *l = combinations[i][0];
Item *r = combinations[i][1];
if (!l || !r)
SCM val = get_music ()->get_property ("grob-value");
if (to_boolean (get_music ()->get_property ("pop-first"))
- && !to_boolean (get_music ()->get_property ("once"))
- )
+ && !to_boolean (get_music ()->get_property ("once")))
execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED);
execute_pushpop_property (get_outlet (), sym, eprop, val);
}
else if (last_spacings_.staff_spacing_)
{
-
last_spacings_.staff_spacing_->set_property ("right-items",
gh_cons (break_item_->self_scm (), SCM_EOL));
}
*/
if (!where)
return ;
+
if (where != trg)
{
SCM base = updated_grob_properties (trg, prop);