X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fmolecule.hh;h=e61a64c8b9c89de83bd13a0d66d5fa6cc8461a17;hb=e2263620675cc1467e01a6ec67f55ffdb56361e4;hp=f8edc37c2520b6fa1b1c731eda0949848f35b905;hpb=1cf3d59c1559fb9774c4c1c8cae155cfe54a927c;p=lilypond.git diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh index f8edc37c25..e61a64c8b9 100644 --- a/lily/include/molecule.hh +++ b/lily/include/molecule.hh @@ -3,40 +3,88 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ #ifndef MOLECULE_HH #define MOLECULE_HH +#include // size_t #include "lily-proto.hh" -#include "plist.hh" #include "box.hh" #include "axes.hh" #include "direction.hh" +#include "lily-guile.hh" /** a group of individually translated symbols. You can add molecules - to the top, to the right, etc. */ -struct Molecule { - Pointer_list atoms_; // change to List? + to the top, to the right, etc. - /* *************** */ + It is implemented as a "tree" of scheme expressions, as in + + Expr = combine Expr Expr + | translate Offset Expr + | SCHEME + ; + + SCHEME is a Scheme expression that --when eval'd-- produces the + desired output. + + + Because of the way that Molecule is implemented, it is the most + efficient to add "fresh" molecules to what you're going to build. + + Dimension behavior: + + Empty molecules have empty dimensions. If add_at_edge is used to + init the molecule, we assume that + DIMENSIONS = (Interval(0,0),Interval(0,0) + + TODO: go full smob with Molecule. - Molecule() { } - Molecule (Atom const &a); +*/ +class Molecule { + /// can't alloc on heap. + void * operator new (size_t s); + Box dim_; + SCM expr_; - void add_at_edge (Axis a, Direction d, const Molecule &m); +public: + + SCM get_expr () const; + Molecule (Box, SCM s); + Molecule(); + + /** + Set dimensions to empty, or to (Interval(0,0),Interval(0,0) */ + void set_empty (bool); + void add_at_edge (Axis a, Direction d, const Molecule &m, Real padding); void add_molecule (Molecule const &m); void translate (Offset); - void translate_axis (Real,Axis); - void add_atom (Atom const & a) ; - /// how big is #this#? - Box extent() const; + + /** + align D direction in axis A. + If D == CENTER, then move the dimension(A).center() to (0,0) - Molecule (const Molecule&s); - void print() const; -private: - void operator=(const Molecule&); + Else, move so dimension(A)[D] == 0.0 + + */ + void align_to (Axis a, Direction d); + void translate_axis (Real,Axis); + + Interval extent (Axis) const; + Box extent_box () const; + /** + codify THIS into a Scheme expression. + */ + SCM create_scheme () const; + bool empty_b() const; }; + +SCM fontify_atom (Font_metric*, SCM atom); + +Molecule create_molecule (SCM brew_molecule); + + + #endif