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