2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2009 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "international.hh"
12 #include "note-column.hh"
13 #include "pointer-group-interface.hh"
14 #include "side-position-interface.hh"
16 #include "stream-event.hh"
18 #include "translator.icc"
20 class Text_spanner_engraver
: public Engraver
23 TRANSLATOR_DECLARATIONS (Text_spanner_engraver
);
25 virtual void finalize ();
26 DECLARE_TRANSLATOR_LISTENER (text_span
);
27 DECLARE_ACKNOWLEDGER (note_column
);
28 void stop_translation_timestep ();
29 void process_music ();
34 Stream_event
*current_event_
;
35 Drul_array
<Stream_event
*> event_drul_
;
39 Text_spanner_engraver::Text_spanner_engraver ()
44 event_drul_
[START
] = 0;
45 event_drul_
[STOP
] = 0;
48 IMPLEMENT_TRANSLATOR_LISTENER (Text_spanner_engraver
, text_span
);
50 Text_spanner_engraver::listen_text_span (Stream_event
*ev
)
52 Direction d
= to_dir (ev
->get_property ("span-direction"));
53 ASSIGN_EVENT_ONCE (event_drul_
[d
], ev
);
57 Text_spanner_engraver::process_music ()
59 if (event_drul_
[STOP
])
62 event_drul_
[STOP
]->origin ()->warning (_ ("cannot find start of text spanner"));
66 announce_end_grob (finished_
, SCM_EOL
);
72 if (event_drul_
[START
])
75 event_drul_
[START
]->origin ()->warning (_ ("already have a text spanner"));
78 current_event_
= event_drul_
[START
];
79 span_
= make_spanner ("TextSpanner", event_drul_
[START
]->self_scm ());
81 Side_position_interface::set_axis (span_
, Y_AXIS
);
82 event_drul_
[START
] = 0;
88 Text_spanner_engraver::typeset_all ()
92 if (!finished_
->get_bound (RIGHT
))
94 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
95 finished_
->set_bound (RIGHT
, e
);
102 Text_spanner_engraver::stop_translation_timestep ()
104 if (span_
&& !span_
->get_bound (LEFT
))
106 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
107 span_
->set_bound (LEFT
, e
);
111 event_drul_
[START
] = 0;
112 event_drul_
[STOP
] = 0;
116 Text_spanner_engraver::finalize ()
121 current_event_
->origin ()->warning (_ ("unterminated text spanner"));
129 Text_spanner_engraver::acknowledge_note_column (Grob_info info
)
132 Pointer_group_interface::add_grob (span_
,
133 ly_symbol2scm ("note-columns"),
135 add_bound_item (span_
, info
.grob ());
136 } else if (finished_
) {
137 Pointer_group_interface::add_grob (finished_
, ly_symbol2scm ("note-columns"),
139 add_bound_item (finished_
, info
.grob ());
143 ADD_ACKNOWLEDGER (Text_spanner_engraver
, note_column
);
145 ADD_TRANSLATOR (Text_spanner_engraver
,
147 "Create text spanner from an event.",