2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 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 process_music ();
29 Drul_array
<Music
*> req_drul_
;
34 Text_spanner_engraver::Text_spanner_engraver ()
44 Text_spanner_engraver::try_music (Music
*m
)
46 if (m
->is_mus_type ("text-span-event"))
49 Direction d
= to_dir (m
->get_property ("span-direction"));
58 Text_spanner_engraver::process_music ()
64 req_drul_
[STOP
]->origin ()->warning
65 (_ ("can't find start of text spanner"));
79 req_drul_
[START
]->origin ()->warning (_ ("already have a text spanner"));
83 current_req_
= req_drul_
[START
];
84 span_
= make_spanner ("TextSpanner", req_drul_
[START
]->self_scm ());
87 Side_position_interface::set_axis (span_
, Y_AXIS
);
94 Text_spanner_engraver::acknowledge_grob (Grob_info info
)
96 Spanner
* spans
[2] ={span_
, finished_
};
97 for (int i
= 0; i
< 2 ; i
++)
99 if (spans
[i
] && Note_column::has_interface (info
.grob_
))
101 Side_position_interface::add_support (spans
[i
], info
.grob_
);
102 add_bound_item (spans
[i
], dynamic_cast<Item
*> (info
.grob_
));
108 Text_spanner_engraver::typeset_all ()
112 if (!finished_
->get_bound (RIGHT
))
114 Grob
* e
= unsmob_grob (get_property ("currentMusicalColumn"));
115 finished_
->set_bound (RIGHT
, e
);
122 Text_spanner_engraver::stop_translation_timestep ()
124 if (span_
&& !span_
->get_bound (LEFT
))
126 Grob
* e
= unsmob_grob (get_property ("currentMusicalColumn"));
127 span_
->set_bound (LEFT
, e
);
131 req_drul_
[START
] = 0;
136 Text_spanner_engraver::finalize ()
141 current_req_
->origin ()->warning (_ ("unterminated text spanner"));
147 ENTER_DESCRIPTION (Text_spanner_engraver
,
148 /* descr */ "Create text spanner from a Music.",
149 /* creats*/ "TextSpanner",
150 /* accepts */ "text-span-event",
151 /* acks */ "note-column-interface",