#include "key.hh"
-#include "stcol.hh"
#include "staff.hh"
#include "staffwalker.hh"
--- /dev/null
+/*
+ registergroup.hh -- declare
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef REGISTERGROUP_HH
+#define REGISTERGROUP_HH
+
+
+#include "plist.hh"
+#include "staffeleminfo.hh"
+/**
+ Group a number of registers. Usually delegates everything to its contents.
+ */
+class Register_group {
+public:
+ IPointerList<Request_register*> reg_list_;
+
+ void set_dir(int i);
+ bool acceptable_request_b(Request*);
+ void pre_move_processing();
+ void post_move_processing();
+ void acknowledge_element(Staff_elem_info info);
+ bool try_request(Request*);
+ void process_requests();
+ virtual ~Register_group();
+ void add(Request_register* reg_p);
+ bool contains_b(Request_register*);
+// bool contains_b(Register_group*);
+};
+
+#endif // REGISTERGROUP_HH
+
+
--- /dev/null
+/*
+ sccol.hh -- part of LilyPond
+
+ (c) 1996,97 Han-Wen Nienhuys
+*/
+
+#ifndef SCCOL_HH
+#define SCCOL_HH
+#include "proto.hh"
+#include "varray.hh"
+#include "moment.hh"
+
+
+/**
+
+ When typesetting hasn't started on PScore yet, the columns which
+ contain data have a rhythmical position. Score_column is the type
+ with a rhythmical time attached to it. The calculation of
+ idealspacing is done with data in these columns. (notably: the
+ #durations# field)
+
+ */
+
+class Score_column {
+ friend class Score;
+ friend class Score_walker;
+
+ bool musical_b_;
+ Moment when_;
+ void set_breakable();
+public:
+ /// indirection to column
+ PCol * pcol_l_;
+
+ /// length of notes/rests in this column
+ Array<Moment> durations;
+
+ /* *************** */
+
+ Moment when() { return when_; }
+ Score_column(Moment when);
+ static int compare(Score_column & c1, Score_column &c2);
+ void add_duration(Moment );
+ void preprocess();
+ bool breakable_b();
+ bool musical_b() { return musical_b_; }
+ bool used_b();
+ void print() const;
+
+
+};
+
+instantiate_compare(Score_column&, Score_column::compare);
+
+#endif // SCCOL_HH
+
+
+
+
--- /dev/null
+/*
+ staffcolumn.hh -- declare Staff_column
+
+ (c) 1996,97 Han-Wen Nienhuys
+*/
+
+#ifndef STAFFCOLUMN_HH
+#define STAFFCOLUMN_HH
+#include "proto.hh"
+#include "varray.hh"
+#include "moment.hh"
+
+/// store simultaneous requests
+class Staff_column {
+
+ Staff_column(Staff_column const&);
+
+public:
+ Array<Request*> musicalreq_l_arr_;
+ Array<Request*> commandreq_l_arr_;
+ Staff * staff_l_;
+
+ /// fields to collect timing data vertically.
+ Array<Timing_req*> timing_req_l_arr_;
+ Score_column *musical_column_l_, *command_column_l_;
+
+ /* *************** */
+
+ Staff_column();
+
+ Moment when() const;
+ void set_cols(Score_column *c1, Score_column *c2);
+ void add(Voice_element*ve);
+ void OK() const;
+ ~Staff_column();
+ void typeset_breakable_items(Array<Item *> &pre_p_arr,
+ Array<Item *> &nobreak_p_arr,
+ Array<Item *> &post_p_arr);
+ void typeset_musical_item(Item *i);
+protected:
+ void setup_one_request(Request*);
+};
+
+
+
+#endif // STAFFCOLUMN_HH
+
#include "score.hh"
#include "pscore.hh"
#include "paperdef.hh"
-#include "sccol.hh"
+#include "scorecolumn.hh"
#include "dimen.hh"
#include "pscore.hh"
#include "bar.hh"
#include "meter.hh"
-#include "sccol.hh"
+#include "scorecolumn.hh"
#include "commandrequest.hh"
const NO_LINES = 5;
#include "lyricwalker.hh"
#include "debug.hh"
#include "lyricitem.hh"
-#include "stcol.hh"
+#include "staffcolumn.hh"
void
Lyric_walker::process_requests()
--- /dev/null
+/*
+ scorecolumn.cc -- implement Score_column
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "debug.hh"
+#include "pcol.hh"
+#include "scorecolumn.hh"
+
+int
+Score_column::compare(Score_column & c1, Score_column &c2)
+{
+ return sign(c1.when_ - c2.when_);
+}
+
+void
+Score_column::set_breakable()
+{
+ pcol_l_->set_breakable();
+}
+
+Score_column::Score_column(Moment w)
+{
+ when_ = w;
+ pcol_l_ = new PCol(0);
+ musical_b_ = false;
+}
+
+bool
+Score_column::used_b() {
+ return pcol_l_->used_b();
+}
+
+void
+Score_column::print() const
+{
+#ifndef NPRINT
+ mtor << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n';
+ mtor << "durations: [";
+ for (int i=0; i < durations.size(); i++)
+ mtor << durations[i] << " ";
+ mtor << "]\n";
+ pcol_l_->print();
+ mtor << "}\n";
+#endif
+}
+
+int
+Moment_compare(Moment &a , Moment& b)
+{
+ return sign(a-b);
+}
+
+void
+Score_column::preprocess()
+{
+ durations.sort(Moment_compare);
+}
+void
+Score_column::add_duration(Moment d)
+{
+ assert(d);
+ for (int i = 0; i< durations.size(); i++) {
+ if (d == durations[i])
+ return ;
+ }
+ durations.push(d);
+}
+
+bool
+Score_column::breakable_b()
+{
+ return pcol_l_->breakable_b();
+}
#include "score.hh"
#include "staffwalker.hh"
#include "staff.hh"
-#include "sccol.hh"
+#include "scorecolumn.hh"
Score_walker::Score_walker(Score *s)
:PCursor<Score_column *> (s->cols_)
+/*
+ template2.cc -- instantiate some list templates.
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "symbol.hh"
#include "voice.hh"
#include "musicalrequest.hh"
#include "staff.hh"
-#include "sccol.hh"
-#include "stcol.hh"
+#include "scorecolumn.hh"
+#include "staffcolumn.hh"
#include "spanner.hh"
#include "plist.tcc"
#include "pcursor.tcc"
+/*
+ template4.cc -- instantiate PointerList baseclass.
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "proto.hh"
#include "list.tcc"
#include "cursor.tcc"
#include "proto.hh"
#include "plist.tcc"
#include "register.hh"
-#include "voicegroup.hh"
+#include "voicegroupregs.hh"
+#include "voiceregs.hh"
IPL_instantiate(Voice_registers);
IPL_instantiate(Voice_group_registers);
+IPL_instantiate(Request_register);
--- /dev/null
+/*
+ voicegroup.cc -- implement Voice_group_registers
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "plist.hh"
+#include "musicalrequest.hh"
+#include "voiceregs.hh"
+#include "voicegroupregs.hh"
+#include "register.hh"
+#include "textreg.hh"
+#include "stembeamreg.hh"
+#include "scriptreg.hh"
+#include "complexwalker.hh"
+#include "commandrequest.hh"
+
+static int temp_id_count;
+
+Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id)
+{
+ walk_l_ = w_l;
+ add(new Text_register(w_l));
+ add(new Stem_beam_register(w_l));
+ add(new Script_register(w_l));
+
+ if (id=="") // UGH
+ id = __FUNCTION__ + String(temp_id_count++);
+ group_id_str_ = id;
+}
+
+bool
+Voice_group_registers::try_request(Request*r_l)
+{
+ if (r_l->groupfeature()) {
+ set_dir(r_l->groupfeature()->stemdir_i_);
+ return true;
+ }
+ return Register_group::try_request(r_l);
+}
+
+void
+Voice_group_registers::acknowledge_element(Staff_elem_info i)
+{
+ if (i.group_regs_l_!= this)
+ return;
+ Register_group::acknowledge_element(i);
+}
+#if 1
+void
+Voice_group_registers::set_dir(int i)
+{
+ Register_group::set_dir(i);
+
+ // ughh
+ Array<Voice_registers*> vr_arr (walk_l_->get_voice_regs(this));
+ for (int j=0; j<vr_arr.size(); j++) {
+ if (vr_arr[j])
+ vr_arr[j]->set_dir(i);
+ }
+}
+#endif
+bool
+Voice_group_registers::acceptable_request_b(Request*r)
+{
+ return (r->stem() || r->beam() || r->text() || r->script() ||
+ r->groupfeature());
+}
+/*
+ voiceregs.cc -- implement Voice_registers
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "musicalrequest.hh"
-#include "voicegroup.hh"
+#include "voiceregs.hh"
#include "register.hh"
#include "slurreg.hh"
#include "headreg.hh"
Voice_registers::Voice_registers(Complex_walker*c_l, Voice *v_p)
{
voice_l_ = v_p;
- head_reg_ = new Notehead_register(c_l);
- slur_reg_ = new Slur_register(c_l);
-}
-Voice_registers::~Voice_registers()
-{
- delete head_reg_;
- delete slur_reg_;
-}
-bool
-Voice_registers::try_request(Request * r_l)
-{
- bool b = head_reg_->try_request(r_l);
- if (!b)
- b = slur_reg_->try_request(r_l);
- return b;
+ add(new Notehead_register(c_l));
+ add(new Slur_register(c_l));
}
void
{
if (i.voice_l_ != voice_l_)
return;
- if (i.origin_reg_l_ != slur_reg_)
- slur_reg_->acknowledge_element(i);
-}
-
-void
-Voice_registers::pre_move_processing()
-{
- head_reg_->pre_move_processing();
- slur_reg_->pre_move_processing();
-}
-void
-Voice_registers::post_move_processing()
-{
- head_reg_->post_move_processing();
- slur_reg_->post_move_processing();
-}
-
-void
-Voice_registers::process_requests()
-{
- head_reg_->process_request();
- slur_reg_->process_request();
+ Register_group::acknowledge_element(i);
}
bool
-Voice_registers::acceptable_request(Request*r)
+Voice_registers::acceptable_request_b(Request*r)
{
return (r->rest() || r->note() || r->slur());
-
-}
-
-void
-Voice_registers::set_dir(int i)
-{
- head_reg_->set_dir(i);
- slur_reg_->set_dir(i);
}
-