#include "multi-measure-rest.hh"
#include "paper-column.hh"
#include "engraver-group-engraver.hh"
-#include "bar.hh"
+
#include "staff-symbol-referencer.hh"
#include "engraver.hh"
#include "moment.hh"
/**
The name says it all: make multi measure rests
-FIXME? The MM rest engraver must be able to see bar lines, so it won't
-work at Voice level. Not a problem in practice, but aesthetically pleasing?
-
*/
class Multi_measure_rest_engraver : public Engraver
{
public:
- VIRTUAL_COPY_CONS(Translator);
- Multi_measure_rest_engraver ();
+ TRANSLATOR_DECLARATIONS(Multi_measure_rest_engraver);
protected:
- virtual void acknowledge_grob (Grob_info i);
virtual bool try_music (Music*);
virtual void process_music ();
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void finalize ();
- virtual void create_grobs ();
private:
Span_req * new_req_l_;
Spanner *lastrest_p_;
};
-ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver);
+
Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
{
new_req_l_ = busy_span_req_l_ = stop_req_l_ =0;
}
-void
-Multi_measure_rest_engraver::acknowledge_grob (Grob_info i)
-{
- Item * item = dynamic_cast<Item*> (i.elem_l_);
- if (item && Bar::has_interface (item))
- {
- if (mmrest_p_)
- Multi_measure_rest::add_column (mmrest_p_,item);
- if (lastrest_p_)
- Multi_measure_rest::add_column (lastrest_p_,item);
- }
-}
bool
Multi_measure_rest_engraver::try_music (Music* req_l)
if (scm_equal_p (sp->get_mus_property ("span-type"),
ly_str02scm ("rest")) == SCM_BOOL_T)
{
- if (sp->get_span_dir() == STOP)
+ if (sp->get_span_dir () == STOP)
{
stop_req_l_ = sp;
}
- else if (sp->get_span_dir() == START && !new_req_l_)
+ else if (sp->get_span_dir () == START && !new_req_l_)
{
new_req_l_ = sp;
}
void
Multi_measure_rest_engraver::process_music ()
{
- if (new_req_l_ && stop_req_l_)
+ if (new_req_l_ && stop_req_l_)
stop_req_l_ = 0;
if (new_req_l_)
new_req_l_ =0;
}
-}
-
-void
-Multi_measure_rest_engraver::create_grobs ()
-{
-
if (busy_span_req_l_ && !mmrest_p_)
{
mmrest_p_ = new Spanner (get_property ("MultiMeasureRest"));
start_measure_i_
= gh_scm2int (get_property ("currentBarNumber"));
}
+
+ if (gh_string_p (get_property ("whichBar")))
+ {
+ Grob *cmc = unsmob_grob (get_property( "currentCommandColumn"));
+ Item *it = dynamic_cast<Item*> (cmc);
+ if (mmrest_p_)
+ add_bound_item (mmrest_p_, it);
+ if (lastrest_p_)
+ add_bound_item (lastrest_p_,it);
+ }
}
void
Multi_measure_rest_engraver::stop_translation_timestep ()
{
SCM smp = get_property ("measurePosition");
- Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
+ Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
if (mmrest_p_ && (now_mom () >= start_moment_)
- && !mp
- && (scm_ilength (mmrest_p_->get_grob_property ("columns")) >= 2))
+ && !mp.to_bool ()
+ && mmrest_p_->get_bound (LEFT) && mmrest_p_->get_bound (RIGHT))
{
typeset_grob (mmrest_p_);
/*
- we must keep mmrest_p_ around to set measure-count.
+ we must keep mmrest_p_ around to set measure-count, so
+ no mmrest_p_ = 0 here.
*/
}
+
if (lastrest_p_)
{
- typeset_grob (lastrest_p_);
+ /* sanity check */
+ if (lastrest_p_->get_bound (LEFT) && lastrest_p_->get_bound (RIGHT)
+ && lastrest_p_->get_bound (LEFT) != lastrest_p_->get_bound (RIGHT))
+ typeset_grob (lastrest_p_);
lastrest_p_ = 0;
}
Multi_measure_rest_engraver::start_translation_timestep ()
{
SCM smp = get_property ("measurePosition");
- Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
+ Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
- if (mmrest_p_ && !mp)
+ if (mmrest_p_ && !mp.to_bool ())
{
lastrest_p_ = mmrest_p_;
int cur = gh_scm2int (get_property ("currentBarNumber"));
if (lastrest_p_)
typeset_grob (lastrest_p_);
}
+
+ENTER_DESCRIPTION(Multi_measure_rest_engraver,
+/* descr */ "Engraves multi-measure rests that are produced with @code{R}. Reads
+measurePosition and currentBarNumber to determine what number to print over the MultiMeasureRest
+",
+/* creats*/ "MultiMeasureRest",
+/* acks */ "",
+/* reads */ "currentBarNumber currentCommandColumn measurePosition",
+/* write */ "");