]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-elem.hh
7e7259f6a25320b1fb9549e0c6b4232b56852c9b
[lilypond.git] / lily / include / score-elem.hh
1 /*
2   score-elem.hh -- part of GNU LilyPond
3
4   (c) 1996,97 Han-Wen Nienhuys
5 */
6
7 #ifndef STAFFELEM_HH
8 #define STAFFELEM_HH
9
10 #include "parray.hh"
11 #include "lily-proto.hh"
12 #include "offset.hh"
13 #include "virtual-methods.hh"
14 #include "directed-graph.hh"
15
16 #define SCORE_ELEM_CLONE(T) VIRTUAL_COPY_CONS(T, Score_elem)
17
18
19
20 /** Both Spanner and Item are Score_elem's. Most Score_elem's depend
21   on other Score_elem'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_elem,
24   which are implemented in the Directed_graph_node class: all elements
25   form an acyclic graph.
26
27   (elem) */
28 class Score_elem : private Directed_graph_node {
29
30     /// member: the symbols
31     Molecule *output;           // should scrap, and use temp var?
32
33
34
35     /**
36       for administration of what was done already
37      */
38     enum Status {
39         ORPHAN,                 // not yet added to pstaff
40         VIRGIN,                 // added to pstaff
41         PREBREAKING,
42         PREBROKEN,
43         PRECALCING,
44         PRECALCED,              // calcs before spacing done
45         BREAKING,
46         BROKEN,
47         POSTCALCING,            // busy calculating. This is used to trap cyclic deps.
48         POSTCALCED,             // after spacing calcs done
49         OUTPUT,                 // molecule has been output
50         DELMARKED,              // mark for 'unclean' deletion
51         DELETED,                // to catch malloc mistakes.
52     };
53     
54     Status status_;
55
56     Score_elem* dependency (int) const;
57     Score_elem* dependent (int) const;
58     int dependent_size() const;
59     int dependency_size() const;
60 public:
61     /**
62       This is  needed, because #output# may still be
63       NULL.
64       */
65     Offset offset_;
66
67
68
69
70     Paper_score *pscore_l_;    
71     Axis_group_element * axis_group_l_a_[2];
72
73     Score_elem (Score_elem const&);
74     virtual String TeX_string() const ;
75     String TeX_string_without_offset (Offset)const;
76     virtual void print() const;
77     
78     Paper_def *paper() const;
79
80     virtual ~Score_elem();
81     Score_elem();
82     DECLARE_MY_RUNTIME_TYPEINFO;    
83     
84     Interval extent (Axis)const;
85     Interval width() const;
86     Interval height() const;
87     Status status() const;
88     
89      /**
90       translate the symbol. The symbol does not have to be created yet. 
91       */
92     void translate (Offset);
93     /**
94       translate in one direction
95      */
96     
97     void translate (Real, Axis);
98     Real relative_coordinate (Axis_group_element*, Axis)const;
99     Offset absolute_offset()const;
100     Real absolute_coordinate (Axis)const;
101     Axis_group_element*common_group (Score_elem const* s, Axis a)const;
102
103     void add_processing();
104     void OK() const;
105     void pre_processing();
106     void breakable_col_processing();
107     void break_processing();
108     
109     void post_processing();
110     void molecule_processing();
111
112     /**
113       Remove all  links (dependencies, dependents, Axis_group_elements.
114      */
115     void unlink();
116     void unlink_all();
117     void substitute_dependency (Score_elem*,Score_elem*);
118     void remove_dependency (Score_elem*);
119     /**
120       add a dependency. It may be the 0 pointer, in which case, it is ignored.
121      */
122     void add_dependency (Score_elem*);    
123     void copy_dependencies (Score_elem const&);
124     /**
125       junk the dependency array. Don't do derived stuff.
126      */
127     void junk_dependencies();
128     
129
130     /*
131       virtual accessors
132      */
133
134     virtual Spanner* spanner()  { return 0; }
135     virtual Item * item() { return 0; }
136     virtual Line_of_score * line_l() const;
137     SCORE_ELEM_CLONE(Score_elem);
138  
139     /// no dimension, translation is noop
140     bool empty_b_;
141     /// do not print anything black
142     bool transparent_b_;
143 protected:
144
145     virtual  Interval do_height()const;
146     virtual Interval do_width()const;
147     
148     /// do printing of derived info.
149     virtual void do_print() const {}
150     /// generate the molecule    
151     virtual Molecule* brew_molecule_p()const;
152     ///executed directly after the item is added to the Paper_score
153     virtual void do_add_processing();
154     /// do calculations before determining horizontal spacing
155     virtual void do_pre_processing();
156
157     virtual void do_breakable_col_processing();
158     /// do calculations after determining horizontal spacing
159     virtual void do_post_processing();
160     
161     virtual void do_substitute_dependency (Score_elem * , Score_elem *);
162     virtual void do_substitute_dependent (Score_elem *, Score_elem *);
163     virtual void do_break_processing();
164     virtual void handle_broken_dependencies();
165     virtual void handle_prebroken_dependencies();
166     virtual Link_array<Score_elem> get_extra_dependencies()const;
167     virtual void do_unlink();
168 };
169
170
171 #endif // STAFFELEM_HH
172