]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / script.cc
1 /*   
2   script.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.hh"
13 #include "font-interface.hh"
14 #include "side-position-interface.hh"
15 #include "paper-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_grob_property ("script-stencil");
26   assert (gh_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
33       SCM str = (gh_pair_p (name_entry)) ? index_get_cell (name_entry, d) :  name_entry;
34       return Font_interface::get_default_font (me)->find_by_name ("scripts-" +
35                                                                   ly_scm2string (str));
36     }
37  else if (key == ly_symbol2scm ("accordion"))
38     {
39       return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me));
40     }
41   else
42     assert (false);
43
44   return Stencil ();
45 }
46
47 MAKE_SCHEME_CALLBACK (Script_interface,before_line_breaking,1);
48 SCM
49 Script_interface::before_line_breaking (SCM smob)
50 {
51   Grob * me = unsmob_grob (smob);
52
53   Direction d = Side_position_interface::get_direction (me);
54
55   if (!d)
56     {
57       /*
58         we should not have `arbitrary' directions. 
59       */
60       programming_error ("Script direction not yet known!");
61       d = DOWN;
62     }
63   
64   set_grob_direction (me, d);
65
66   if (Grob * par = me->get_parent (X_AXIS))
67     {
68       Grob * stem = Note_column::get_stem (par);
69       if (stem && Stem::first_head (stem))
70         {
71           me->set_parent (Stem::first_head (stem), X_AXIS);
72         }
73     }
74   
75   return SCM_UNSPECIFIED;
76 }
77
78
79 MAKE_SCHEME_CALLBACK (Script_interface,print,1);
80
81 SCM
82 Script_interface::print (SCM smob)
83 {
84   Grob *me= unsmob_grob (smob);
85
86   Direction dir = Side_position_interface::get_direction (me);
87   if (!dir)
88     {
89       programming_error ("Script direction not known, but stencil wanted.");
90       dir= DOWN;
91     }
92   
93   return get_stencil (me, dir).smobbed_copy ();
94 }
95
96
97
98 struct Text_script
99 {
100     static bool has_interface (Grob*);
101 };
102
103 struct Skript
104 {
105     static bool has_interface (Grob*);
106 };
107
108 ADD_INTERFACE (Text_script,"text-script-interface",
109   "Any text script",
110   "script-priority");
111
112 ADD_INTERFACE (Script_interface, "script-interface",
113   "",
114   "script-priority script-stencil");
115