(c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include <iostream.h>
-#include "score-engraver.hh"
-#include "timing-engraver.hh"
+#include "translator-group.hh"
#include "command-request.hh"
-#include "score-element-info.hh"
+#include "grob-info.hh"
#include "multi-measure-rest.hh"
+#include "timing-translator.hh"
+#include "engraver.hh"
+
+/**
+ Do time bookkeeping
+ */
+class Timing_engraver : public Timing_translator, public Engraver
+{
+protected:
+ virtual void start_translation_timestep ();
+ virtual void stop_translation_timestep ();
+ virtual void process_music ();
+public:
+ VIRTUAL_COPY_CONS(Translator);
+};
ADD_THIS_TRANSLATOR(Timing_engraver);
void
-Timing_engraver::do_post_move_processing( )
+Timing_engraver::start_translation_timestep( )
{
- bar_req_l_ = 0;
- Timing_translator::do_post_move_processing ();
-
-}
+ Timing_translator::start_translation_timestep ();
-bool
-Timing_engraver::do_try_music (Music*m)
-{
- if (Bar_req * b= dynamic_cast <Bar_req *> (m))
+ SCM nonauto = get_property ("barNonAuto");
+
+ SCM which = get_property ("whichBar");
+ if (!gh_string_p (which))
+ which = now_mom ()
+ ? SCM_EOL : ly_str02scm ("|");
+
+ if (!gh_string_p (which) && !to_boolean (nonauto))
{
- if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
- return false;
-
- bar_req_l_ = b;
- return true;
+ SCM always = get_property ("barAlways");
+ if (!measure_position ()
+ || (to_boolean (always)))
+ {
+ which=get_property ("defaultBarType" );
+ }
}
-
- return Timing_translator::do_try_music (m);
+
+ daddy_trans_l_->set_property ("whichBar", which);
}
-#if 0
-String
-Timing_engraver::do_process_music ()
+void
+Timing_engraver::stop_translation_timestep ()
{
- if (gh_string_p (get_property ("barType")))
- ;
- else if (!now_mom ())
- {
- daddy_trans_l_->set_property ("barType", ly_str02scm ("|"));
- }
- else
-
- {
- }
+ Timing_translator::stop_translation_timestep ();
+ daddy_trans_l_->set_property ("whichBar", SCM_EOL);
}
-#endif
/*
- TODO make properties of this.
+ ugh. Translator doesn't do process_music ().
*/
-String
-Timing_engraver::which_bar ()
+void
+Timing_engraver::process_music ()
{
- if (!bar_req_l_)
- {
- if (!now_mom ())
- return "|";
-
- SCM nonauto = get_property ("barNonAuto");
- if (!to_boolean (nonauto))
- {
- SCM always = get_property ("barAlways");
- if (!measure_position ()
- || (to_boolean (always)))
- {
- SCM def=get_property ("defaultBarType" );
- return (gh_string_p (def))? ly_scm2string (def) : "";
- }
- }
- return "";
- }
- else
- {
- return bar_req_l_->type_str_;
- }
+ Timing_translator::process_music ();
}