X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fmolecule.hh;h=78aace7bd3f72cd26a2bc876ec24641a6605a3f6;hb=5cc390968095201b69f142ad01842ac3f08144a2;hp=3904acb4bf121f50a6fa76a20fd4785e7be85b97;hpb=b75137963d1390716d79dab8fd593daa2d56c94f;p=lilypond.git diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh index 3904acb4bf..78aace7bd3 100644 --- a/lily/include/molecule.hh +++ b/lily/include/molecule.hh @@ -1,57 +1,90 @@ +/* + molecule.hh -- declare Molecule + + source file of the GNU LilyPond music typesetter + + (c) 1997--2004 Han-Wen Nienhuys +*/ #ifndef MOLECULE_HH #define MOLECULE_HH -#include "proto.hh" -#include "plist.hh" -#include "boxes.hh" -#include "symbol.hh" +#include // size_t +#include "lily-proto.hh" +#include "box.hh" +#include "axes.hh" +#include "direction.hh" +#include "lily-guile.hh" +#include "smobs.hh" -/// a symbol which can be translated, and freely copied -struct Atom { - Offset off; - Symbol sym; +/** a group of individually translated symbols. You can add molecules + to the top, to the right, etc. - /* *************** */ - - void translate(Offset o) { - off += o; - } + 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. - /// how big is #this#? - Box extent() const; - Atom(Symbol s); + Dimension behavior: - void print() const; + 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) +*/ +class Molecule +{ + friend SCM ly_molecule_set_extent_x (SCM, SCM, SCM); + + Box dim_; + SCM expr_; + + DECLARE_SIMPLE_SMOBS (Molecule,); +public: + Molecule (Box, SCM s); + Molecule (); - String TeXstring() const; -}; + SCM smobbed_copy () const; + SCM get_expr () const; -/** a group of individually translated symbols. You can add molecules - to the top, to the right, etc. */ -struct Molecule { - Pointer_list ats; // change to List? + /** + 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, + Real minimum); + void add_molecule (Molecule const &m); + void translate (Offset); + void align_to (Axis a, Real x); + void translate_axis (Real,Axis); + + Interval extent (Axis) const; + Box extent_box () const; + /** + codify THIS into a Scheme expression. + */ + SCM create_scheme () const; + bool is_empty () const; - /* *************** */ - - Molecule() { } - Molecule(Atom a) { add(a) ; } - - void add_right(const Molecule &m); - void add_left(const Molecule &m); - void add_top(const Molecule &m); - void add_bottom(const Molecule &m); - void add(Molecule const &m); - void translate(Offset); - void add(Atom a) { ats.bottom().add(new Atom(a)); } - /// how big is #this#? - Box extent() const; - - String TeXstring() const; - - Molecule(const Molecule&s); - void print() const; -private: - void operator=(const Molecule&); + + static SCM ly_get_molecule_extent (SCM mol, SCM axis); + static SCM ly_set_molecule_extent_x (SCM,SCM,SCM); + static SCM ly_molecule_combined_at_edge (SCM,SCM,SCM,SCM,SCM); }; + + +DECLARE_UNSMOB(Molecule,molecule); +SCM fontify_atom (Font_metric const*, SCM atom); + +Molecule create_molecule (SCM print); + + + #endif