]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/score-element.hh
release: 1.3.19
[lilypond.git] / lily / include / score-element.hh
index 69f8eb998fc420f0a795106f46209a38554a0065..a223d5657d9f673b61cbe468655715d7bc7cb167 100644 (file)
@@ -9,10 +9,9 @@
 
 #include "parray.hh"
 #include "virtual-methods.hh"
-#include "directed-graph.hh"
-#include "graphical-element.hh"
-
-
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+#include "smobs.hh"
 
 typedef void (Score_element::*Score_element_method_pointer) (void);
 
@@ -23,72 +22,104 @@ typedef void (Score_element::*Score_element_method_pointer) (void);
   which are implemented in the Directed_graph_node class: all elements
   form an acyclic graph.
 
-  (elem) */
-class Score_element : private Directed_graph_node, public virtual Graphical_element {
+  (elem)
+
+
+Element Properties:
+
+Boolean (true iff defined)
+
+ break_helper_only -- if defined try to junk this after calcing breakpoints.
+
+ transparent -- do not calc. output
+
+*/
+class Score_element  {
+  /**
+     The lookup, determined by the font size. Cache this value.
+   */
+  Lookup * lookup_l_;
 public:
-  /// delete after linebreak calculation.
-  bool break_helper_only_b_;
-  Paper_score *pscore_l_;    
+  /**
+     properties specific for this element. Destructor will not call
+     scm_unprotect, so as to allow more flexible GC arrangements.  The
+     real alist is in (cdr element_property_alist_), to reduce the
+     need for more scm_protect calls.
+
+  */
+  SCM element_property_alist_;
+  
+  Score_element *original_l_;
+
+  /**
+    Administration: Where are we?. This is mainly used by Super_element and
+    Score_element::calcalute_dependencies ()
+
+    0 means ORPHAN,
+    -1 means deleted
+    
+   */
+  int status_i_;
+
+  Paper_score *pscore_l_;
   Molecule * output_p_;
   Score_element ();
   Score_element (Score_element const&);
   virtual void print () const;
-    
-  Paper_def *paper () const;
-  Lookup const *lookup_l () const;
 
-  virtual ~Score_element ();
-      
+  /*
+    properties
+   */
+  SCM get_elt_property (String nm) const;
+  void set_elt_property (String, SCM val);
+  SCM remove_elt_property (String nm);
+
+  void Score_element::set_real (String, Real);
+  Real Score_element::get_real (String s) const;
+
+  /*
+    related classes.
+   */
+  Paper_def *paper_l () const;
+  Lookup const *lookup_l () const;
 
   void add_processing ();
 
-  /**
-    Remove all  links (dependencies, dependents, Axis_group_elements.
-    */
-  void unlink ();
-  void substitute_dependency (Score_element*,Score_element*);
-  void remove_dependency (Score_element*);
   /**
     add a dependency. It may be the 0 pointer, in which case, it is ignored.
     */
   void add_dependency (Score_element*);    
-
   virtual Line_of_score * line_l () const;
-  virtual bool linked_b () const;
+  bool linked_b () const;
   VIRTUAL_COPY_CONS(Score_element);
  
-  /// do not print anything black
-  bool transparent_b_;
+  /**
+     Recursively track all dependencies of this Score_element.  The
+     status_i_ field is used as a mark-field.  It is marked with
+     #busy# during execution of this function, and marked with #final#
+     when finished.
 
-  int size_i_;
-  
-  // ugh: no protection. Denk na, Vrij Veilig
+     #funcptr# is the function to call to update this element.
+   */
   void calculate_dependencies (int final, int busy, Score_element_method_pointer funcptr);
 
-protected:
-  /**
-    Administration: Where are we?. This is mainly used by Super_element and
-    Score_element::calcalute_dependencies ()
+  static SCM handle_broken_smobs (SCM, SCM criterion);
+  void recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)());
 
-    0 means ORPHAN,
-    -1 means deleted
-    
-   */
-public:
-  int status_i_;
+  virtual void do_break_processing ();
+  virtual Score_element *find_broken_piece (Line_of_score*) const;
 protected:
-  Score_element* dependency (int) const;
-  Score_element* dependent (int) const;
-  int dependent_size () const;
-  int dependency_size () const;
+
+  /**
+    Junk score element. This is protected because this is supposed to
+    be handled by GUILE gc.  */
+  virtual ~Score_element ();
   
   virtual void output_processing ();
-  void junk_links ();
-  virtual Interval do_height () const;
-  virtual Interval do_width () const;
-    
+  static Interval molecule_extent (Dimension_cache const*);
+
   /// do printing of derived info.
-  virtual void do_print () const {}
+  virtual void do_print () const;
   /// generate the molecule    
   virtual Molecule* do_brew_molecule_p () const;
   ///executed directly after the item is added to the Paper_score
@@ -103,16 +134,59 @@ protected:
   /// do calculations after determining horizontal spacing
   virtual void do_post_processing ();
     
-  virtual void do_substitute_element_pointer (Score_element * , Score_element *);
-  virtual void do_break_processing ();
+  virtual Link_array<Score_element> get_extra_dependencies () const;
+
+  static Interval dim_cache_callback (Dimension_cache const*);
+public:
   virtual void handle_broken_dependencies ();
   virtual void handle_prebroken_dependencies ();
-  virtual void handle_prebroken_dependents ();
-  virtual Link_array<Score_element> get_extra_dependencies () const;
-  virtual void do_unlink ();
-  virtual void do_junk_links ();
+
+
+  DECLARE_SMOBS;
+
+  void init ();
+
+public:
+  Dimension_cache *dim_cache_[NO_AXES];
+
+  /**
+     Set this if anyone points to me, or if I point to anyone.
+   */
+  bool used_b_;
+  
+  char const * name () const;
+  /**
+     Set empty in direction A.
+   */
+  void set_empty (Axis a);
+  bool empty_b (Axis a) const;
+  Interval extent (Axis) const;
+  /**
+    translate in one direction
+    */
+    
+  void translate_axis (Real, Axis);
+
+  Real relative_coordinate (Score_element const* refp, Axis) const;
+  /**
+    Find the group-element which has both #this# and #s#
+   */
+  Score_element*common_refpoint (Score_element const* s, Axis a) const;
+  Score_element*common_refpoint (Link_array<Score_element> elems, Axis a) const;
+
+  /**
+     Set the  parent refpoint of THIS to E
+   */
+  void set_parent (Score_element* e, Axis);
+  
+  Score_element *parent_l (Axis a) const;
+  void fixup_refpoint ();
 };
 
+Score_element * unsmob_element (SCM);
+
+
 
 #endif // STAFFELEM_HH