Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(73)

Unified Diff: lily/extender-engraver.cc

Issue 313240043: Automatic LyricExtenders
Patch Set: Version 2017-02-04 by Knut Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lily/extender-engraver.cc
diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc
index f1940083b95a350722cab732eec36a84d1127f3e..1cbad29de4cf092aefb8ac09519bf7e2f159fb03 100644
--- a/lily/extender-engraver.cc
+++ b/lily/extender-engraver.cc
@@ -30,12 +30,15 @@
#include "warn.hh"
#include "spanner.hh"
#include "translator.icc"
+#include "iostream"
dak 2017/02/06 19:08:17 Why?
void completize_extender (Spanner *sp);
class Extender_engraver : public Engraver
{
- Stream_event *ev_;
+ Stream_event *syllable_;
+ Stream_event *ex_;
+ Stream_event *hy_;
Spanner *extender_;
Spanner *pending_extender_;
@@ -43,7 +46,9 @@ public:
TRANSLATOR_DECLARATIONS (Extender_engraver);
protected:
+ void listen_lyric (Stream_event *);
void listen_extender (Stream_event *);
+ void listen_hyphen (Stream_event *);
void listen_completize_extender (Stream_event *);
void acknowledge_lyric_syllable (Grob_info);
@@ -56,15 +61,30 @@ protected:
Extender_engraver::Extender_engraver (Context *c)
: Engraver (c)
{
+ syllable_ = 0;
extender_ = 0;
pending_extender_ = 0;
- ev_ = 0;
+ ex_ = 0;
+ hy_ = 0;
+}
+
+void
+Extender_engraver::listen_lyric (Stream_event *ev)
+{
+ if (robust_scm2string (ev->get_property ("text"), "") != " ")
+ syllable_ = ev;
}
void
Extender_engraver::listen_extender (Stream_event *ev)
{
- ASSIGN_EVENT_ONCE (ev_, ev);
+ ASSIGN_EVENT_ONCE (ex_, ev);
+}
+
+void
+Extender_engraver::listen_hyphen (Stream_event *ev)
+{
+ ASSIGN_EVENT_ONCE (hy_, ev);
dak 2017/02/06 19:08:17 If we are not the primary engraver for an item, we
}
/*
@@ -86,8 +106,13 @@ Extender_engraver::listen_completize_extender (Stream_event * /* ev */)
void
Extender_engraver::process_music ()
{
- if (ev_)
- extender_ = make_spanner ("LyricExtender", ev_->self_scm ());
+ if (ex_ && !hy_)
dak 2017/02/06 19:08:17 Why check for hy_ here? If there is an explicit e
+ {
+ extender_ = make_spanner ("LyricExtender", ex_->self_scm ());
+ extender_->set_property ("force-extender", SCM_BOOL_T);
dak 2017/02/06 19:08:17 I think it might make more sense to have, if at al
+ }
+ else if (syllable_ && !hy_)
+ extender_ = make_spanner ("LyricExtender", syllable_->self_scm ());
}
void
@@ -143,7 +168,9 @@ Extender_engraver::stop_translation_timestep ()
}
}
- ev_ = 0;
+ ex_ = 0;
+ hy_ = 0;
+ syllable_ = 0;
}
void
@@ -163,18 +190,12 @@ Extender_engraver::finalize ()
if (extender_)
{
completize_extender (extender_);
-
- if (!extender_->get_bound (RIGHT))
- extender_->warning (_ ("unterminated extender"));
extender_ = 0;
}
if (pending_extender_)
{
completize_extender (pending_extender_);
-
- if (!pending_extender_->get_bound (RIGHT))
- pending_extender_->warning (_ ("unterminated extender"));
pending_extender_ = 0;
}
}
@@ -182,7 +203,9 @@ Extender_engraver::finalize ()
void
Extender_engraver::boot ()
{
+ ADD_LISTENER (Extender_engraver, lyric);
ADD_LISTENER (Extender_engraver, extender);
+ ADD_LISTENER (Extender_engraver, hyphen);
ADD_LISTENER (Extender_engraver, completize_extender);
ADD_ACKNOWLEDGER (Extender_engraver, lyric_syllable);
}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b