+2004-09-23 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * input/regression/lyric-extender.ly: simplify.
+
+ * lily/lyric-extender.cc (print): use it to determine size of
+ extender. Remove Lyric_extender::is_visible().
+
+ * lily/extender-engraver.cc (acknowledge_grob): store lyric in
+ next property.
+
+ * lily/lyric-engraver.cc: remove get_current_rest().
+
2004-09-23 Jan Nieuwenhuizen <janneke@gnu.org>
* input/regression/lyric-extender.ly: Fix and add test.
LyricExtender does not extend past a rest."}
\paper { raggedright = ##t }
-<<
- \relative c''{
- c8( d e f)
- d1
- r2. f4
- }
- \addlyrics { ah2 __ ha4 __ ah4 }
->>
+\relative c''{
+ d8( e f) r4.
+ f4
+}
+\addlyrics { ah __ ha }
#include "note-head.hh"
#include "warn.hh"
+void completize_extender (Spanner *sp);
+
class Extender_engraver : public Engraver
{
Music *ev_;
extender_->set_bound (LEFT, item);
if (pending_extender_)
- pending_extender_->set_bound (RIGHT, item);
+ {
+ pending_extender_->set_property ("next", item->self_scm ());
+ completize_extender (pending_extender_);
+ pending_extender_ = 0;
+ }
}
}
void
Extender_engraver::stop_translation_timestep ()
{
- if (pending_extender_ && pending_extender_->get_bound (RIGHT))
- pending_extender_ = 0;
-
if (extender_ || pending_extender_)
{
Context *voice = get_voice_to_lyrics (context ());
Grob *h = voice ? get_current_note_head (voice) : 0;
- Grob *r = voice ? get_current_rest (voice) : 0;
if (h)
{
if (extender_)
- Pointer_group_interface::add_grob (extender_,
- ly_symbol2scm ("heads"), h);
+ {
+ Pointer_group_interface::add_grob (extender_,
+ ly_symbol2scm ("heads"), h);
+ }
+
if (pending_extender_)
- Pointer_group_interface::add_grob (pending_extender_,
- ly_symbol2scm ("heads"), h);
+ {
+ Pointer_group_interface::add_grob (pending_extender_,
+ ly_symbol2scm ("heads"), h);
+ }
}
- else if (r && pending_extender_)
- /* Rest: stop right here. */
- pending_extender_->set_bound (RIGHT, r);
-
- if (extender_ && !r)
+
+ if (extender_)
{
pending_extender_ = extender_;
extender_ = 0;
class Lyric_extender
{
public:
- static bool is_visible (Grob*);
static bool has_interface (Grob*);
DECLARE_SCHEME_CALLBACK (print, (SCM ));
};
return 0;
}
-Grob *
-get_current_rest (Context *voice)
-{
- for (SCM s = voice->get_property ("busyGrobs"); ly_c_pair_p (s);
- s = ly_cdr (s))
- {
- Item *g = dynamic_cast<Item*> (unsmob_grob (ly_cdar (s)));
-
- if (g && !g->get_column ()
- && (Rest::has_interface (g)
- || Multi_measure_rest::has_interface (g)))
- return g;
- }
-
- return 0;
-}
-
void
Lyric_engraver::stop_translation_timestep ()
{
#include "note-head.hh"
#include "group-interface.hh"
-bool
-Lyric_extender::is_visible (Grob *gr)
-{
- Spanner *me = dynamic_cast<Spanner*> (gr);
- SCM heads = me->get_property ("heads");
- int il = scm_ilength (heads);
- return il != 0;
-}
MAKE_SCHEME_CALLBACK (Lyric_extender, print, 1)
SCM
{
Spanner *me = unsmob_spanner (smob);
Item *le = me->get_bound (LEFT);
- Item *ri = me->get_bound (RIGHT);
- Grob *common = le->common_refpoint (ri, X_AXIS);
-
+ Item *right_text = unsmob_item (me->get_property ("next"));
+
+ Grob *common = le->common_refpoint (right_text, X_AXIS);
+ common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS);
Real sl = me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
Link_array<Grob> heads (Pointer_group_interface__extract_grobs (me, (Grob*)0,
"heads"));
- if (!heads.size () && ri->break_status_dir () == CENTER)
+ if (!heads.size ())
return SCM_EOL;
common = common_refpoint_of_array (heads, common, X_AXIS);
Real right_point
= left_point + (robust_scm2double (minlen, 0));
- Spanner *orig = dynamic_cast<Spanner*> (me->original_);
- bool last_line = orig
- && (me->get_break_index () == orig->broken_intos_.size () - 2)
- && !Lyric_extender::is_visible (orig->broken_intos_.top ());
-
if (heads.size ())
right_point = right_point >? heads.top ()->extent (common, X_AXIS)[RIGHT];
Real h = sl * robust_scm2double (me->get_property ("thickness"), 0);
Real pad = 2* h;
- if (ri->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
- right_point = right_point <? (ri->extent (common, X_AXIS)[LEFT] - pad);
- else if (Note_head::has_interface (ri))
- ;
- else if (!last_line)
- /* run to end of line. */
- right_point = right_point >? (ri->extent (common, X_AXIS)[LEFT] - pad);
-
- if (isinf (right_point))
- {
- programming_error ("Right point of extender not defined?");
- right_point = ri->relative_coordinate (common, X_AXIS);
- }
+ if (right_text)
+ right_point = right_point <? (robust_relative_extent (right_text, common, X_AXIS)[LEFT] - pad);
+ /* run to end of line. */
+ right_point = right_point >? (me->get_bound (RIGHT)->extent (common, X_AXIS)[LEFT] - pad);
+
left_point += pad;
Real w = right_point - left_point;
ADD_INTERFACE (Lyric_extender,"lyric-extender-interface",
- "The extender is a simple line at the baseline of the lyric "
- " that helps show the length of a melissima (tied/slurred note).",
- "thickness heads");
+ "The extender is a simple line at the baseline of the lyric "
+ "that helps show the length of a melissima (tied/slurred note).",
+ "next thickness heads");
return internal_print (me).smobbed_copy ();
}
-/*
- Compute the width the head without ledgers.
-
- -- there used to be some code from the time that ledgers
- did take space. Nowadays, we can simply take the standard extent.
- */
-Interval
-Note_head::head_extent (Grob *me, Axis a)
-{
- SCM brewer = me->get_property ("print-function");
- if (brewer == Note_head::print_proc)
- {
- Stencil mol = internal_print (me);
-
- if (!mol.is_empty ())
- return mol.extent (a);
- }
- else
- {
- Stencil * mol = me->get_stencil ();
- if (mol)
- return mol->extent (a) ;
- }
-
- return Interval (0,0);
-}
MAKE_SCHEME_CALLBACK (Note_head,brew_ez_stencil,1);
SCM
Real thick = thickness (me);
Grob *hed = support_head (me);
- Real w = Note_head::head_extent (hed, X_AXIS)[dir];
+ Real w = hed->extent (hed, X_AXIS)[dir];
for (int i = 0; i < heads.size (); i++)
- heads[i]->translate_axis (w - Note_head::head_extent (heads[i],
- X_AXIS)[dir],
+ heads[i]->translate_axis (w - heads[i]->extent (heads[i], X_AXIS)[dir],
X_AXIS);
bool parity = true;
{
if (parity)
{
- Real ell = Note_head::head_extent (heads[i], X_AXIS).length ();
+ Real ell = heads[i]->extent (heads[i], X_AXIS).length ();
Direction d = get_direction (me);
/*
/*
must not take ledgers into account.
*/
- Interval head_height = Note_head::head_extent (hed,Y_AXIS);
+ Interval head_height = hed->extent (hed,Y_AXIS);
Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS);
y_attach = head_height.linear_combination (y_attach);
if (head_count (me))
if (Grob *f = first_head (me))
{
- Interval head_wid = Note_head::head_extent (f, X_AXIS);
+ Interval head_wid = f->extent (f, X_AXIS);
Real attach = 0.0;
if (is_invisible (me))
(new-accidentals ,list? "List of @code{(@var{pitch}
. @var{accidental})} pairs.")
+ (next ,ly:grob? "Object that is next relation (eg. the lyric syllable following an extender.")
(note-names ,vector? "Vector of strings containing names for
easy-notation note heads.")
(no-ledgers ,boolean? "If set, don't draw ledger lines on this object.")