source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
assert (a == X_AXIS);
Grob *par = me->get_parent (a);
- if (par && !to_boolean (par->get_grob_property ("break-alignment-done")))
+ if (par && !to_boolean (par->get_property ("positioning-done")))
{
- par->set_grob_property ("break-alignment-done", SCM_BOOL_T);
+ par->set_property ("positioning-done", SCM_BOOL_T);
Break_align_interface::do_alignment (par);
}
Direction bsd = item->break_status_dir ();
if (bsd == LEFT)
{
- me->set_grob_property ("self-alignment-X", scm_int2num (RIGHT));
+ me->set_property ("self-alignment-X", scm_int2num (RIGHT));
}
/*
return Self_alignment_interface::aligned_on_self (element_smob, axis);
}
+
+void
+Break_align_interface::order_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 ;
+
+ 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;
+ 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))
+ {
+ Grob * g = unsmob_grob (gh_car (*tail));
+ if (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_list = scm_reverse_x (elts, new_list);
+ me->set_property ("elements", new_list);
+}
+
void
Break_align_interface::add_element (Grob*me, Grob *toadd)
{
}
void
-Break_align_interface::do_alignment (Grob *me)
+Break_align_interface::do_alignment (Grob *grob)
{
- Item * item = dynamic_cast<Item*> (me);
+ Item * me = dynamic_cast<Item*> (grob);
+
+ order_elements (me);
+
Link_array<Grob> elems
= Pointer_group_interface__extract_grobs (me, (Grob*)0,
"elements");
idx++;
Array<Real> offsets;
- offsets.set_size (elems.size());
- for (int i= 0; i < offsets.size();i ++)
+ offsets.set_size (elems.size ());
+ for (int i= 0; i < offsets.size ();i ++)
offsets[i] = 0.0;
Real extra_right_space = 0.0;
int edge_idx = -1;
- while (idx < elems.size())
+ while (idx < elems.size ())
{
int next_idx = idx+1;
- while (next_idx < elems.size() &&
+ while (next_idx < elems.size () &&
extents[next_idx].is_empty () )
next_idx++;
Grob *l = elems[idx];
Grob *r = 0;
- if (next_idx < elems.size())
+ if (next_idx < elems.size ())
r = elems[next_idx];
SCM alist = SCM_EOL;
/*
Find the first grob with a space-alist entry.
*/
- for (SCM s= l->get_grob_property ("elements");
+ for (SCM s= l->get_property ("elements");
gh_pair_p (s) ; s = gh_cdr (s))
{
Grob *elt = unsmob_grob (gh_car (s));
if (edge_idx < 0
- && elt->get_grob_property ("break-align-symbol")
- == ly_symbol2scm( "left-edge"))
+ && elt->get_property ("break-align-symbol")
+ == ly_symbol2scm ( "left-edge"))
edge_idx = idx;
- SCM l =elt->get_grob_property ("space-alist");
- if (gh_pair_p(l))
+ SCM l =elt->get_property ("space-alist");
+ if (gh_pair_p (l))
{
alist= l;
break;
table, but that gets icky when that grob is suicided for some
reason.
*/
- for (SCM s = r ? r->get_grob_property ("elements") : SCM_EOL;
+ for (SCM s = r ? r->get_property ("elements") : SCM_EOL;
!gh_symbol_p (rsym) && gh_pair_p (s); s = gh_cdr (s))
{
- Grob * elt =unsmob_grob(gh_car (s));
+ Grob * elt =unsmob_grob (gh_car (s));
- rsym = elt->get_grob_property ("break-align-symbol");
+ rsym = elt->get_property ("break-align-symbol");
}
- if (rsym == ly_symbol2scm("left-edge"))
+ if (rsym == ly_symbol2scm ("left-edge"))
edge_idx = next_idx;
SCM entry = SCM_EOL;
if (!entry_found)
{
String sym_string;
- if(gh_symbol_p (rsym))
+ if (gh_symbol_p (rsym))
sym_string = ly_symbol2string (rsym);
String orig_string ;
- if (unsmob_grob (l->get_grob_property ("cause")))
- orig_string = unsmob_grob (l->get_grob_property ("cause"))->name ();
+ if (unsmob_grob (l->get_property ("cause")))
+ orig_string = unsmob_grob (l->get_property ("cause"))->name ();
- programming_error (_f("No spacing entry from %s to `%s'",
+ programming_error (_f ("No spacing entry from %s to `%s'",
orig_string.to_str0 (),
sym_string.to_str0 ()));
}
offsets[next_idx] = extents[idx][RIGHT] + distance
- extents[next_idx][LEFT];
/* should probably junk minimum-space */
- else if (type == ly_symbol2scm("minimum-space"))
+ else if (type == ly_symbol2scm ("minimum-space"))
offsets[next_idx] = extents[idx][RIGHT] >? distance;
}
else
Interval total_extent;
Real alignment_off =0.0;
- for (int i =0 ; i < offsets.size(); i++)
+ for (int i =0 ; i < offsets.size (); i++)
{
here += offsets[i];
if (i == edge_idx)
}
- if (item->break_status_dir () == LEFT)
+ if (me->break_status_dir () == LEFT)
{
alignment_off = - total_extent[RIGHT] - extra_right_space;
}
alignment_off = -total_extent[LEFT];
here = alignment_off;
- for (int i =0 ; i < offsets.size(); i++)
+ for (int i =0 ; i < offsets.size (); i++)
{
here += offsets[i];
elems[i]->translate_axis (here, X_AXIS);
ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface",
- //
-"Items that are aligned in prefatory matter.\n"
-"\n"
-"The spacing of these items is controlled by the space-alist\n"
-"property. It contains a list break-align-symbols with a specification\n"
-"of the associated space. The space definition is either (extra-space\n"
-". @var{number}), which adds space after the symbol, (minimum-space\n"
-". @var{ms}), which pads the space until it it is @var{ms}.\n"
-"\n"
-"\n"
-"Special keys for the alist are 'first-note and 'next-note, signifyign\n"
-"the first note on a line, and the next note halfway a line.\n"
-"\n"
-"Rules for this spacing are much more complicated than this. \n"
-"See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147\n",
- "break-align-symbol break-alignment-done space-alist");
+ "Items that are aligned in prefatory matter.\n"
+ "\n"
+ "The spacing of these items is controlled by the @code{space-alist}\n"
+ "property. It contains a list @code{break-align-symbol}s with a specification\n"
+ "of the associated space. The space specification can be "
+ "@table @code\n"
+ "@item (minimum-space . @var{spc}))\n"
+ " Pad space until the distance is @var{spc}\n"
+ "@item (fixed-space . @var{spc})\n"
+ " Set a fixed space\n"
+ "@item (semi-fixed-space . @var{spc})\n"
+ " Set a space. Half of it is fixed and half is stretchable. \n"
+ "(does not work at start of line. fixme)\n"
+ "@item (extra-space . @var{spc})\n"
+ " Add @var{spc} amount of space.\n"
+ "@end table\n"
+ "\n"
+ "Special keys for the alist are @code{first-note} and @code{next-note}, signifying\n"
+ "the first note on a line, and the next note halfway a line.\n"
+ "\n"
+ "Rules for this spacing are much more complicated than this. \n"
+ "See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147\n",
+ "break-align-symbol space-alist");
ADD_INTERFACE (Break_align_interface, "break-alignment-interface",
- "See @ref{break-aligned-interface}.",
- "break-alignment-done");
+ "The object that performs break aligment. See @ref{break-aligned-interface}.",
+ "positioning-done break-align-orders");