/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 2000--2011 Jan Nieuwenhuizen <janneke@gnu.org>
+ Copyright (C) 2000--2014 Jan Nieuwenhuizen <janneke@gnu.org>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
private:
vector<Spanner *> lines_;
- bool start_glissandi;
- bool stop_glissandi;
+ vector<Spanner *> kill_me_;
+ bool start_glissandi_;
+ bool stop_glissandi_;
Stream_event *event_;
- SCM map;
vector<vsize> note_column_1;
vector<vsize> note_column_2;
};
Glissando_engraver::Glissando_engraver ()
{
event_ = 0;
- map = SCM_EOL;
- start_glissandi = false;
- stop_glissandi = false;
+ start_glissandi_ = false;
+ stop_glissandi_ = false;
}
IMPLEMENT_TRANSLATOR_LISTENER (Glissando_engraver, glissando);
Glissando_engraver::process_music ()
{
if (event_)
- start_glissandi = true;
+ start_glissandi_ = true;
}
void
Glissando_engraver::acknowledge_note_column (Grob_info info)
{
Grob *g = info.grob ();
- if (start_glissandi)
+ if (to_boolean (g->get_property ("glissando-skip")))
+ return;
+
+ if (stop_glissandi_)
+ {
+ extract_grob_set (g, "note-heads", note_heads);
+ int glissando_index = 0;
+ for (vsize i = 0; i < note_column_1.size (); i++)
+ {
+ if (note_column_2[i] >= note_heads.size ())
+ {
+ kill_me_.push_back (lines_[i]);
+ announce_end_grob (lines_[i], SCM_EOL);
+ }
+ else
+ {
+ lines_[i]->set_bound (RIGHT, note_heads[note_column_2[i]]);
+ lines_[i]->set_property ("glissando-index", scm_from_int (glissando_index));
+ glissando_index++;
+ announce_end_grob (lines_[i], note_heads[note_column_2[i]]->self_scm ());
+ }
+ }
+ lines_.clear ();
+ note_column_1.clear ();
+ note_column_2.clear ();
+ stop_glissandi_ = false;
+ }
+
+ if (start_glissandi_)
{
extract_grob_set (g, "note-heads", note_heads);
- map = get_property ("glissandoMap");
+ SCM map = get_property ("glissandoMap");
if (map == SCM_EOL)
for (vsize i = 0; i < note_heads.size (); i++)
{
continue;
int n1 = robust_scm2int (scm_car (candidate), -1);
int n2 = robust_scm2int (scm_cdr (candidate), -1);
- if (n1 < 0 || n2 < 0 || n1 >= note_heads.size ())
+ if ((n1 < 0) || (n2 < 0) || (size_t (n1) >= note_heads.size ()))
continue;
note_column_1.push_back (vsize (n1));
note_column_2.push_back (vsize (n2));
}
- for (vsize i=0; i < note_column_1.size (); i++)
+ for (vsize i = 0; i < note_column_1.size (); i++)
{
lines_.push_back (make_spanner ("Glissando", event_->self_scm ()));
lines_.back ()->set_bound (LEFT, note_heads[note_column_1[i]]);
}
}
-
- if (stop_glissandi)
- {
- extract_grob_set (g, "note-heads", note_heads);
- int glissando_index = 0;
- for (vsize i=0; i < note_column_1.size (); i++)
- {
- if (note_column_2[i] >= note_heads.size ())
- lines_[i]->suicide ();
- else
- {
- lines_[i]->set_bound (RIGHT, note_heads[note_column_2[i]]);
- lines_[i]->set_property ("glissando-index", scm_from_int (glissando_index));
- glissando_index++;
- announce_end_grob (lines_[i], note_heads[note_column_2[i]]->self_scm ());
- }
- }
- lines_.clear ();
- note_column_1.clear ();
- note_column_2.clear ();
- stop_glissandi = false;
- }
}
void
Glissando_engraver::stop_translation_timestep ()
{
-
- if (start_glissandi)
+ if (start_glissandi_)
{
- if (stop_glissandi)
- programming_error ("overwriting glissando");
- stop_glissandi = true;
+ if (stop_glissandi_)
+ programming_error ("overwriting glissando");
+ stop_glissandi_ = true;
+ start_glissandi_ = false;
}
-
- start_glissandi = false;
event_ = 0;
}
string msg = _ ("unterminated glissando");
if (event_)
- event_->origin ()->warning (msg);
+ event_->origin ()->warning (msg);
else
- warning (msg);
+ warning (msg);
- for (vsize i=0; i < lines_.size (); i++)
+ for (vsize i = 0; i < lines_.size (); i++)
lines_[i]->suicide ();
}
+
+ for (vsize i = 0; i < kill_me_.size (); i++)
+ kill_me_[i]->suicide ();
}
ADD_ACKNOWLEDGER (Glissando_engraver, note_column);
ADD_TRANSLATOR (Glissando_engraver,
- /* doc */
- "Engrave glissandi.",
+ /* doc */
+ "Engrave glissandi.",
- /* create */
- "Glissando ",
+ /* create */
+ "Glissando ",
- /* read */
- "glissandoMap ",
+ /* read */
+ "glissandoMap ",
- /* write */
- ""
- );
+ /* write */
+ ""
+ );