]> git.donarmstrong.com Git - lilypond.git/blob - hdr/request.hh
release: 0.0.22
[lilypond.git] / hdr / request.hh
1 // LilyPond's second egg of columbus!
2 #ifndef REQUEST_HH
3 #define REQUEST_HH
4
5 #include "glob.hh"
6 #include "string.hh"
7 #include "moment.hh"
8
9 /// a voice element wants something printed
10 struct Request {
11     Voice_element*elt_l_;
12     
13     /****************/
14
15     Request();
16     Request(Request const&);
17     virtual ~Request(){}
18
19     virtual void print()const ;
20     virtual Moment duration() const { return 0.0; }
21     virtual Request* clone() const =0;
22
23     /*  accessors for children */
24     virtual Barcheck_req *barcheck() { return 0; }
25     virtual Note_req *note() {return 0;}
26     virtual Script_req *script() {return 0;}
27     virtual Stem_req *stem() {return 0;}
28     virtual Text_req*text() { return 0; }
29     virtual Rest_req *rest() {return 0;}
30     virtual Span_req *span() {return 0;}
31     virtual Beam_req *beam() { return 0 ; }
32     virtual Slur_req *slur() { return 0 ; }
33     virtual Rhythmic_req*rhythmic() { return 0; }
34     virtual Melodic_req *melodic() { return 0; }
35 };
36
37 /**
38 see lilygut page
39  */
40         
41 struct Barcheck_req : Request {
42     virtual Barcheck_req *barcheck() { return this; }
43     void print ()const;
44     Request*clone() const;
45 };
46
47 /// a request with a duration
48 struct Rhythmic_req : virtual Request {
49     int balltype;
50     int dots;
51     Moment plet_factor;
52     /****************/
53
54     Moment duration() const;
55     Rhythmic_req();
56     Rhythmic_req*rhythmic() { return this;}
57     void print ()const;
58     Request*clone() const;
59 };
60
61
62 struct Melodic_req :virtual  Request
63 {
64     /// 0 is c
65     int name;
66     int octave;
67     int accidental;
68     bool forceacc;
69
70     // return height from central c (in halflines)
71     int height()const; 
72     Melodic_req();
73     Melodic_req*melodic() { return this;}
74     virtual void print() const;
75     Request*clone() const;
76 };
77
78 /// Put a note of specified type, height, and with accidental on the staff.
79 struct Note_req : Rhythmic_req, virtual Melodic_req {
80     Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
81     
82     Note_req*note() { return this;}
83     virtual void print() const;
84     Request*clone() const;
85 };
86 /**
87 */
88
89
90 ///Put a rest on the staff.
91 struct Rest_req : Rhythmic_req {
92
93     void print()const;
94
95     Rest_req * rest() { return this;}
96     Request*clone() const ;
97 };
98 /**
99 Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
100 */
101
102 /// attach a stem to the noteball
103 struct Stem_req : Request {
104     /// 4,8,16, ..
105     int stem_number;
106
107     virtual Stem_req *stem() {return this;}
108     Stem_req(int s) { stem_number = s; }
109     Request*clone() const;
110 };
111
112 /// requests to start or stop something.
113 struct Span_req : Request {
114     /// should the spanner start or stop, or is it unwanted?
115     enum {
116         NOSPAN, START, STOP
117     } spantype ;
118
119     virtual void print() const;
120     Span_req*span() { return this; }
121     Span_req();
122     virtual Request*clone()const;
123 };
124 /**
125  This type of request typically results in the creation of a #Spanner#
126 */
127
128
129 ///Start / stop a beam at this note.
130 struct Beam_req : Span_req {
131     int nplet;
132
133     /****************/
134     
135     Beam_req();
136     virtual Beam_req * beam() { return this; }
137     virtual Request*clone()const;
138 };
139 /**   if #nplet# is set, the staff will try to put an
140 appropriate number over the beam
141     */
142
143 /// a slur
144 struct Slur_req : Span_req {
145
146     virtual Request*clone()const;
147     virtual Slur_req*slur() { return this; }
148 };
149
150
151 ///Put a script above or below this ``note''    
152 struct Script_req : Request {
153     int dir;
154     Script_def *scriptdef;
155
156     /****************/
157     Script_req*script() { return this; }
158     virtual void print() const;
159     Request *clone()const;
160     Script_req(int d, Script_def*);
161     ~Script_req();
162     Script_req(Script_req const&);
163 };
164 /** eg upbow, downbow. Why a request? These symbols may conflict with
165 slurs and brackets, so this also a request */
166
167
168 ///Put a text above or below (?) this staff.
169 struct Text_req : Request {
170     int dir;
171     Text_def *spec;
172     /****************/
173     Text_req*text() { return this; }
174     virtual void print() const;
175     Request *clone()const;
176     Text_req(int d, Text_def*);
177     ~Text_req();
178     Text_req(Text_req const&);
179 };
180
181
182 #if 0
183
184 ///Put a lyric above or below (?) this staff.
185 struct Lyric_req : Request {
186     String text;
187 };
188
189
190
191 ///Draw a (Guitar) chord above or below this ``note''
192 struct Chord : Request {
193         // don't know how this looks.
194 };
195 /**
196 Why a request?
197 Because everything else is done in requests.
198 */
199
200
201 /// for absolute dynamics
202 enum Loudness {
203     FFF, FF, F, MF, MP, P, PP, PPP
204 } ;
205
206
207 ///Start / stop a slur or a bracket.
208 struct Bracket_req : Span_req {
209     int nplet;                  // print a number over the beam.
210 };
211
212 /**
213 Start/stop a bracket at this note. if #nplet# is set, the staff will
214 try to put an appropriate number over the bracket
215 */
216
217 struct Subtle_request {
218     Moment subtime;
219 };
220
221 /// helper in the hierarchy
222 struct Dynamic:Subtle_request {
223
224 };
225 /** Each dynamic is bound to one note ( a crescendo spanning multiple
226     notes is thought to be made of two "dynamics": a start and a stop).
227     Dynamic changes can occur in a smaller time than the length of its
228     note, therefore fore each Dynamic request carries a time, measured
229     from the start of its note.
230
231     This subfield would come in handy, if mpp96 was adapted for midi
232     support.
233     
234     Dynamic should have been derived from request, but I don't want to
235     fuss with virtual baseclasses.  */
236
237 /// do a crescendo
238 struct Cresc_req : Span_req, Dynamic {
239     
240 };
241
242 /// do a decrescendo
243 struct Decresc_req : Span_req, Dynamic {
244     
245 };
246
247 /// do a dynamic like "fff" or "mp"
248 struct Absdynamic_req : Request, Dynamic {
249     Loudness loudness;
250 };
251
252 struct Grace_req : Subtle_request {
253     
254 };
255
256 struct Grace_turn_req : Grace_turn {
257     
258 };
259
260 struct Grace_note : Melodic_req {
261     
262 };
263
264 struct Grace_notes {
265     
266 };
267 #endif
268 #endif