2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "dimensions.hh"
10 #include "musical-request.hh"
11 #include "paper-column.hh"
12 #include "note-column.hh"
14 #include "side-position-interface.hh"
15 #include "engraver.hh"
16 #include "group-interface.hh"
17 #include "directional-element-interface.hh"
18 #include "translator-group.hh"
19 #include "axis-group-interface.hh"
22 class Text_spanner_engraver
: public Engraver
25 VIRTUAL_COPY_CONS (Translator
);
26 Text_spanner_engraver ();
29 virtual void finalize ();
30 virtual void acknowledge_grob (Grob_info
);
31 virtual bool try_music (Music
*);
32 virtual void stop_translation_timestep ();
33 virtual void start_translation_timestep ();
34 virtual void create_grobs ();
39 Span_req
*current_req_
;
40 Drul_array
<Span_req
*> req_drul_
;
44 ADD_THIS_TRANSLATOR (Text_spanner_engraver
);
47 Text_spanner_engraver::Text_spanner_engraver ()
57 Text_spanner_engraver::start_translation_timestep ()
64 Text_spanner_engraver::try_music (Music
*m
)
66 if (Span_req
*s
= dynamic_cast <Span_req
*> (m
))
68 String t
= ly_scm2string (s
->get_mus_property ("span-type"));
79 req_drul_
[s
->get_span_dir()] = s
;
87 Text_spanner_engraver::create_grobs ()
93 req_drul_
[STOP
]->origin ()->warning
94 (_ ("can't find start of text spanner"));
99 Grob
* e
= unsmob_grob (get_property ("currentMusicalColumn"));
100 span_
->set_bound (RIGHT
, e
);
109 if (req_drul_
[START
])
113 req_drul_
[START
]->origin ()->warning
114 (_ ("already have a text spanner"));
118 current_req_
= req_drul_
[START
];
119 span_
= new Spanner (get_property ("TextSpanner"));
121 /* Ugh. Reset (de)cresc. specific properties */
122 span_
->set_grob_property ("outer", SCM_BOOL_T
);
123 span_
->set_grob_property ("if-text-padding", gh_double2scm (0));
124 span_
->set_grob_property ("width-correct", gh_double2scm (0));
126 Side_position::set_axis (span_
, Y_AXIS
);
127 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
128 span_
->set_bound (LEFT
, e
);
130 announce_grob (span_
, req_drul_
[START
]);
131 req_drul_
[START
] = 0;
137 Text_spanner_engraver::acknowledge_grob (Grob_info info
)
139 if (span_
&& Note_column::has_interface (info
.elem_l_
))
141 Side_position::add_support (span_
, info
.elem_l_
);
142 add_bound_item (span_
, dynamic_cast<Item
*> (info
.elem_l_
));
147 Text_spanner_engraver::typeset_all ()
151 Side_position::add_staff_support (finished_
);
152 typeset_grob (finished_
);
158 Text_spanner_engraver::stop_translation_timestep ()
164 Text_spanner_engraver::finalize ()
169 current_req_
->origin ()->warning (_ ("unterminated text spanner"));