]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/score-elem.hh
release: 0.0.73pre
[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     
78      /**
79       translate the symbol. The symbol does not have to be created yet. 
80       */
81     void translate(Offset);
82     Offset offset()const;
83
84     void add_processing();
85     void OK() const;
86     void pre_processing();
87     void breakable_col_processing();
88     void break_processing();
89     
90     void post_processing();
91     void molecule_processing();
92
93     void unlink();
94     void unlink_all();
95     void remove_dependency(Score_elem*);
96     /**
97       add a dependency. It may be the 0 pointer, in which case, it is ignored.
98      */
99     void add_dependency(Score_elem* );    
100     
101     
102     virtual Spanner* spanner()  { return 0; }
103     virtual Horizontal_vertical_group* elem_group() { return 0; }
104     virtual Item * item() { return 0; }
105     virtual Line_of_score * line_l() const;
106     SCORE_ELEM_CLONE(Score_elem);
107 protected:
108
109     virtual  Interval do_height()const;
110     virtual Interval do_width()const;
111     
112     /// do printing of derived info.
113     virtual void do_print() const {}
114     /// generate the molecule    
115     virtual Molecule* brew_molecule_p()const;
116     ///executed directly after the item is added to the PScore
117     virtual void do_add_processing();
118     /// do calculations before determining horizontal spacing
119     virtual void do_pre_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_dependency(Score_elem * , Score_elem *);
126     virtual void do_substitute_dependent(Score_elem *, Score_elem *);
127     virtual void do_break_processing();
128     virtual void handle_broken_dependencies();
129     virtual void handle_prebroken_dependencies();
130
131     Score_elem* dependency(int) const;
132     Score_elem* dependent(int) const;
133     int dependent_size() const;
134     int dependency_size() const;
135
136
137     /// no dimension, translation is noop
138     bool empty_b_;
139     /// do not print anything black
140     bool transparent_b_;
141 };
142
143
144 #endif // STAFFELEM_HH
145