]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-elem.hh
release: 0.0.76
[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 /** Both Spanner and Item are Score_elem's. Most Score_elem's depend
19   on other Score_elem's, eg, Beam needs to know and set direction of
20   Stem. So the Beam has to be calculated *before* Stem. This is
21   accomplished with the dependencies fields of struct Score_elem,
22   which are implemented in the Directed_graph_node class: all elements
23   form an acyclic graph.
24
25   (elem) */
26 class Score_elem : private Directed_graph_node {
27
28     /// member: the symbols
29     Molecule *output;           // should scrap, and use temp var?
30
31
32     /**
33       This is  needed, because #output# may still be
34       NULL.
35       */
36     Offset offset_;
37
38     /**
39       for administration of what was done already
40      */
41     enum Status {
42         ORPHAN,                 // not yet added to pstaff
43         VIRGIN,                 // added to pstaff
44         PREBREAKING,
45         PREBROKEN,
46         PRECALCING,
47         PRECALCED,              // calcs before spacing done
48         BREAKING,
49         BROKEN,
50         POSTCALCING,            // busy calculating. This is used to trap cyclic deps.
51         POSTCALCED,             // after spacing calcs done
52         OUTPUT,                 // molecule has been output
53         DELMARKED,              // mark for 'unclean' deletion
54         DELETED,                // to catch malloc mistakes.
55     };
56     
57     Status status_;
58
59 public:
60     PScore *pscore_l_;    
61     int x_group_element_i_;
62     int y_group_element_i_;
63     Score_elem(Score_elem const&);
64     virtual String TeX_string () const ;
65     virtual void print() const;
66     
67     Paper_def *paper() const;
68
69     virtual ~Score_elem();
70     Score_elem();
71     NAME_MEMBERS();    
72     
73     Interval width() const;
74     Interval height() const;
75     virtual void translate_x(Real);
76     virtual void translate_y(Real);
77     Status status() const;
78     
79      /**
80       translate the symbol. The symbol does not have to be created yet. 
81       */
82     void translate(Offset);
83     Offset offset()const;
84
85     void add_processing();
86     void OK() const;
87     void pre_processing();
88     void breakable_col_processing();
89     void break_processing();
90     
91     void post_processing();
92     void molecule_processing();
93
94     void unlink();
95     void unlink_all();
96     void substitute_dependency(Score_elem*,Score_elem*);
97     void remove_dependency(Score_elem*);
98     /**
99       add a dependency. It may be the 0 pointer, in which case, it is ignored.
100      */
101     void add_dependency(Score_elem* );    
102     
103     
104     virtual Spanner* spanner()  { return 0; }
105     virtual Horizontal_vertical_group* elem_group() { return 0; }
106     virtual Item * item() { return 0; }
107     virtual Line_of_score * line_l() const;
108     SCORE_ELEM_CLONE(Score_elem);
109     Score_elem* dependency(int) const;
110     Score_elem* dependent(int) const;
111     int dependent_size() const;
112     int dependency_size() const;
113     
114     /// no dimension, translation is noop
115     bool empty_b_;
116     /// do not print anything black
117     bool transparent_b_;
118 protected:
119
120     virtual  Interval do_height()const;
121     virtual Interval do_width()const;
122     
123     /// do printing of derived info.
124     virtual void do_print() const {}
125     /// generate the molecule    
126     virtual Molecule* brew_molecule_p()const;
127     ///executed directly after the item is added to the PScore
128     virtual void do_add_processing();
129     /// do calculations before determining horizontal spacing
130     virtual void do_pre_processing();
131
132     virtual void do_breakable_col_processing();
133     /// do calculations after determining horizontal spacing
134     virtual void do_post_processing();
135     
136     virtual void do_substitute_dependency(Score_elem * , Score_elem *);
137     virtual void do_substitute_dependent(Score_elem *, Score_elem *);
138     virtual void do_break_processing();
139     virtual void handle_broken_dependencies();
140     virtual void handle_prebroken_dependencies();
141
142
143
144 };
145
146
147 #endif // STAFFELEM_HH
148