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