source file of the GNU LilyPond music typesetter
- (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "all-font-metrics.hh"
#include "score-engraver.hh"
#include "paper-score.hh"
#include "paper-column.hh"
-#include "command-request.hh"
#include "paper-def.hh"
#include "axis-group-interface.hh"
-#include "translator-def.hh"
-
+#include "context-def.hh"
#include "staff-spacing.hh"
#include "note-spacing.hh"
+#include "context.hh"
+#include "global-context.hh"
+
+
+
/*
TODO: the column creation logic is rather hairy. Revise it.
*/
if (!command_column_)
{
- set_columns (new Paper_column (get_property ("NonMusicalPaperColumn")),
- new Paper_column (get_property ("PaperColumn")));
-
- command_column_->set_grob_property ("breakable", SCM_BOOL_T);
-
+ SCM nmp
+ = updated_grob_properties (daddy_context_,
+ ly_symbol2scm ("NonMusicalPaperColumn"));
+ SCM pc = updated_grob_properties (daddy_context_,
+ ly_symbol2scm ("PaperColumn"));
+
+ set_columns (new Paper_column (nmp), new Paper_column (pc));
- Grob_info i1 (command_column_);
+ Grob_info i1;
+ i1.grob_ = command_column_;
i1.origin_trans_ = this;
- Grob_info i2 (musical_column_);
+ announce_grob (i1);
+
+ Grob_info i2;
+ i2.grob_ = musical_column_;
i2.origin_trans_ = this;
- announce_grob (i1);
announce_grob (i2);
}
}
void
-Score_engraver::prepare (Moment w)
+Score_engraver::prepare (Moment m)
{
- Global_translator::prepare (w);
-
/*
TODO: don't make columns when skipTypesetting is true.
*/
make_columns ();
-
- command_column_->set_grob_property ("when", now_mom_.smobbed_copy ());
- musical_column_->set_grob_property ("when", now_mom_.smobbed_copy ());
+ SCM w = m.smobbed_copy ();
+ command_column_->set_property ("when", w);
+ musical_column_->set_property ("when", w);
- Translator_group::start_translation_timestep();
+ recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, DOWN);
}
void
{
if ((breaks_%8))
progress_indication ("[" + to_string (breaks_) + "]");
-
- check_removal ();
- removal_processing ();
+ recurse_down_translators (daddy_context_, &Translator::finalize, UP);
}
/*
error (_f ("can't find `%s'", "feta20.afm")
+ "\n" +_ ("Fonts have not been installed properly. Aborting"));
- unsmob_translator_def (definition_)->apply_property_operations (this);
- assert (dynamic_cast<Paper_def *> (output_def_));
- assert (!daddy_trans_);
pscore_ = new Paper_score;
- pscore_->paper_ = dynamic_cast<Paper_def*> (output_def_);
+ pscore_->paper_ = dynamic_cast<Paper_def*> (get_output_def ());
- SCM props = get_property ("System");
+ SCM props = updated_grob_properties (daddy_context_, ly_symbol2scm ("System"));
pscore_->typeset_line (new System (props));
make_columns ();
system_ = pscore_->system_;
system_->set_bound (LEFT, command_column_);
- command_column_->set_grob_property ("breakable", SCM_BOOL_T);
+ command_column_->set_property ("breakable", SCM_BOOL_T);
Engraver_group_engraver::initialize ();
}
void
Score_engraver::finalize ()
{
- Engraver_group_engraver::finalize ();
+ Score_translator::finalize ();
Grob * cc
= unsmob_grob (get_property ("currentCommandColumn"));
system_->set_bound (RIGHT, cc);
- cc->set_grob_property ("breakable", SCM_BOOL_T);
+ cc->set_property ("breakable", SCM_BOOL_T);
typeset_all ();
}
+
void
Score_engraver::one_time_step ()
{
if (!to_boolean (get_property ("skipTypesetting")))
{
- process_music ();
- do_announces ();
+ recurse_down_translators (daddy_context_, &Engraver::process_music, UP);
+ recurse_down_translators (daddy_context_, &Engraver::do_announces, UP);
}
- stop_translation_timestep ();
-
- apply_finalizations ();
- check_removal ();
-
-
- for (int i = announce_infos_.size(); i--;)
- {
- Grob *g = announce_infos_[i].grob_;
- if (!dynamic_cast<Paper_column*> (g)) // ugh.
- {
-
- String msg= "Grob "
- + g->name()
- + " was created too late!";
- g->programming_error (msg);
- }
- }
- announce_infos_.clear ();
+ recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, UP);
}
void
{
if (!elem->get_parent (X_AXIS))
{
- bool br = to_boolean (elem->get_grob_property ("breakable"));
+ bool br = to_boolean (elem->get_property ("breakable"));
Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem);
}
Engraver_group_engraver::stop_translation_timestep ();
typeset_all ();
- if (to_boolean (command_column_->get_grob_property ("breakable")))
+ if (to_boolean (command_column_->get_property ("breakable")))
{
breaks_ ++;
if (! (breaks_%8))
musical_column_ = new_musical;
if (new_command)
{
- set_property ("currentCommandColumn", new_command->self_scm ());
+ daddy_context_->set_property ("currentCommandColumn", new_command->self_scm ());
}
if (new_musical)
{
- set_property ("currentMusicalColumn", new_musical->self_scm ());
+ daddy_context_->set_property ("currentMusicalColumn", new_musical->self_scm ());
}
}
return o;
}
+
bool
Score_engraver::try_music (Music*r)
{
bool gotcha = Engraver_group_engraver::try_music (r);
- if (!gotcha)
+ if (!gotcha && r->is_mus_type ("break-event"))
{
- if (Break_req* b = dynamic_cast<Break_req *> (r))
- {
- gotcha = true;
+ gotcha = true;
+ SCM pen = command_column_->get_property ("penalty");
+ Real total_penalty = gh_number_p (pen)
+ ? gh_scm2double (pen)
+ : 0.0;
- SCM pen = command_column_->get_grob_property ("penalty");
- Real total_penalty = gh_number_p (pen)
- ? gh_scm2double (pen)
- : 0.0;
-
- SCM rpen = b->get_mus_property ("penalty");
- if (gh_number_p (rpen))
- total_penalty += gh_scm2double (rpen);
+ SCM rpen = r->get_property ("penalty");
+ if (gh_number_p (rpen))
+ total_penalty += gh_scm2double (rpen);
- if (total_penalty > 10000.0) // ugh. arbitrary.
- forbid_breaks ();
+ if (total_penalty > 10000.0) // ugh. arbitrary.
+ forbid_breaks ();
- command_column_->set_grob_property ("penalty",
- gh_double2scm (total_penalty));
- }
+ command_column_->set_property ("penalty",
+ gh_double2scm (total_penalty));
}
- return gotcha;
+ return gotcha;
}
-/*
- TODO: use property Score.breakForbidden = #t
- */
void
Score_engraver::forbid_breaks ()
{
- /*
- result is junked.
- */
if (command_column_)
- command_column_->set_grob_property ("breakable", SCM_EOL);
+ command_column_->set_property ("breakable", SCM_EOL);
}
void
ENTER_DESCRIPTION(Score_engraver,
-/* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System)
-
-
-This engraver decides whether a column is breakable. The default is
-that a column is always breakable. However, when every Bar_engraver
-that does not have a barline at a certain point will call
-Score_engraver::forbid_breaks to stop linebreaks. In practice, this
-means that you can make a breakpoint by creating a barline (assuming
-that there are no beams or notes that prevent a breakpoint.)
-
-
-",
-/* creats*/ "System PaperColumn NonMusicalPaperColumn",
+/* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
+"\n\n "
+"This engraver decides whether a column is breakable. The default is "
+"that a column is always breakable. However, when every Bar_engraver "
+"that does not have a barline at a certain point will call "
+"Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
+"means that you can make a breakpoint by creating a barline (assuming "
+"that there are no beams or notes that prevent a breakpoint.) "
+,
+/* creats*/ "System PaperColumn NonMusicalPaperColumn",
+/* accepts */ "break-event",
/* acks */ "note-spacing-interface staff-spacing-interface",
/* reads */ "currentMusicalColumn currentCommandColumn",
/* write */ "");