]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-element.hh
2a0a7805eff19ad5e42a1055bdf7db684e571f45
[lilypond.git] / lily / include / score-element.hh
1 /*
2   score-element.hh -- declare Score_element
3
4   (c) 1996-1999 Han-Wen Nienhuys
5 */
6
7 #ifndef STAFFELEM_HH
8 #define STAFFELEM_HH
9
10 #include "parray.hh"
11 #include "virtual-methods.hh"
12 #include "directed-graph.hh"
13 #include "graphical-element.hh"
14 #include "lily-guile.hh"
15
16
17 typedef void (Score_element::*Score_element_method_pointer) (void);
18
19 /** Both Spanner and Item are Score_element's. Most Score_element's depend
20   on other Score_element's, eg, Beam needs to know and set direction of
21   Stem. So the Beam has to be calculated *before* Stem. This is
22   accomplished with the dependencies fields of struct Score_element,
23   which are implemented in the Directed_graph_node class: all elements
24   form an acyclic graph.
25
26   (elem)
27
28
29 Element Properties:
30
31 Boolean (true iff defined)
32
33  break_helper_only -- if defined try to junk this after calcing breakpoints.
34
35  transparent -- do not calc. output
36
37 */
38 class Score_element : public virtual Graphical_element {
39
40   friend class Paper_score;
41   /**
42      properties specific for this element. Destructor will not call
43      scm_unprotect, so as to allow more flexible GC arrangements.  The
44      real alist is in (cdr element_property_alist_), to reduce the
45      need for more scm_protect calls.
46
47   */
48   SCM element_property_alist_;
49   Link_array<Score_element> dependency_arr_;
50   /**
51      The lookup, determined by the font size. Cache this value.
52    */
53   Lookup * lookup_l_;
54 public:
55   Score_element *original_l_;
56
57   /**
58     Administration: Where are we?. This is mainly used by Super_element and
59     Score_element::calcalute_dependencies ()
60
61     0 means ORPHAN,
62     -1 means deleted
63     
64    */
65   int status_i_;
66
67   Paper_score *pscore_l_;
68   Molecule * output_p_;
69   Score_element ();
70   Score_element (Score_element const&);
71   virtual void print () const;
72
73   /*
74     properties
75    */
76   SCM get_elt_property (SCM sym) const;
77   void set_elt_property (SCM sym, SCM val);
78   SCM remove_elt_property (SCM key);
79
80   /*
81     related classes.
82    */
83   Paper_def *paper_l () const;
84   Lookup const *lookup_l () const;
85
86   virtual ~Score_element ();
87   void add_processing ();
88
89   void substitute_dependency (Score_element*,Score_element*);
90   void remove_dependency (Score_element*);
91   /**
92     add a dependency. It may be the 0 pointer, in which case, it is ignored.
93     */
94   void add_dependency (Score_element*);    
95   virtual Line_of_score * line_l () const;
96   bool linked_b () const;
97   VIRTUAL_COPY_CONS(Score_element);
98  
99   /**
100      Recursively track all dependencies of this Score_element.  The
101      status_i_ field is used as a mark-field.  It is marked with
102      #busy# during execution of this function, and marked with #final#
103      when finished.
104
105      #funcptr# is the function to call to update this element.
106    */
107   void calculate_dependencies (int final, int busy, Score_element_method_pointer funcptr);
108
109 protected:
110   Score_element* dependency (int) const;
111   int dependency_size () const;
112   
113   virtual void output_processing ();
114   virtual Interval do_height () const;
115   virtual Interval do_width () const;
116     
117   /// do printing of derived info.
118   virtual void do_print () const;
119   /// generate the molecule    
120   virtual Molecule* do_brew_molecule_p () const;
121   ///executed directly after the item is added to the Paper_score
122   virtual void do_add_processing ();
123   /// do calculations before determining horizontal spacing
124   virtual void do_pre_processing ();
125
126   /// generate rods & springs
127   virtual void do_space_processing ();
128
129   virtual void do_breakable_col_processing ();
130   /// do calculations after determining horizontal spacing
131   virtual void do_post_processing ();
132     
133   virtual void do_substitute_element_pointer (Score_element * , Score_element *);
134   virtual void do_break_processing ();
135   virtual void handle_broken_dependencies ();
136   virtual void handle_prebroken_dependencies ();
137   virtual void handle_prebroken_dependents ();
138   virtual Link_array<Score_element> get_extra_dependencies () const;
139
140   static Interval dim_cache_callback (Dimension_cache*);
141 };
142
143
144 #endif // STAFFELEM_HH
145