2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "note-column.hh"
11 #include "side-position-interface.hh"
12 #include "engraver.hh"
14 class Text_spanner_engraver
: public Engraver
17 TRANSLATOR_DECLARATIONS(Text_spanner_engraver
);
19 virtual void finalize ();
20 virtual void acknowledge_grob (Grob_info
);
21 virtual bool try_music (Music
*);
22 virtual void stop_translation_timestep ();
23 virtual void start_translation_timestep ();
24 virtual void process_music ();
30 Drul_array
<Music
*> req_drul_
;
35 Text_spanner_engraver::Text_spanner_engraver ()
45 Text_spanner_engraver::start_translation_timestep ()
52 Text_spanner_engraver::try_music (Music
*m
)
54 if (m
->is_mus_type ("text-span-event"))
57 Direction d
= to_dir (m
->get_mus_property ("span-direction"));
61 else if (m
->is_mus_type ("abort-event"))
74 Text_spanner_engraver::process_music ()
80 req_drul_
[STOP
]->origin ()->warning
81 (_ ("can't find start of text spanner"));
95 req_drul_
[START
]->origin ()->warning(_ ("already have a text spanner"));
99 current_req_
= req_drul_
[START
];
100 span_
= new Spanner (get_property ("TextSpanner"));
103 /* Ugh. Reset (de)cresc. specific properties */
104 span_
->set_grob_property ("enclose-bounds", SCM_BOOL_T
);
105 span_
->set_grob_property ("if-text-padding", gh_double2scm (0));
106 span_
->set_grob_property ("width-correct", gh_double2scm (0));
109 Side_position_interface::set_axis (span_
, Y_AXIS
);
110 announce_grob (span_
, req_drul_
[START
]->self_scm());
111 req_drul_
[START
] = 0;
117 Text_spanner_engraver::acknowledge_grob (Grob_info info
)
119 Spanner
* spans
[2] ={span_
, finished_
};
120 for (int i
= 0; i
< 2 ; i
++)
122 if (spans
[i
] && Note_column::has_interface (info
.grob_
))
124 Side_position_interface::add_support (spans
[i
], info
.grob_
);
125 add_bound_item (spans
[i
], dynamic_cast<Item
*> (info
.grob_
));
131 Text_spanner_engraver::typeset_all ()
135 Side_position_interface::add_staff_support (finished_
);
136 if (!finished_
->get_bound (RIGHT
))
138 Grob
* e
= unsmob_grob (get_property ("currentMusicalColumn"));
139 finished_
->set_bound (RIGHT
, e
);
141 typeset_grob (finished_
);
147 Text_spanner_engraver::stop_translation_timestep ()
149 if (span_
&& !span_
->get_bound (LEFT
))
151 Grob
* e
= unsmob_grob (get_property ("currentMusicalColumn"));
152 span_
->set_bound (LEFT
, e
);
159 Text_spanner_engraver::finalize ()
164 current_req_
->origin ()->warning (_ ("unterminated text spanner"));
170 ENTER_DESCRIPTION(Text_spanner_engraver
,
171 /* descr */ "Create text spanner from a Music.",
172 /* creats*/ "TextSpanner",
173 /* accepts */ "text-span-event",
174 /* acks */ "note-column-interface",