/*
complex-walker.cc -- implement Complex_walker
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-
+#include "score.hh"
#include "staff-column.hh"
#include "voice.hh"
#include "p-score.hh"
-#include "complex-staff.hh"
#include "debug.hh"
#include "complex-walker.hh"
#include "walk-regs.hh"
+#include "score-elem.hh"
+#include "staff.hh"
+#include "staffline.hh"
void
Complex_walker::do_post_move()
{
if (!elem_p)
return;
+ staff_l_->staff_line_l_->add_element(elem_p);
if (elem_p->spanner())
- pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_);
+ pscore_l_->typeset_unbroken_spanner(elem_p->spanner());
else
ptr()->typeset_musical_item(elem_p->item());
}
-Complex_walker::Complex_walker(Complex_staff*s)
- : Staff_walker(s, s->pstaff_l_->pscore_l_)
+Complex_walker::Complex_walker(Staff*s)
+ : Staff_walker(s, s->score_l_->pscore_p_)
{
walk_regs_p_ = new Walker_registers(this);
do_post_move();
Complex_walker::~Complex_walker()
{
-}
-
-Complex_staff*
-Complex_walker::staff()
-{
- return (Complex_staff*) staff_l_;
+ delete walk_regs_p_;
}
/*
p-score.hh -- declare PScore
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#define P_SCORE_HH
#include "colhpos.hh"
-#include "varray.hh"
+#include "parray.hh"
#include "lily-proto.hh"
-#include "p-col.hh"
-#include "p-staff.hh"
+#include "plist.hh"
+/** all stuff which goes onto paper. notes, signs, symbols in a score
+ #PScore# contains the items, the columns.
+
+ */
-/** all stuff which goes onto paper. notes, signs, symbols in a score can be grouped in two ways:
- horizontally (staffwise), and vertically (columns). #PScore#
- contains the items, the columns and the staffs.
- */
-
-struct PScore {
+class PScore {
+public:
Paper_def *paper_l_;
-
+
/// the columns, ordered left to right
Pointer_list<PCol *> cols;
/// the idealspacings, no particular order
Pointer_list<Idealspacing*> suz;
- /// the staffs ordered top to bottom
- Pointer_list<PStaff*> staffs;
-
- /// all symbols in score. No particular order.
- Pointer_list<Item*> its;
-
- /// if broken, the different lines
- Pointer_list<Line_of_score*> lines;
-
/// crescs etc; no particular order
Pointer_list<Spanner *> spanners;
- /// broken spanners
- Pointer_list<Spanner*> broken_spans;
+ /// other elements
+ Pointer_list<Score_elem*> elem_p_list_;
+
+ Super_elem *super_elem_l_;
- Pointer_list<Vertical_spanner*> vspan_p_list_;
/* *************** */
/* CONSTRUCTION */
/// add a line to the broken stuff. Positions given in #config#
void set_breaking(Array<Col_hpositions> const &);
- void add(PStaff *);
-
-
/** add an item.
add the item in specified containers. If breakstatus is set
properly, add it to the {pre,post}break of the pcol.
*/
- void typeset_item(Item *item_p, PCol *pcol_l,PStaff*pstaf_l,int breakstatus=1);
+ void typeset_item(Item *item_p, PCol *pcol_l,int breakstatus=1);
- /// add a Spanner
- void typeset_spanner(Spanner*, PStaff*);
-
/// add to bottom of pcols
void add(PCol*);
- void add_broken(Spanner*);
- /* INSPECTION */
- Array<Item*> select_items(PStaff*, PCol*);
-
- /**
- @return argument as a cursor of the list
- */
+ /**
+ @return argument as a cursor of the list
+ */
PCursor<PCol *> find_col(PCol const *)const;
+ Link_array<PCol> col_range(PCol *left_l, PCol *right_l) const;
+
/* MAIN ROUTINES */
void process();
/* STANDARD ROUTINES */
void OK()const;
void print() const;
+ ~PScore();
+ void typeset_element(Score_elem*);
+ void typeset_broken_spanner(Spanner*);
+ /// add a Spanner
+ void typeset_unbroken_spanner(Spanner*);
+
+
private:
/// before calc_breaking
void preprocess();
/*
staff-side.hh -- declare Staff_side
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#ifndef STAFF_SIDE_HH
#define STAFF_SIDE_HH
-#include "staff-elem.hh"
+#include "score-elem.hh"
/// A symbol which sits along the staff
-class Staff_side {
- Array<Score_elem*> support_l_arr_;
+class Staff_side : virtual Score_elem {
+ Link_array<Score_elem> support_l_arr_;
int staff_size_i_;
- Score_elem * elem_l_;
Interval support_height()const;
Staff_symbol* staff_sym_l_;
+
void read_staff_sym();
public:
- Real inter_f_;
+
/**
Vertical dir of symbol relative to staff. -1 = below staff?
*/
/// follow the support inside the staff?
bool inside_staff_b_;
- void set_staffsym(Staff_symbol*);
+ void set_staffsym(Staff_symbol * );
- Staff_side(Score_elem*);
+ Staff_side();
void add_support(Score_elem*);
protected:
+ virtual void do_substitute_dependency(Score_elem *, Score_elem*);
int get_position_i()const;
int get_position_i(Interval)const;
};
/*
slur.cc -- implement Slur
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
left_col_l_ = encompass_arr_[0]->pcol_l_;
}
-Spanner*
-Slur::do_break_at(PCol*l, PCol*r) const
+void
+Slur::do_break_at(PCol*l, PCol*r)
{
assert(l->line_l_ == r->line_l_);
- Slur*ret = new Slur(*this);
- ret->encompass_arr_.set_size(0);
- for (int i =0; i < encompass_arr_.size(); i++) {
- if (encompass_arr_[i]->pcol_l_->line_l_==l->line_l_)
- ret->encompass_arr_.push(encompass_arr_[i]);
+ Array<Note_column*> old_encompass_arr = encompass_arr_;
+ encompass_arr_.set_size(0);
+ for (int i =0; i < old_encompass_arr.size(); i++) {
+ if (old_encompass_arr[i]->pcol_l_->line_l_==l->line_l_)
+ encompass_arr_.push(old_encompass_arr[i]);
}
+}
- return ret;
+void
+Slur::do_substitute_dependency(Score_elem*o, Score_elem*n)
+{
+ int i;
+ while((i = encompass_arr_.find_i((Note_column*)o->item())) >=0) {
+ if (n)
+ encompass_arr_[i] = (Note_column*)n->item();
+ else
+ encompass_arr_.del(i);
+ }
}
+
void
Slur::do_post_processing()
{
if (!dir_i_)
set_default_dir();
- Real inter_f = paper()->internote();
+ Real inter_f = paper()->internote_f();
if (encompass_arr_[0]->stem_l_)
left_pos_i_ = rint(encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f);
else
--- /dev/null
+/*
+ spanner-elem-group.cc -- implement
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "p-col.hh"
+#include "spanner-elem-group.hh"
+
+void
+Spanner_elem_group::do_break_at(PCol*c1, PCol*c2 )
+{
+ Line_of_score * line_C = c1->line_l_;
+ Array<Score_elem*> old_elems=elem_l_arr_;
+ elem_l_arr_.set_size(0);
+ for (int i=0; i < old_elems.size(); i++) {
+ if (old_elems[i]->line_l() == line_C) {
+ add_element(old_elems[i]);
+ }
+ }
+}
+
+IMPLEMENT_STATIC_NAME(Spanner_elem_group);
+
+Interval
+Spanner_elem_group::do_width() const
+{
+ return Spanner::do_width();
+}
+
+void
+Spanner_elem_group::do_print() const
+{
+ Element_group::do_print();
+}
+
/*
staff.cc -- implement Staff
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-#include "input-register.hh"
+
#include "proto.hh"
+#include "plist.hh"
+#include "input-register.hh"
#include "staff.hh"
#include "score.hh"
#include "voice.hh"
#include "debug.hh"
#include "musical-request.hh"
#include "command-request.hh" // todo
-
+#include "staffline.hh"
+#include "complex-walker.hh"
+#include "super-elem.hh"
+#include "p-score.hh"
+#include "scoreline.hh"
void
Staff::add(Link_list<Voice*> const &l)
#ifndef NDEBUG
cols_.OK();
voice_list_.OK();
- iter_top(cols_, i);
- iter_top(cols_, j);
- i++;
assert(score_l_);
#endif
}
#endif
}
+Staff::~Staff()
+{
+ delete ireg_p_;
+}
+
Staff::Staff()
{
ireg_p_ =0;
score_l_ =0;
pscore_l_ =0;
- pstaff_l_ =0;
}
void
cols_.bottom().add(c_l);
c_l->staff_l_ = this;
}
+
+void
+Staff::set_output(PScore* pscore_l )
+{
+ pscore_l_ = pscore_l;
+ staff_line_l_ = new Line_of_staff;
+ pscore_l_->typeset_unbroken_spanner(staff_line_l_);
+ pscore_l_->super_elem_l_->line_of_score_l_->add_line(staff_line_l_);
+}
+
+
+Staff_walker *
+Staff::get_walker_p()
+{
+ return new Complex_walker(this);
+}