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 */
--- /dev/null
+/*
+ break.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef BREAK_HH
+#define BREAK_HH
+#include "vray.hh"
+#include "proto.hh"
+typedef svec<PCol*> Line_of_cols;
+
+struct Col_configuration {
+ Line_of_cols cols;
+ svec<Real> config;
+ Real energy;
+
+ /****************/
+ void OK()const;
+ void setsol(svec<Real>);
+ 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<PCol *> find_breaks() const;
+
+ /// helper: solve for the columns in #curline#.
+ svec<Real> solve_line(Line_of_cols) const;
+
+
+ /// does curline fit on the paper?
+ bool feasible(Line_of_cols)const;
+
+ virtual svec<Col_configuration> solve()=0;
+};
+
+/// wordwrap type algorithm: move to next line if current is optimal.
+struct Word_wrap : Break_algorithm {
+ virtual svec<Col_configuration> solve();
+ Word_wrap(PScore&);
+};
+#endif // BREAK_HH
+
--- /dev/null
+/*
+ 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<Staff_elem*> 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
+
#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*);
};
/**
-#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;
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;
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);
}