]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-interface.cc
(stop_translation_timestep): new
[lilypond.git] / lily / script-interface.cc
1 /*   
2   script-interface.cc --  implement Script_interface
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "directional-element-interface.hh"
11 #include "warn.hh"
12 #include "script-interface.hh"
13 #include "font-interface.hh"
14 #include "side-position-interface.hh"
15 #include "output-def.hh"
16 #include "item.hh"
17 #include "stencil.hh"
18 #include "lookup.hh"
19 #include "stem.hh"
20 #include "note-column.hh"
21
22 Stencil
23 Script_interface::get_stencil (Grob *me, Direction d)
24 {
25   SCM s = me->get_property ("script-stencil");
26   assert (ly_c_pair_p (s));
27
28   SCM key = ly_car (s);
29   if (key == ly_symbol2scm ("feta"))
30     {
31       SCM name_entry = ly_cdr (s);
32       SCM str = ((ly_c_pair_p (name_entry)) ? index_get_cell (name_entry, d)
33                  : name_entry);
34       return Font_interface::get_default_font (me)
35         ->find_by_name ("scripts-" + ly_scm2string (str));
36     }
37   else if (key == ly_symbol2scm ("accordion"))
38     return Lookup::accordion (ly_cdr (s), 1.0,
39                               Font_interface::get_default_font (me));
40   else
41     assert (false);
42
43   return Stencil ();
44 }
45
46 MAKE_SCHEME_CALLBACK (Script_interface, before_line_breaking, 1);
47 SCM
48 Script_interface::before_line_breaking (SCM smob)
49 {
50   Grob *me = unsmob_grob (smob);
51
52   Direction d = Side_position_interface::get_direction (me);
53
54   if (!d)
55     {
56       /* FIXME: This should never happen: `arbitrary' directions.  */
57       programming_error ("Script direction not yet known!");
58       d = DOWN;
59     }
60
61   set_grob_direction (me, d);
62
63   if (Grob *par = me->get_parent (X_AXIS))
64     {
65       Grob *stem = Note_column::get_stem (par);
66       if (stem && Stem::first_head (stem))
67         me->set_parent (Stem::first_head (stem), X_AXIS);
68     }
69   return SCM_UNSPECIFIED;
70 }
71
72 MAKE_SCHEME_CALLBACK (Script_interface, print, 1);
73
74 SCM
75 Script_interface::print (SCM smob)
76 {
77   Grob *me= unsmob_grob (smob);
78
79   Direction dir = Side_position_interface::get_direction (me);
80   if (!dir)
81     {
82       programming_error ("Script direction not known, but stencil wanted.");
83       dir = DOWN;
84     }
85   return get_stencil (me, dir).smobbed_copy ();
86 }
87
88 struct Text_script
89 {
90   static bool has_interface (Grob*);
91 };
92
93 ADD_INTERFACE (Text_script,"text-script-interface",
94   "An object that is put above or below a note",
95   "add-stem-support slur script-priority inside-slur");
96
97
98 /*
99   Hmm. Where should we put add-stem-support ?
100  */
101 ADD_INTERFACE (Script_interface, "script-interface",
102   "An object that is put above or below a note",
103   "add-stem-support slur script-priority script-stencil inside-slur");
104