2 #include "simple-closure.hh"
3 #include "unpure-pure-container.hh"
4 #include "lily-imports.hh"
7 axis_offset_symbol (Axis a)
10 ? ly_symbol2scm ("X-offset")
11 : ly_symbol2scm ("Y-offset");
15 axis_parent_positioning (Axis a)
18 ? Grob::x_parent_positioning_proc
19 : Grob::y_parent_positioning_proc;
29 (+ (PROC GROB) (orig-proc GROB))
32 add_offset_callback (Grob *g, SCM proc, Axis a)
34 SCM data = g->get_property_data (axis_offset_symbol (a));
35 if (!scm_is_number (data)
36 && !ly_is_procedure (data)
37 && !unsmob<Simple_closure> (data))
39 g->set_property (axis_offset_symbol (a), proc);
43 if (ly_is_procedure (data) || unsmob<Unpure_pure_container> (data))
44 data = Simple_closure::make_smob (scm_list_1 (data));
45 else if (Simple_closure *sc = unsmob<Simple_closure> (data))
46 data = sc->expression ();
48 if (ly_is_procedure (proc))
49 proc = Simple_closure::make_smob (scm_list_1 (proc));
51 SCM expr = scm_list_3 (Guile_user::plus, proc, data);
52 g->set_property (axis_offset_symbol (a), Simple_closure::make_smob (expr));
62 (PROC GROB (orig-proc GROB))
65 chain_callback (Grob *g, SCM proc, SCM sym)
67 SCM data = g->get_property_data (sym);
69 if (ly_is_procedure (data) || unsmob<Unpure_pure_container> (data))
70 data = Simple_closure::make_smob (scm_list_1 (data));
71 else if (Simple_closure *sc = unsmob<Simple_closure> (data))
72 data = sc->expression ();
75 Data may be nonnumber. In that case, it is assumed to be
81 SCM expr = scm_list_2 (proc, data);
84 // twice: one as a wrapper for grob property routines,
85 // once for the actual delayed binding.
86 Simple_closure::make_smob (Simple_closure::make_smob (expr)));
90 chain_offset_callback (Grob *g, SCM proc, Axis a)
92 chain_callback (g, proc, axis_offset_symbol (a));