-ADD_TRANSLATOR (Vertical_align_engraver,
-/* descr */ "Catch Vertical axis groups and stack them.",
-/* creats*/ "VerticalAlignment",
-/* accepts */ "",
-/* acks */ "axis-group-interface",
-/* reads */ "",
-/* write */ "");
+
+ SCM before_id = i.context ()->get_property ("alignAboveContext");
+ SCM after_id = i.context ()->get_property ("alignBelowContext");
+
+ SCM before = scm_hash_ref (id_to_group_hashtab_, before_id, SCM_BOOL_F);
+ SCM after = scm_hash_ref (id_to_group_hashtab_, after_id, SCM_BOOL_F);
+
+
+ Align_interface::add_element (valign_, i.grob (),
+ get_property ("verticalAlignmentChildCallback"));
+
+ if (unsmob_grob (before) || unsmob_grob (after))
+ {
+ SCM elts = valign_->get_property ("elements");
+ SCM new_order = scm_cdr (elts);
+ SCM *current = &new_order;
+
+ for (SCM s = new_order; scm_is_pair (s); s = scm_cdr (s))
+ {
+ if (scm_car (s) == after)
+ {
+ *current = scm_cons (i.grob ()->self_scm(), s);
+ break;
+ }
+ else if (scm_car (s) == before)
+ {
+ scm_set_cdr_x (s, scm_cons (i.grob ()->self_scm (),
+ scm_cdr (s)));
+ break;
+ }
+
+ current = SCM_CDRLOC (s);
+ }
+
+ valign_->set_property ("elements", new_order);
+ }
+ }
+}