From d97cbe3ca35baa941727fd4985ad9e939f502955 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:27:21 +0000 Subject: [PATCH] lilypond-0.0.21 --- hdr/beam.hh | 16 ++++++----- hdr/break.hh | 54 ++++++++++++++++++++++++++++++++++++ hdr/staffelem.hh | 68 ++++++++++++++++++++++++++++++++++++++++++++++ hdr/textspanner.hh | 16 ++++++----- src/textspanner.cc | 41 ++++++++++++++-------------- 5 files changed, 161 insertions(+), 34 deletions(-) create mode 100644 hdr/break.hh create mode 100644 hdr/staffelem.hh diff --git a/hdr/beam.hh b/hdr/beam.hh index e376f00978..2fd78100c3 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -24,22 +24,24 @@ struct Beam: public Directional_spanner { virtual Interval width()const; Offset center() const; - Spanner *broken_at(PCol *, PCol *) const; + Spanner *do_break_at(PCol *, PCol *) const; Beam(); void add(Stem*); - void process(); - void calculate(); + + void set_default_dir(); - void preprocess(); - Interval height()const; + void do_pre_processing(); + void do_post_processing(); + void print() const; void set_grouping(Rhythmic_grouping def, Rhythmic_grouping current); void set_stemlens(); ~Beam(); + private: - Molecule stem_beams(Stem *here, Stem *next, Stem *prev); + Molecule stem_beams(Stem *here, Stem *next, Stem *prev)const; void solve_slope(); - void brew_molecule(); + Molecule*brew_molecule()const; }; /** Beam adjusts the stems its owns to make sure that they reach the beam and that point in the correct direction */ diff --git a/hdr/break.hh b/hdr/break.hh new file mode 100644 index 0000000000..4c0f6b33b6 --- /dev/null +++ b/hdr/break.hh @@ -0,0 +1,54 @@ +/* + break.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef BREAK_HH +#define BREAK_HH +#include "vray.hh" +#include "proto.hh" +typedef svec Line_of_cols; + +struct Col_configuration { + Line_of_cols cols; + svec config; + Real energy; + + /****************/ + void OK()const; + void setsol(svec); + Col_configuration() ; + void add( PCol*c); + void print() const; +}; + +struct Break_algorithm { + PScore &pscore_; + Real linelength; + + /****************/ + + Break_algorithm(PScore&); + /// check if the spacing/breaking problem is well-stated + void problem_OK()const; + /// search all pcols which are breakable. + svec find_breaks() const; + + /// helper: solve for the columns in #curline#. + svec solve_line(Line_of_cols) const; + + + /// does curline fit on the paper? + bool feasible(Line_of_cols)const; + + virtual svec solve()=0; +}; + +/// wordwrap type algorithm: move to next line if current is optimal. +struct Word_wrap : Break_algorithm { + virtual svec solve(); + Word_wrap(PScore&); +}; +#endif // BREAK_HH + diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh new file mode 100644 index 0000000000..a12addbfac --- /dev/null +++ b/hdr/staffelem.hh @@ -0,0 +1,68 @@ +/* + staffelem.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef STAFFELEM_HH +#define STAFFELEM_HH +#include "vray.hh" +#include "proto.hh" +#include "offset.hh" +#include "molecule.hh" + +struct Staff_elem { + enum Status { + ORPHAN, // not yet added to pstaff + VIRGIN, // added to pstaff + PRECALCED, // calcs before spacing done + POSTCALCED, // after spacing calcs done + OUTPUT, // molecule has been output + } status; + bool calc_children; + svec dependencies; + + /// indirection to the pstaff it is in + PStaff *pstaff_; + + /****************/ + + String TeXstring () const ; + virtual void print() const; + virtual Interval width() const; + virtual Interval height() const; + Paperdef *paper() const; + virtual ~Staff_elem(); + Staff_elem(); + + void translate(Offset); + void add_processing(); + void pre_processing(); + void post_processing(); + void molecule_processing(); + +protected: + /// generate the molecule + virtual Molecule* brew_molecule()const=0; + ///executed directly after the item is added to the PScore + virtual void do_add_processing(); + /// do calculations before determining horizontal spacing + virtual void do_pre_processing(); + + /// do calculations after determining horizontal spacing + virtual void do_post_processing(); + +private: + /// member: the symbols + Molecule *output; // should scrap, and use temp var? + + /// + Offset offset_; + /** + This is needed, because #output# may still be + NULL. + */ +}; + +#endif // STAFFELEM_HH + diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh index 6a0aa3e761..1e9d06d543 100644 --- a/hdr/textspanner.hh +++ b/hdr/textspanner.hh @@ -9,18 +9,20 @@ #include "string.hh" #include "directionalspanner.hh" +#include "textdef.hh" /// a spanner which puts texts on top of other spanners. struct Text_spanner : Spanner { - int align; - String text; - String style; + Text_def spec; + Offset tpos; Directional_spanner*support; /****************/ - virtual void process(); - virtual void preprocess(); - virtual Interval height() const; - virtual Spanner* broken_at(PCol*,PCol*)const; + virtual void do_pre_processing(); + virtual void do_post_processing(); + Molecule* brew_molecule()const; + virtual Interval height() const ; + void print() const; + virtual Spanner* do_break_at(PCol*,PCol*)const; Text_spanner(Directional_spanner*); }; /** diff --git a/src/textspanner.cc b/src/textspanner.cc index e33efbb9b3..3fd9683926 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -1,22 +1,18 @@ -#include "paper.hh" #include "molecule.hh" -#include "lookup.hh" #include "boxes.hh" #include "textspanner.hh" +#include "textdef.hh" Text_spanner::Text_spanner(Directional_spanner*d) { support = d; - align = 0; - style = "roman"; + dependencies.add(d); } void -Text_spanner::process() +Text_spanner::do_post_processing() { - Offset tpos; - - switch(align) { + switch(spec.align) { case 0: tpos = support->center(); break; @@ -25,16 +21,24 @@ Text_spanner::process() break; } - Paperdef *pap_p = paper(); - Atom tsym (pap_p->lookup_->text(style, text, -align)); - tsym.translate(tpos); - output = new Molecule; - output->add( tsym ); } +Molecule* +Text_spanner::brew_molecule() const +{ + Atom tsym (spec.create(paper())); + tsym.translate(tpos); + Molecule*output = new Molecule; + output->add( tsym ); + return output; +} +void +Text_spanner::print() const // todo +{ +} void -Text_spanner::preprocess() +Text_spanner::do_pre_processing() { right = support->right; left = support->left; @@ -44,14 +48,11 @@ Text_spanner::preprocess() Interval Text_spanner::height()const { - return output->extent().y; + return brew_molecule()->extent().y; } Spanner* -Text_spanner::broken_at(PCol*c1, PCol*c2)const +Text_spanner::do_break_at(PCol*c1, PCol*c2)const { - Text_spanner *n=new Text_spanner(*this); - n->left = c1; - n->right = c2; - return n; + return new Text_spanner(*this); } -- 2.39.5