Format and improve documentation of internal grob properties.
[lilypond.git] / lily / script-interface.cc
blob6db959113e846e182fb0d724956b8dc62a0ffa25
1 /*
2 script-interface.cc -- implement Script_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "script-interface.hh"
11 #include "directional-element-interface.hh"
12 #include "item.hh"
13 #include "warn.hh"
14 #include "font-interface.hh"
15 #include "side-position-interface.hh"
16 #include "output-def.hh"
17 #include "lookup.hh"
18 #include "stem.hh"
19 #include "note-column.hh"
21 Stencil
22 Script_interface::get_stencil (Grob *me, Direction d)
24 SCM s = me->get_property ("script-stencil");
25 assert (scm_is_pair (s));
27 SCM key = scm_car (s);
28 if (key == ly_symbol2scm ("feta"))
30 SCM name_entry = scm_cdr (s);
31 SCM str = ((scm_is_pair (name_entry)) ? index_get_cell (name_entry, d)
32 : name_entry);
33 return Font_interface::get_default_font (me)
34 ->find_by_name ("scripts." + ly_scm2string (str));
36 else if (key == ly_symbol2scm ("accordion"))
37 return Lookup::accordion (scm_cdr (s), 1.0,
38 Font_interface::get_default_font (me));
39 else
40 assert (false);
42 return Stencil ();
45 MAKE_SCHEME_CALLBACK (Script_interface, calc_positioning_done, 1);
46 SCM
47 Script_interface::calc_positioning_done (SCM smob)
49 Grob *me = unsmob_grob (smob);
50 if (Grob *par = me->get_parent (X_AXIS))
52 Grob *stem = Note_column::get_stem (par);
53 if (stem && Stem::first_head (stem))
54 me->set_parent (Stem::first_head (stem), X_AXIS);
56 return SCM_BOOL_T;
59 MAKE_SCHEME_CALLBACK (Script_interface, calc_direction, 1);
60 SCM
61 Script_interface::calc_direction (SCM smob)
63 Grob *me = unsmob_grob (smob);
64 Direction d = Side_position_interface::get_direction (me);
66 if (!d)
68 me->programming_error ("script direction not yet known");
69 d = DOWN;
72 (void) me->get_property ("positioning-done");
73 return scm_from_int (d);
76 MAKE_SCHEME_CALLBACK (Script_interface, calc_cross_staff, 1);
77 SCM
78 Script_interface::calc_cross_staff (SCM smob)
80 Grob *me = unsmob_grob (smob);
81 Grob *stem = Note_column::get_stem (me->get_parent (X_AXIS));
82 return scm_from_bool (stem && to_boolean (stem->get_property ("cross-staff")));
85 MAKE_SCHEME_CALLBACK (Script_interface, print, 1);
87 SCM
88 Script_interface::print (SCM smob)
90 Grob *me = unsmob_grob (smob);
92 Direction dir = get_grob_direction (me);
94 return get_stencil (me, dir).smobbed_copy ();
97 struct Text_script
99 DECLARE_GROB_INTERFACE ();
102 ADD_INTERFACE (Text_script,
103 "An object that is put above or below a note",
105 /* properties */
106 "add-stem-support "
107 "avoid-slur "
108 "script-priority "
109 "slur "
113 Hmm. Where should we put add-stem-support ?
115 ADD_INTERFACE (Script_interface,
116 "An object that is put above or below a note",
117 "add-stem-support "
118 "avoid-slur "
119 "positioning-done "
120 "script-priority "
121 "script-stencil "
122 "slur "
123 "slur-padding "