2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "script-interface.hh"
22 #include "directional-element-interface.hh"
25 #include "font-interface.hh"
26 #include "side-position-interface.hh"
27 #include "output-def.hh"
30 #include "note-column.hh"
33 Script_interface::get_stencil (Grob *me, Direction d)
35 SCM s = me->get_property ("script-stencil");
36 assert (scm_is_pair (s));
38 SCM key = scm_car (s);
39 if (scm_is_eq (key, ly_symbol2scm ("feta")))
41 SCM name_entry = scm_cdr (s);
42 SCM str = ((scm_is_pair (name_entry)) ? index_get_cell (name_entry, d)
44 return Font_interface::get_default_font (me)
45 ->find_by_name ("scripts." + ly_scm2string (str));
53 MAKE_SCHEME_CALLBACK (Script_interface, calc_positioning_done, 1);
55 Script_interface::calc_positioning_done (SCM smob)
57 Grob *me = unsmob<Grob> (smob);
58 if (Grob *par = me->get_parent (X_AXIS))
60 Grob *stem = Note_column::get_stem (par);
61 if (stem && Stem::first_head (stem))
62 me->set_parent (Stem::first_head (stem), X_AXIS);
68 Script_interface::get_direction (Grob *me)
70 Direction relative_dir = Direction (1);
71 SCM reldir = me->get_property ("side-relative-direction");
72 if (is_direction (reldir))
73 relative_dir = to_dir (reldir);
75 SCM other_elt = me->get_object ("direction-source");
76 Grob *e = unsmob<Grob> (other_elt);
78 return (Direction) (relative_dir * get_grob_direction (e));
83 MAKE_SCHEME_CALLBACK (Script_interface, calc_direction, 1);
85 Script_interface::calc_direction (SCM smob)
87 Grob *me = unsmob<Grob> (smob);
88 Direction d = Script_interface::get_direction (me);
92 me->programming_error ("script direction not yet known");
96 (void) me->get_property ("positioning-done");
97 return scm_from_int (d);
100 MAKE_SCHEME_CALLBACK (Script_interface, calc_cross_staff, 1);
102 Script_interface::calc_cross_staff (SCM smob)
104 Grob *me = unsmob<Grob> (smob);
105 Grob *stem = Note_column::get_stem (me->get_parent (X_AXIS));
107 if (stem && to_boolean (stem->get_property ("cross-staff")))
110 Grob *slur = unsmob<Grob> (me->get_object ("slur"));
111 SCM avoid_slur = me->get_property ("avoid-slur");
112 if (slur && to_boolean (slur->get_property ("cross-staff"))
113 && (scm_is_eq (avoid_slur, ly_symbol2scm ("outside"))
114 || scm_is_eq (avoid_slur, ly_symbol2scm ("around"))))
120 MAKE_SCHEME_CALLBACK (Script_interface, print, 1);
123 Script_interface::print (SCM smob)
125 Grob *me = unsmob<Grob> (smob);
127 Direction dir = get_grob_direction (me);
129 return get_stencil (me, dir).smobbed_copy ();
136 ADD_INTERFACE (Text_script,
137 "An object that is put above or below a note.",
146 Hmm. Where should we put add-stem-support ?
148 ADD_INTERFACE (Script_interface,
149 "An object that is put above or below a note.",
158 "side-relative-direction "
162 "toward-stem-shift-in-column "