]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/score-element.hh
release: 1.3.105
[lilypond.git] / lily / include / score-element.hh
index 919333c9a6edd79b22e52db776cc9cd4c01b9913..424a182932976f093dffb25dee832f73a39b55f7 100644 (file)
@@ -1,7 +1,7 @@
 /*
-  score-element.hh -- part of GNU LilyPond
+  score-element.hh -- declare Score_element
 
-  (c) 1996,97 Han-Wen Nienhuys
+  (c) 1996-1999--2000 Han-Wen Nienhuys
 */
 
 #ifndef STAFFELEM_HH
 
 #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"
+#include "dimension-cache.hh"
 
+/**
+    for administration of what was done already
+    */
+enum Score_element_status {
+  ORPHAN=0,                    // not yet added to Paper_score
+  VIRGIN,      
+  PRECALCING,
+  PRECALCED,           // calcs before spacing done
+  POSTCALCING,         // busy calculating. This is used to trap cyclic deps.
+  POSTCALCED,          // after spacing calcs done
+};
 
 typedef void (Score_element::*Score_element_method_pointer) (void);
 
-/** Both Spanner and Item are Score_element's. Most Score_element's depend
-  on other Score_element's, eg, Beam needs to know and set direction of
-  Stem. So the Beam has to be calculated *before* Stem. This is
-  accomplished with the dependencies fields of struct Score_element,
-  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 {
+/*
+   Basic output object.
+*/
+class Score_element  {
 public:
-  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;
+  SCM immutable_property_alist_;
+  SCM mutable_property_alist_;
+  Score_element *original_l_;
 
-  virtual ~Score_element ();
-      
+  /**
+    Administration: Where are we?. This is mainly used by Super_element and
+    Score_element::calcalute_dependencies ()
+
+    0 means ORPHAN,
+   */
+  char status_i_;
+  String name () const;
 
-  void add_processing ();
+  /*
+    IDEA: make this a global variable. This is the same for all
+    elements, I think it is safe to assume that we will not have
+    scores being formatted multithreadedly.
+   */
+  Paper_score *pscore_l_;
+
+  Score_element (SCM basic_props);
+  Score_element (Score_element const&);
+
+  /*
+    properties
+   */
+  SCM get_elt_property (const char*) const;
+  SCM get_elt_property (SCM) const;
+  void set_elt_property (const char * , SCM val);
+  void set_immutable_elt_property (const char * , SCM val);
+  void set_immutable_elt_property (SCM key, SCM val);  
+  void set_elt_property (SCM , SCM val);  
+  void set_elt_pointer (const char*, SCM val);
+  friend class Property_engraver; //  UGHUGHUGH.
+  SCM remove_elt_property (const char* nm);
+
+  /*
+    related classes.
+   */
+  Paper_def *paper_l () const;
 
-  /**
-    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.
+
+     #funcptr# is the function to call to update this element.
+   */
+  void calculate_dependencies (int final, int busy, SCM funcname);
+  static SCM handle_broken_smobs (SCM, SCM criterion);
+
+  virtual void do_break_processing ();
+  virtual Score_element *find_broken_piece (Line_of_score*) const;
+  virtual void discretionary_processing ();
+  virtual SCM do_derived_mark ();
 
-  int size_i_;
+  Molecule * get_molecule () const;
+  void suicide ();
   
-  // ugh: no protection. Denk na, Vrij Veilig
-  void calculate_dependencies (int final, int busy, Score_element_method_pointer funcptr);
+  DECLARE_SCHEME_CALLBACK(preset_extent, (SCM smob, SCM axis));
+  DECLARE_SCHEME_CALLBACK(point_dimension_callback, (SCM smob, SCM axis));
+  DECLARE_SCHEME_CALLBACK(molecule_extent, (SCM smob, SCM axis));
 
-protected:
-  /**
-    Administration: Where are we?. This is mainly used by Super_element and
-    Score_element::calcalute_dependencies ()
 
-    0 means ORPHAN,
-    -1 means deleted
+  static SCM ly_set_elt_property (SCM, SCM,SCM);
+  static SCM ly_get_elt_property (SCM, SCM);  
+
+  bool has_interface (SCM intf);
+  void set_interface (SCM intf);
+
+  virtual void handle_broken_dependencies ();
+  virtual void handle_prebroken_dependencies ();
+
+
+  DECLARE_SMOBS(Score_element,foo);
+
+  void init ();
+
+  Dimension_cache dim_cache_[NO_AXES];
+
+public:
+  bool empty_b (Axis a) const;
+
+  Interval extent (Score_element * refpoint, Axis) const;
+  /**
+    translate in one direction
+    */
     
+  void translate_axis (Real, Axis);
+
+  /**
+     Find the offset relative to D.  If   D equals THIS, then it is 0.
+     Otherwise, it recursively defd as
+
+     OFFSET_ + PARENT_L_->relative_coordinate (D)
    */
-public:
-  int status_i_;
-protected:
-  Score_element* dependency (int) const;
-  Score_element* dependent (int) const;
-  int dependent_size () const;
-  int dependency_size () const;
+  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 (SCM elt_list, Axis a) const;
+
+  // duh. slim down interface here. (todo)
+  bool has_offset_callback_b (SCM callback, Axis)const;
+  void add_offset_callback (SCM callback, Axis);
+  bool has_extent_callback_b (SCM, Axis)const;  
+  void set_extent_callback (SCM , Axis);
+  bool has_extent_callback_b (Axis) const;
+
   
-  virtual void output_processing ();
-  void junk_links ();
-  virtual Interval do_height () const;
-  virtual Interval do_width () const;
-    
-  /// do printing of derived info.
-  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
-  virtual void do_add_processing ();
-  /// do calculations before determining horizontal spacing
-  virtual void do_pre_processing ();
-
-  /// generate rods & springs
-  virtual void do_space_processing ();
-
-  virtual void do_breakable_col_processing ();
-  /// do calculations after determining horizontal spacing
-  virtual void do_post_processing ();
-    
-  virtual void do_substitute_dependency (Score_element * , Score_element *);
-  virtual void do_substitute_dependent (Score_element *, Score_element *);
-  virtual void do_break_processing ();
-  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 ();
+  /**
+    Invoke callbacks to get offset relative to parent.
+   */
+  Real get_offset (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;
+  DECLARE_SCHEME_CALLBACK(fixup_refpoint, (SCM));
 };
 
+Score_element * unsmob_element (SCM);
 
 #endif // STAFFELEM_HH