2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "engraver.hh"
12 #include "side-position-interface.hh"
16 #include "rhythmic-head.hh"
17 #include "text-item.hh"
21 typeset directions that are plain text.
23 class Text_engraver
: public Engraver
25 Link_array
<Music
> reqs_
;
26 Link_array
<Item
> texts_
;
28 TRANSLATOR_DECLARATIONS(Text_engraver
);
30 virtual bool try_music (Music
* m
);
31 virtual void stop_translation_timestep ();
32 virtual void start_translation_timestep ();
33 virtual void process_acknowledged_grobs ();
34 virtual void acknowledge_grob (Grob_info
);
38 Text_engraver::try_music (Music
*m
)
40 if (m
->is_mus_type ("text-script-event"))
49 Text_engraver::acknowledge_grob (Grob_info inf
)
51 if (Rhythmic_head::has_interface (inf
.grob_
))
53 for (int i
=0; i
< texts_
.size (); i
++)
56 Side_position_interface::add_support (t
,inf
.grob_
);
61 if (Side_position_interface::get_axis (t
) == X_AXIS
62 && !t
->get_parent (Y_AXIS
))
63 t
->set_parent (inf
.grob_
, Y_AXIS
);
64 else if (Side_position_interface::get_axis (t
) == Y_AXIS
65 && !t
->get_parent (X_AXIS
))
66 t
->set_parent (inf
.grob_
, X_AXIS
);
70 if (Stem::has_interface (inf
.grob_
))
72 for (int i
=0; i
< texts_
.size (); i
++)
74 Side_position_interface::add_support (texts_
[i
],inf
.grob_
);
80 Text_engraver::process_acknowledged_grobs ()
84 for (int i
=0; i
< reqs_
.size (); i
++)
88 // URG: Text vs TextScript
89 String basic
= "TextScript";
91 Item
*text
= new Item (get_property (basic
.to_str0 ()));
94 FIXME -> need to use basic props.
96 SCM axisprop
= get_property ("scriptHorizontal");
98 Axis ax
= to_boolean (axisprop
) ? X_AXIS
: Y_AXIS
;
99 Side_position_interface::set_axis (text
, ax
);
103 SCM s
= text
->get_grob_property ("script-priority");
105 priority
= gh_scm2int (s
);
107 /* see script-engraver.cc */
110 text
->set_grob_property ("script-priority", gh_int2scm (priority
));
112 Direction dir
= to_dir (r
->get_mus_property ("direction"));
114 Side_position_interface::set_direction (text
, dir
);
117 SCM mark
= r
->get_mus_property ("text");
119 if (new_markup_p (mark
))
120 text
->set_grob_property ("molecule-callback", new_markup_brewer());
122 text
->set_grob_property ("text", mark
);
123 announce_grob (text
, r
->self_scm ());
129 Text_engraver::stop_translation_timestep ()
131 for (int i
=0; i
< texts_
.size (); i
++)
133 Item
*ti
= texts_
[i
];
134 if (!to_boolean (get_property ("scriptHorizontal")))
135 Side_position_interface::add_staff_support (ti
);
142 Text_engraver::start_translation_timestep ()
148 Text_engraver::Text_engraver(){}
150 ENTER_DESCRIPTION(Text_engraver
,
151 /* descr */ "Create text-scripts",
152 /* creats*/ "TextScript",
153 /* accepts */ "text-script-event",
154 /* acks */ "rhythmic-head-interface stem-interface",
155 /* reads */ "scriptHorizontal",