X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fmolecule.hh;h=e61a64c8b9c89de83bd13a0d66d5fa6cc8461a17;hb=e2263620675cc1467e01a6ec67f55ffdb56361e4;hp=d33a100cdf770b30a6132cc53c5ef7dd4fc54c14;hpb=bb36bac02a64770871780231ecc709cb18b20932;p=lilypond.git diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh index d33a100cdf..e61a64c8b9 100644 --- a/lily/include/molecule.hh +++ b/lily/include/molecule.hh @@ -8,45 +8,56 @@ #ifndef MOLECULE_HH #define MOLECULE_HH +#include // size_t #include "lily-proto.hh" #include "box.hh" #include "axes.hh" #include "direction.hh" -#include "cons.hh" - -//#define ATOM_SMOB +#include "lily-guile.hh" /** a group of individually translated symbols. You can add molecules 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. + */ class Molecule { -#ifdef ATOM_SMOB - SCM atom_list_; -#else - // Protected_scm atom_list_; // change to List? - Cons *atom_list_; -#endif - friend class Paper_outputter; + /// can't alloc on heap. + void * operator new (size_t s); + Box dim_; + SCM expr_; public: - Box dim_; + SCM get_expr () const; + + Molecule (Box, SCM s); Molecule(); - ~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_atom (Atom const *a); void add_molecule (Molecule const &m); void translate (Offset); @@ -60,15 +71,20 @@ public: */ void align_to (Axis a, Direction d); void translate_axis (Real,Axis); - - /// how big is #this#? - Box extent() const; Interval extent (Axis) const; - - Molecule (const Molecule&s); - void print() const; - void operator=(const Molecule&); + 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