#include "duration.hh"
#include "moment.hh"
+#include "translator.icc"
+
class Forbid_line_break_engraver : public Engraver
{
public:
PRECOMPUTED_VIRTUAL void start_translation_timestep ();
};
-Forbid_line_break_engraver::Forbid_line_break_engraver (){}
+Forbid_line_break_engraver::Forbid_line_break_engraver ()
+{
+}
void
Forbid_line_break_engraver::start_translation_timestep ()
while (scm_is_pair (busy))
{
Grob *g = unsmob_grob (scm_cdar (busy));
- if (Rhythmic_head::has_interface (g))
+ if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
{
get_score_engraver ()->forbid_breaks ();
}
}
}
-#include "translator.icc"
ADD_TRANSLATOR (Forbid_line_break_engraver,
/* descr */ "Forbid line breaks when note heads are still playing at some point.",
#include "grob.hh"
#include "warn.hh"
+struct Grob_pq_entry
+{
+ Grob *grob_;
+ Moment end_;
+ static int compare (Grob_pq_entry const &a,
+ Grob_pq_entry const &b)
+ {
+ return Moment::compare (a.end_, b.end_);
+ }
+};
+
class Grob_pq_engraver : public Engraver
{
public:
virtual void acknowledge_grob (Grob_info);
PRECOMPUTED_VIRTUAL void start_translation_timestep ();
PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+
+ Array<Grob_pq_entry> started_now_;
};
Grob_pq_engraver::Grob_pq_engraver ()
}
Moment end = n + l;
- SCM lst = scm_acons (end.smobbed_copy (),
- gi.grob ()->self_scm (),
- SCM_EOL);
- SCM busy = get_property ("busyGrobs");
- busy = scm_merge_x (lst, busy, ly_grob_pq_less_p_proc);
- context ()->set_property ("busyGrobs", busy);
+ Grob_pq_entry e;
+ e.grob_ = gi.grob ();
+ e.end_ = end;
+
+ started_now_.push (e);
}
}
busy = scm_cdr (busy);
}
- if (start_busy != busy)
- context ()->set_property ("busyGrobs", busy);
+ started_now_.sort (Grob_pq_entry::compare);
+ SCM lst = SCM_EOL;
+ SCM *tail = &lst;
+ for (int i = 0; i < started_now_.size (); i++)
+ {
+ *tail = scm_acons (started_now_[i].end_.smobbed_copy (),
+ started_now_[i].grob_->self_scm (),
+ SCM_EOL);
+ tail = SCM_CDRLOC(*tail);
+ }
+
+ busy = scm_merge_x (lst, busy, ly_grob_pq_less_p_proc);
+ context ()->set_property ("busyGrobs", busy);
+
+ started_now_.clear ();
}
void
ADD_TRANSLATOR (Grob_pq_engraver,
- /* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \
-engraver is a sort-of a failure, since it doesn't handle all sorts of \
-borderline cases very well. \
-",
-
- /* creats*/ "",\
- /* accepts */ "",\
- /* acks */ "grob-interface",\
- /* reads */ "busyGrobs",\
+ /* descr */ "Administrate when certain grobs (eg. note heads) stop playing",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "busyGrobs",
/* write */ "busyGrobs");