1 /*
2 This file is part of LilyPond, the GNU music typesetter.
3
4 Copyright (C) 2005--2021 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "grob.hh"
21 #include "unpure-pure-container.hh"
22 #include "lily-imports.hh"
23
24 SCM
axis_offset_symbol(Axis a)25 axis_offset_symbol (Axis a)
26 {
27 return a == X_AXIS
28 ? ly_symbol2scm ("X-offset")
29 : ly_symbol2scm ("Y-offset");
30 }
31
32 SCM
axis_parent_positioning(Axis a)33 axis_parent_positioning (Axis a)
34 {
35 return (a == X_AXIS)
36 ? Grob::x_parent_positioning_proc
37 : Grob::y_parent_positioning_proc;
38 }
39
40 /*
41 Replace
42
43 (orig-proc GROB)
44
45 by
46
47 (+ (PROC GROB) (orig-proc GROB))
48 */
49 void
add_offset_callback(Grob * g,SCM proc,Axis a)50 add_offset_callback (Grob *g, SCM proc, Axis a)
51 {
52 SCM sym = axis_offset_symbol (a);
53 SCM data = get_property_data (g, sym);
54 set_property (g, sym, Lily::grob_offset_function (proc, data));
55 }
56
57 /*
58 replace
59
60 (orig-proc GROB)
61
62 by
63
64 (PROC GROB (orig-proc GROB))
65 */
66 void
chain_callback(Grob * g,SCM proc,SCM sym)67 chain_callback (Grob *g, SCM proc, SCM sym)
68 {
69 SCM data = get_property_data (g, sym);
70 set_property (g, sym, Lily::grob_compose_function (proc, data));
71 }
72
73 void
chain_offset_callback(Grob * g,SCM proc,Axis a)74 chain_offset_callback (Grob *g, SCM proc, Axis a)
75 {
76 chain_callback (g, proc, axis_offset_symbol (a));
77 }
78