(set_center_parent): new function.
* lily/side-position-interface.cc (set_axis): new function.
* lily/new-fingering-engraver.cc (position_scripts): use drul for
generic code.
* scm/define-grob-properties.scm (all-user-grob-properties):
remove [XY]-offset-callbacks add [YX]-offset
2005-11-02 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/self-aligment-interface.cc (set_align_self): new function
+ (set_center_parent): new function.
+
+ * lily/side-position-interface.cc (set_axis): new function.
+
+ * lily/new-fingering-engraver.cc (position_scripts): use drul for
+ generic code.
+
* scm/define-grob-properties.scm (all-user-grob-properties):
remove [XY]-offset-callbacks add [YX]-offset
"length-fraction "
"least-squares-dy "
"neutral-direction "
- "position-callbacks "
"positions "
"quant-score "
"shorten "
{
Grob *head = heads[0];
script_->set_parent (head, X_AXIS);
- script_->set_property ("self-X-offset",
- Self_alignment_interface::centered_on_x_parent_proc);
+ Self_alignment_interface::set_center_parent (script_, X_AXIS);
}
}
fingerings for chords need different settings.
*/
Side_position_interface::set_axis (fingering, Y_AXIS);
- fingering->set_property ("self-X-offset", Self_alignment_interface::x_aligned_on_self_proc);
- fingering->set_property ("X-offset", Self_alignment_interface::centered_on_x_parent_proc);
+ Self_alignment_interface::set_align_self (fingering, X_AXIS);
+ Self_alignment_interface::set_center_parent (fingering, X_AXIS);
// Hmm
int priority = 200;
--- /dev/null
+#include "grob.hh"
+#include "simple-closure.hh"
+
+/*
+ UGH : todo -> to different file.
+ */
+
+SCM
+axis_offset_symbol (Axis a)
+{
+ return a == X_AXIS
+ ? ly_symbol2scm ("X-offset")
+ : ly_symbol2scm ("Y-offset");
+}
+
+SCM
+axis_parent_positioning (Axis a)
+{
+ return (a == X_AXIS)
+ ? Grob::x_parent_positioning_proc
+ : Grob::y_parent_positioning_proc;
+}
+
+
+
+/*
+ Replace
+
+ (orig-proc GROB)
+
+ by
+
+ (+ (PROC GROB) (orig-proc GROB))
+
+*/
+void
+add_offset_callback (Grob *g, SCM proc, Axis a)
+{
+ SCM data = g->get_property_data (axis_offset_symbol (a));
+ if (ly_is_procedure (data))
+ data = ly_make_simple_closure (scm_list_1 (data));
+ else if (is_simple_closure (data))
+ data = simple_closure_expression (data);
+ else if (!scm_is_number (data))
+ g->internal_set_property (axis_offset_symbol (a),
+ proc);
+ else
+ {
+ SCM plus = ly_lily_module_constant ("+");
+ SCM expr = scm_list_3 (plus,
+ ly_make_simple_closure (scm_list_1 (proc)),
+ data);
+ g->internal_set_property (axis_offset_symbol (a),
+ ly_make_simple_closure (expr));
+ }
+}
+
+
+/*
+ replace
+
+ (orig-proc GROB)
+
+ by
+
+ (PROC GROB (orig-proc GROB))
+
+*/
+void
+chain_offset_callback (Grob *g, SCM proc, Axis a)
+{
+ SCM data = g->get_property_data (axis_offset_symbol (a));
+
+ if (ly_is_procedure (data))
+ data = ly_make_simple_closure (scm_list_1 (data));
+ else if (is_simple_closure (data))
+ data = simple_closure_expression (data);
+ else if (!scm_is_number (data))
+ data = scm_from_int (0);
+
+ SCM expr = scm_list_2 (proc, data);
+ g->internal_set_property (axis_offset_symbol (a),
+
+ // twice: one as a wrapper for grob property routines,
+ // once for the actual delayed binding.
+ ly_make_simple_closure (ly_make_simple_closure (expr)));
+}
if (do_internal_type_checking_global)
{
if (!ly_is_procedure (v)
+ && !is_simple_closure (v)
&& !type_check_assignment (sym, v, ly_symbol2scm ("backend-type?")))
abort ();
check_interfaces_for_property (this, sym);
{
SCM val = scm_cdr (handle);
if (!ly_is_procedure (val)
+ && !is_simple_closure (val)
&& !type_check_assignment (sym, val,
ly_symbol2scm ("backend-type?")))
abort ();
/* properties */
"X-extent "
- "X-offset-callbacks "
+ "X-offset "
"Y-extent "
- "Y-offset-callbacks "
+ "Y-offset "
"after-line-breaking "
"axis-group-parent-X "
"axis-group-parent-Y "
"transparent "
);
-
-#include "simple-closure.hh"
-
-/*
- UGH : todo -> to different file.
- */
-
-SCM
-axis_offset_symbol (Axis a)
-{
- return a == X_AXIS
- ? ly_symbol2scm ("X-offset")
- : ly_symbol2scm ("Y-offset");
-}
-
-SCM
-axis_parent_positioning (Axis a)
-{
- return (a == X_AXIS)
- ? Grob::x_parent_positioning_proc
- : Grob::y_parent_positioning_proc;
-}
-
-
-
-/*
- Replace
-
- (orig-proc GROB)
-
- by
-
- (+ (PROC GROB) (orig-proc GROB))
-
-*/
-void
-add_offset_callback (Grob *g, SCM proc, Axis a)
-{
- SCM data = g->get_property_data (axis_offset_symbol (a));
-
- if (ly_is_procedure (data))
- data = ly_make_simple_closure (scm_list_1 (data));
- else if (is_simple_closure (data))
- data = simple_closure_expression (data);
- else if (!scm_is_number (data))
- data = scm_from_int (0);
-
- SCM plus = ly_lily_module_constant ("+");
- SCM expr = scm_list_3 (plus,
- ly_make_simple_closure (scm_list_1 (proc)),
- data);
- g->internal_set_property (axis_offset_symbol (a),
- ly_make_simple_closure (expr));
-}
-
-
-/*
- replace
-
- (orig-proc GROB)
-
- by
-
- (PROC GROB (orig-proc GROB))
-
-*/
-void
-chain_offset_callback (Grob *g, SCM proc, Axis a)
-{
- SCM data = g->get_property_data (axis_offset_symbol (a));
-
- if (ly_is_procedure (data))
- data = ly_make_simple_closure (scm_list_1 (data));
- else if (is_simple_closure (data))
- data = simple_closure_expression (data);
- else if (!scm_is_number (data))
- data = scm_from_int (0);
-
- SCM expr = scm_list_2 (proc, data);
- g->internal_set_property (axis_offset_symbol (a),
-
- // twice: one as a wrapper for grob property routines,
- // once for the actual delayed binding.
- ly_make_simple_closure (ly_make_simple_closure (expr)));
-}
void
Hara_kiri_engraver::add_element (Grob *e)
{
- Hara_kiri_group_spanner::add_element (staffline_, e);
+ Axis_group_engraver::add_element (e);
}
Spanner *
return scm_from_double (0.0);
}
-void
-Hara_kiri_group_spanner::add_element (Grob *me, Grob *e)
-{
- Axis_group_interface::add_element (me, e);
-}
-
void
Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n)
{
DECLARE_SCHEME_CALLBACK (force_hara_kiri_callback, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (y_extent, (SCM smob));
DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_parent_callback, (SCM, SCM));
- static void add_element (Grob *me, Grob *e);
static bool has_interface (Grob *);
static void consider_suicide (Grob *me);
static void add_interesting_item (Grob *me, Grob *n);
static SCM aligned_on_self (Grob *me, Axis a);
static SCM centered_on_parent (Grob *me, Axis a);
static SCM aligned_on_parent (Grob *me, Axis a);
+ static void set_center_parent (Grob *me, Axis a);
+ static void set_align_self (Grob *me, Axis a);
DECLARE_SCHEME_CALLBACK (x_aligned_on_self, (SCM element));
DECLARE_SCHEME_CALLBACK (y_aligned_on_self, (SCM element));
f->set_parent (ft.head_, X_AXIS);
f->set_parent (ft.head_, Y_AXIS);
- f->set_property ("self-Y-offset",Self_alignment_interface::y_aligned_on_self_proc);
- f->set_property ("Y-offset", Self_alignment_interface::centered_on_y_parent_proc);
- f->set_property ("X-offset", Side_position_interface::x_aligned_side_proc);
+
+ Self_alignment_interface::set_align_self (f, Y_AXIS);
+ Self_alignment_interface::set_center_parent (f, Y_AXIS);
+ Side_position_interface::set_axis (f, X_AXIS);
f->set_property ("direction", scm_from_int (hordir));
}
int finger_prio = 200;
- for (int i = 0; i < up.size (); i++)
- {
- Finger_tuple ft = up[i];
- Grob *f = ft.script_;
- f->set_parent (ft.head_, X_AXIS);
- f->set_property ("script-priority",
- scm_from_int (finger_prio + ft.position_));
-
- f->set_property ("self-X-offset", Self_alignment_interface::x_aligned_on_self_proc);
- f->set_property ("Y-offset", Side_position_interface::y_aligned_side_proc);
- f->set_property ("X-offset", Self_alignment_interface::centered_on_x_parent_proc);
-
- f->set_property ("direction", scm_from_int (UP));
- }
- for (int i = 0; i < down.size (); i++)
+ Direction d = DOWN;
+ Drul_array< Array<Finger_tuple> > vertical (down, up);
+ do
{
- Finger_tuple ft = down[i];
- Grob *f = ft.script_;
- f->set_parent (ft.head_, X_AXIS);
- f->set_property ("script-priority",
- scm_from_int (finger_prio + down.size () - ft.position_));
-
- f->set_property ("self-X-offset", Self_alignment_interface::x_aligned_on_self_proc);
- f->set_property ("X-offset", Self_alignment_interface::centered_on_x_parent_proc);
- f->set_property ("Y-offset", Side_position_interface::y_aligned_side_proc);
-
- f->set_property ("direction", scm_from_int (DOWN));
+ for (int i = 0; i < vertical[d].size (); i++)
+ {
+ Finger_tuple ft = vertical[d][i];
+ Grob *f = ft.script_;
+ f->set_parent (ft.head_, X_AXIS);
+ f->set_property ("script-priority",
+ scm_from_int (finger_prio + d * ft.position_));
+
+ Self_alignment_interface::set_align_self (f, X_AXIS);
+ Self_alignment_interface::set_center_parent (f, X_AXIS);
+ Side_position_interface::set_axis (f, Y_AXIS);
+
+ f->set_property ("direction", scm_from_int (d));
+ }
}
+ while (flip (&d) != DOWN);
}
void
return scm_from_double (x);
}
+void
+Self_alignment_interface::set_center_parent (Grob *me, Axis a)
+{
+ add_offset_callback (me,
+ (a==X_AXIS) ? centered_on_x_parent_proc : centered_on_y_parent_proc,
+ a);
+}
+
+void
+Self_alignment_interface::set_align_self (Grob *me, Axis a)
+{
+ add_offset_callback (me,
+ (a==X_AXIS) ? x_aligned_on_self_proc : y_aligned_on_self_proc,
+ a);
+}
+
ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
"Position this object on itself and/or on its parent. To this end, the following functions "
" are provided: \n"
"@table @code \n"
- "@item Self_alignment_interface::aligned_on_self\n"
+ "@item Self_alignment_interface::[xy]_aligned_on_self\n"
" Align self on reference point, using @code{self-alignment-X} and "
"@code{self-alignment-Y}."
- "@item Self_alignment_interface::aligned_on_parent\n"
- "@item Self_alignment_interface::centered_on_parent\n"
+ "@item Self_alignment_interface::aligned_on_[xy]_parent\n"
+ "@item Self_alignment_interface::centered_on_[xy]_parent\n"
" Shift the object so its own reference point is centered on the "
" extent of the parent \n"
- "@item Self_alignment_interface::centered_on_other_axis_parent\n"
- " For X-axis, center on the Y-parent, and vice versa.\n "
"@end table\n",
/* porperties */
"self-alignment-X "
+ "self-X-offset "
+ "self-Y-offset "
"self-alignment-Y ");
void
Side_position_interface::set_axis (Grob *me, Axis a)
{
- me->internal_set_property (axis_offset_symbol (a),
- (a==X_AXIS)
- ? x_aligned_side_proc
- : y_aligned_side_proc);
+ add_offset_callback (me,
+ (a==X_AXIS)
+ ? x_aligned_side_proc
+ : y_aligned_side_proc,
+ a);
}
// ugh. doesn't catch all variants.
"symbol. "
"These usually have @code{Staff_symbol_referencer::callback} "
"in their @code{Y-offset-callbacks}. ",
+
+ /* properties */
"staff-position");
(X-offset ,number? "The horizontal amount that this object is moved relative to its X-parent")
(Y-offset ,number? "The vertical amount that this object is moved
relative to its X-parent")
+ (self-X-offset ,number? "")
+ (self-Y-offset ,number? "")
(accidentals ,list? "List of alteration numbers")
(alteration-alist ,list? "List of @code{(@var{pitch}
. @var{accidental})} pairs for key signature.")
(chord-tremolo ,boolean? "if set, this beam is a tremolo. ")
(begin-of-line-visible ,boolean? "Used for marking ChordNames that should only show changes.")
+ (quantize-position ,boolean? "If set, a vertical alignment is aligned to be within staff spaces.")
(quant-score ,string? "Beam quanting score -- can be stored for
debugging")
(X-extent . ,Axis_group_interface::width)
(meta . ((class . Spanner)
(interfaces . (axis-group-interface
+ hara-kiri-group-interface
vertically-spaceable-interface))))))
(VocalName