]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.21
authorfred <fred>
Sun, 24 Mar 2002 19:27:21 +0000 (19:27 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:27:21 +0000 (19:27 +0000)
hdr/beam.hh
hdr/break.hh [new file with mode: 0644]
hdr/staffelem.hh [new file with mode: 0644]
hdr/textspanner.hh
src/textspanner.cc

index e376f00978066da6a4a2c0d61709eee112ed1780..2fd78100c35d52a612669ca96f3b059f5e8e24ae 100644 (file)
@@ -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 (file)
index 0000000..4c0f6b3
--- /dev/null
@@ -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<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
+
diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh
new file mode 100644 (file)
index 0000000..a12addb
--- /dev/null
@@ -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<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
+
index 6a0aa3e761f95a7f82a052792c3d555b392d9071..1e9d06d54338b3ca5da63a45228050bc0fc7f235 100644 (file)
@@ -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*);
 };
 /**
index e33efbb9b38ae7e76d777d802ec55ec71a608d9e..3fd96839262f74d18efcd66be34aaa341483ca0d 100644 (file)
@@ -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);    
 }