2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "directional-element-interface.hh"
10 #include "engraver.hh"
11 #include "side-position-interface.hh"
15 #include "rhythmic-head.hh"
16 #include "text-item.hh"
20 typeset directions that are plain text.
22 class Text_engraver
: public Engraver
24 Link_array
<Music
> evs_
;
25 Link_array
<Item
> texts_
;
27 TRANSLATOR_DECLARATIONS (Text_engraver
);
29 virtual bool try_music (Music
* m
);
30 virtual void stop_translation_timestep ();
31 virtual void process_acknowledged_grobs ();
32 virtual void acknowledge_grob (Grob_info
);
36 Text_engraver::try_music (Music
*m
)
38 if (m
->is_mus_type ("text-script-event"))
47 Text_engraver::acknowledge_grob (Grob_info inf
)
49 if (Rhythmic_head::has_interface (inf
.grob_
))
51 for (int i
=0; i
< texts_
.size (); i
++)
54 Side_position_interface::add_support (t
,inf
.grob_
);
59 if (Side_position_interface::get_axis (t
) == X_AXIS
60 && !t
->get_parent (Y_AXIS
))
61 t
->set_parent (inf
.grob_
, Y_AXIS
);
62 else if (Side_position_interface::get_axis (t
) == Y_AXIS
63 && !t
->get_parent (X_AXIS
))
64 t
->set_parent (inf
.grob_
, X_AXIS
);
68 if (Stem::has_interface (inf
.grob_
))
70 for (int i
=0; i
< texts_
.size (); i
++)
72 Side_position_interface::add_support (texts_
[i
],inf
.grob_
);
78 Text_engraver::process_acknowledged_grobs ()
82 for (int i
=0; i
< evs_
.size (); i
++)
86 // URG: Text vs TextScript
87 Item
*text
= make_item ("TextScript");
91 Side_position_interface::set_axis (text
, ax
);
95 SCM s
= text
->get_property ("script-priority");
97 priority
= gh_scm2int (s
);
99 /* see script-engraver.cc */
102 text
->set_property ("script-priority", gh_int2scm (priority
));
104 Direction dir
= to_dir (r
->get_property ("direction"));
106 set_grob_direction (text
, dir
);
109 SCM mark
= r
->get_property ("text");
111 text
->set_property ("text", mark
);
112 announce_grob (text
, r
->self_scm ());
118 Text_engraver::stop_translation_timestep ()
120 for (int i
=0; i
< texts_
.size (); i
++)
122 Item
*ti
= texts_
[i
];
130 Text_engraver::Text_engraver ()
134 ENTER_DESCRIPTION (Text_engraver
,
135 /* descr */ "Create text-scripts",
136 /* creats*/ "TextScript",
137 /* accepts */ "text-script-event",
138 /* acks */ "rhythmic-head-interface stem-interface",