]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/molecule.hh
release: 1.3.69
[lilypond.git] / lily / include / molecule.hh
index d33a100cdf770b30a6132cc53c5ef7dd4fc54c14..548085bcff912bfc8228d17e1b1b8a9c183c7506 100644 (file)
@@ -8,45 +8,54 @@
 #ifndef MOLECULE_HH
 #define MOLECULE_HH
 
+#include <stdlib.h>            // 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)
-
+    
 */
 class Molecule {
-#ifdef ATOM_SMOB
-  SCM atom_list_;
-#else
-  //  Protected_scm atom_list_;        // change to List<Atom>?
-  Cons<Atom> *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 +69,19 @@ 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&);  
+  /**
+     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