+++ /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
-/*
- stcol.hh -- declare Staff_column
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STCOL_HH
-#define STCOL_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 // STCOL_HH
-
+++ /dev/null
-/*
- voicegroup.hh -- part of LilyPond
-
- (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef VOICEGROUP_HH
-#define VOICEGROUP_HH
-
-#include "proto.hh"
-#include "string.hh"
-
-struct Voice_registers {
- Notehead_register *head_reg_;
- Slur_register *slur_reg_;
- Voice *voice_l_;
-
- /* *************** */
- void set_dir(int i);
- static bool acceptable_request(Request*);
- void pre_move_processing();
- void post_move_processing();
- void acknowledge_element(Staff_elem_info info);
- Voice_registers(Complex_walker*,Voice*);
- ~Voice_registers();
- bool try_request(Request*);
- void process_requests();
-};
-
-
-struct Voice_group_registers {
- String group_id_str_;
- Text_register* text_reg_;
- Stem_beam_register* stem_beam_reg_;
- Script_register *script_reg_;
- Complex_walker * walk_l_;
- int dir_i_;
-
- /* *************** */
- void set_dir(int i);
- static bool acceptable_request(Request*);
- void pre_move_processing();
- void post_move_processing();
- void acknowledge_element(Staff_elem_info info);
- Voice_group_registers(Complex_walker*, String id = "");
- ~Voice_group_registers();
- void process_requests();
- bool try_request(Request*);
-};
-
-#endif
+++ /dev/null
-/*
- sccol.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 "sccol.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();
-}
+++ /dev/null
-/*
- stcol.cc -- implement Staff_column
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "staff.hh"
-#include "voice.hh"
-#include "timedescription.hh"
-#include "sccol.hh"
-#include "stcol.hh"
-#include "commandrequest.hh"
-#include "musicalrequest.hh"
-#include "interval.hh"
-#include "pscore.hh"
-#include "item.hh"
-#include "pcol.hh"
-
-void
-Staff_column::OK() const
-{
-#ifndef NDEBUG
- assert (command_column_l_->when() == musical_column_l_->when());
-#endif
-}
-
-Moment
-Staff_column::when() const
-{
- return (command_column_l_)?
- command_column_l_->when():
- musical_column_l_->when();
-}
-
-void
-Staff_column::add(Voice_element*ve)
-{
- for (iter_top(ve->reqs,j); j.ok(); j++) {
- if (j->nonmus()) {
- Nonmusical_req * c_l = j->nonmus();
- if (c_l->timing()) {
- timing_req_l_arr_.push(j->nonmus()->timing());
- }
- if (!c_l->barcheck() && !c_l->partial() &&
- !c_l->measuregrouping())
- setup_one_request(j); // no need to bother children
- } else {
- if (j->rhythmic()) {
- musical_column_l_->add_duration(j->rhythmic()->duration());
- }
- if (!j->musical()->skip())
- setup_one_request(j);
- }
- }
-}
-
-Staff_column::Staff_column()
-{
- musical_column_l_ = 0;
- command_column_l_ = 0;
- staff_l_ = 0;
-}
-
-
-
-
-Staff_column::~Staff_column()
-{
-}
-
-void
-Staff_column::set_cols(Score_column*c1, Score_column*c2)
-{
- command_column_l_ = c1;
- musical_column_l_ = c2;
-}
-
-void
-Staff_column::setup_one_request(Request * j)
-{
- if (j->nonmus()) // ugh
- commandreq_l_arr_.push(j);
- else if (j->musical())
- musicalreq_l_arr_.push(j);
-}
-
-void
-Staff_column::typeset_musical_item(Item*i)
-{
- assert(i);
- Score_column * sccol_l = musical_column_l_;
- musical_column_l_->pcol_l_->pscore_l_->typeset_item(i, sccol_l->pcol_l_,
- staff_l_->pstaff_l_);
-}
-
-/**
- align items in #item_l_arr#, return the width.
- */
-Interval
-align_items(Array<Item*> item_l_arr)
-{
- Interval wid(0,0);
- for (int i =0; i < item_l_arr.size(); i++) {
- Interval item_width= item_l_arr[i]->width();
- item_l_arr[i]->translate(Offset( wid.right - item_width.left ,0));
- wid.unite(item_width);
- }
- return wid;
-}
-
-void
-translate_items(Real x, Array<Item*> item_l_arr)
-{
- for (int i =0; i < item_l_arr.size(); i++)
- item_l_arr[i]->translate(Offset(x, 0));
-}
-/*
- UGR
- This still sux
- */
-void
-Staff_column::typeset_breakable_items(Array<Item *> &pre_p_arr,
- Array<Item *> &nobreak_p_arr,
- Array<Item *> &post_p_arr)
-{
- PCol * c= command_column_l_->pcol_l_;
- PScore *ps_l=command_column_l_->pcol_l_->pscore_l_;
-
- if (!c->breakable_b()) {
- for (int i =0; i < pre_p_arr.size(); i++)
- delete pre_p_arr[i];
- pre_p_arr.set_size(0);
- for (int i =0; i < post_p_arr.size(); i++)
- delete post_p_arr[i];
- post_p_arr.set_size(0);
- }
-
-
- for (int i =0; i < pre_p_arr.size(); i++) {
- ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0);
- }
- for (int i =0; i < nobreak_p_arr.size(); i++) {
- ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1);
- }
- for (int i =0; i < post_p_arr.size(); i++) {
- ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2);
- }
-
- Interval pre_wid= align_items(pre_p_arr);
- translate_items( -pre_wid.right, pre_p_arr);
- align_items(nobreak_p_arr);
- Interval post_wid =align_items(post_p_arr);
- translate_items (-post_wid.left , post_p_arr);
-
- pre_p_arr.set_size(0);
- post_p_arr.set_size(0);
- nobreak_p_arr.set_size(0);
-}
+++ /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 "voicegroup.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;
- text_reg_=new Text_register(w_l);
- stem_beam_reg_= new Stem_beam_register(w_l);
- script_reg_ = new Script_register(w_l);
- if (id=="")
- id = __FUNCTION__ + String(temp_id_count++);
- group_id_str_ = id;
- dir_i_ = 0;
-}
-
-Voice_group_registers::~Voice_group_registers()
-{
- delete text_reg_;
- delete stem_beam_reg_;
- delete script_reg_;
-}
-
-void
-Voice_group_registers::pre_move_processing()
-{
- stem_beam_reg_->pre_move_processing();
- script_reg_->pre_move_processing();
- text_reg_->pre_move_processing();
-}
-
-void
-Voice_group_registers::post_move_processing()
-{
- stem_beam_reg_->post_move_processing();
- text_reg_->post_move_processing();
- script_reg_->post_move_processing();
-}
-
-bool
-Voice_group_registers::try_request(Request*r_l)
-{
- if (r_l->groupfeature()) {
- set_dir(r_l->groupfeature()->stemdir_i_);
- return true;
- }
- bool b = stem_beam_reg_->try_request(r_l);
- if (!b)
- b|= script_reg_->try_request(r_l);
- if (!b)
- b|= text_reg_->try_request(r_l);
-
- return b;
-}
-
-void
-Voice_group_registers::acknowledge_element(Staff_elem_info i)
-{
- if (i.group_regs_l_!= this)
- return;
-
- stem_beam_reg_->acknowledge_element(i);
- script_reg_->acknowledge_element(i);
- text_reg_->acknowledge_element(i);
-}
-
-void
-Voice_group_registers::set_dir(int i)
-{
- stem_beam_reg_->set_dir(i);
- script_reg_->set_dir(i);
- text_reg_->set_dir(i);
-
- 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);
-}
-}
-void
-Voice_group_registers::process_requests()
-{
- stem_beam_reg_->process_request();
- script_reg_->process_request();
- text_reg_->process_request();
-}
-
-
-bool
-Voice_group_registers::acceptable_request(Request*r)
-{
- return (r->stem() || r->beam() || r->text() || r->script() ||
- r->groupfeature());
-}