Mercurial > projects > dstep
comparison dstep/appkit/NSAnimation.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSAnimation; | |
8 | |
9 import dstep.appkit.AppKitDefines; | |
10 import dstep.appkit.NSGraphicsContext; | |
11 import dstep.foundation.NSArray; | |
12 import dstep.foundation.NSCoder; | |
13 import dstep.foundation.NSDictionary; | |
14 import dstep.foundation.NSObjCRuntime; | |
15 import dstep.foundation.NSObject; | |
16 import dstep.foundation.NSString; | |
17 import dstep.foundation.NSTimer; | |
18 import dstep.foundation.NSString; | |
19 import dstep.foundation.NSZone; | |
20 import dstep.objc.bridge.Bridge; | |
21 import dstep.objc.objc; | |
22 | |
23 import bindings = dstep.appkit.NSAnimation_bindings; | |
24 | |
25 alias NSUInteger NSAnimationCurve; | |
26 alias NSUInteger NSAnimationBlockingMode; | |
27 alias float NSAnimationProgress; | |
28 | |
29 private | |
30 { | |
31 NSString NSAnimationProgressMarkNotification_; | |
32 NSString NSAnimationProgressMark_; | |
33 NSString NSViewAnimationTargetKey_; | |
34 NSString NSViewAnimationStartFrameKey_; | |
35 NSString NSViewAnimationEndFrameKey_; | |
36 NSString NSViewAnimationEffectKey_; | |
37 NSString NSViewAnimationFadeInEffect_; | |
38 NSString NSViewAnimationFadeOutEffect_; | |
39 NSString NSAnimationTriggerOrderIn_; | |
40 NSString NSAnimationTriggerOrderOut_; | |
41 } | |
42 | |
43 NSString NSAnimationProgressMarkNotification () | |
44 { | |
45 if (NSAnimationProgressMarkNotification_) | |
46 return NSAnimationProgressMarkNotification_; | |
47 | |
48 return NSAnimationProgressMarkNotification_ = new NSString(bindings.NSAnimationProgressMarkNotification); | |
49 } | |
50 | |
51 NSString NSAnimationProgressMark () | |
52 { | |
53 if (NSAnimationProgressMark_) | |
54 return NSAnimationProgressMark_; | |
55 | |
56 return NSAnimationProgressMark_ = new NSString(bindings.NSAnimationProgressMark); | |
57 } | |
58 | |
59 NSString NSViewAnimationTargetKey () | |
60 { | |
61 if (NSViewAnimationTargetKey_) | |
62 return NSViewAnimationTargetKey_; | |
63 | |
64 return NSViewAnimationTargetKey_ = new NSString(bindings.NSViewAnimationTargetKey); | |
65 } | |
66 | |
67 NSString NSViewAnimationStartFrameKey () | |
68 { | |
69 if (NSViewAnimationStartFrameKey_) | |
70 return NSViewAnimationStartFrameKey_; | |
71 | |
72 return NSViewAnimationStartFrameKey_ = new NSString(bindings.NSViewAnimationStartFrameKey); | |
73 } | |
74 | |
75 NSString NSViewAnimationEndFrameKey () | |
76 { | |
77 if (NSViewAnimationEndFrameKey_) | |
78 return NSViewAnimationEndFrameKey_; | |
79 | |
80 return NSViewAnimationEndFrameKey_ = new NSString(bindings.NSViewAnimationEndFrameKey); | |
81 } | |
82 | |
83 NSString NSViewAnimationEffectKey () | |
84 { | |
85 if (NSViewAnimationEffectKey_) | |
86 return NSViewAnimationEffectKey_; | |
87 | |
88 return NSViewAnimationEffectKey_ = new NSString(bindings.NSViewAnimationEffectKey); | |
89 } | |
90 | |
91 NSString NSViewAnimationFadeInEffect () | |
92 { | |
93 if (NSViewAnimationFadeInEffect_) | |
94 return NSViewAnimationFadeInEffect_; | |
95 | |
96 return NSViewAnimationFadeInEffect_ = new NSString(bindings.NSViewAnimationFadeInEffect); | |
97 } | |
98 | |
99 NSString NSViewAnimationFadeOutEffect () | |
100 { | |
101 if (NSViewAnimationFadeOutEffect_) | |
102 return NSViewAnimationFadeOutEffect_; | |
103 | |
104 return NSViewAnimationFadeOutEffect_ = new NSString(bindings.NSViewAnimationFadeOutEffect); | |
105 } | |
106 | |
107 NSString NSAnimationTriggerOrderIn () | |
108 { | |
109 if (NSAnimationTriggerOrderIn_) | |
110 return NSAnimationTriggerOrderIn_; | |
111 | |
112 return NSAnimationTriggerOrderIn_ = new NSString(bindings.NSAnimationTriggerOrderIn); | |
113 } | |
114 | |
115 NSString NSAnimationTriggerOrderOut () | |
116 { | |
117 if (NSAnimationTriggerOrderOut_) | |
118 return NSAnimationTriggerOrderOut_; | |
119 | |
120 return NSAnimationTriggerOrderOut_ = new NSString(bindings.NSAnimationTriggerOrderOut); | |
121 } | |
122 | |
123 enum | |
124 { | |
125 NSAnimationEaseInOut, | |
126 NSAnimationEaseIn, | |
127 NSAnimationEaseOut, | |
128 NSAnimationLinear | |
129 } | |
130 | |
131 enum | |
132 { | |
133 NSAnimationBlocking, | |
134 NSAnimationNonblocking, | |
135 NSAnimationNonblockingThreaded | |
136 } | |
137 | |
138 class NSAnimation : NSObject, INSCopying, INSCoding | |
139 { | |
140 mixin (ObjcWrap); | |
141 | |
142 this (NSCoder aDecoder) | |
143 { | |
144 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); | |
145 } | |
146 | |
147 void encodeWithCoder (NSCoder aCoder) | |
148 { | |
149 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
150 } | |
151 | |
152 typeof(this) initWithCoder (NSCoder aDecoder) | |
153 { | |
154 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); | |
155 } | |
156 | |
157 typeof(this) copyWithZone (NSZone* zone) | |
158 { | |
159 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); | |
160 } | |
161 | |
162 NSAnimation initWithDuration (double duration, uint animationCurve) | |
163 { | |
164 id result = invokeObjcSelf!(id, "initWithDuration:animationCurve:", double, uint)(duration, animationCurve); | |
165 return result is this.objcObject ? this : (result !is null ? new NSAnimation(result) : null); | |
166 } | |
167 | |
168 this (double duration, uint animationCurve) | |
169 { | |
170 super(NSAnimation.alloc.initWithDuration(duration, animationCurve).objcObject); | |
171 } | |
172 | |
173 void startAnimation () | |
174 { | |
175 return invokeObjcSelf!(void, "startAnimation"); | |
176 } | |
177 | |
178 void stopAnimation () | |
179 { | |
180 return invokeObjcSelf!(void, "stopAnimation"); | |
181 } | |
182 | |
183 bool isAnimating () | |
184 { | |
185 return invokeObjcSelf!(bool, "isAnimating"); | |
186 } | |
187 | |
188 float currentProgress () | |
189 { | |
190 return invokeObjcSelf!(float, "currentProgress"); | |
191 } | |
192 | |
193 void setCurrentProgress (float progress) | |
194 { | |
195 return invokeObjcSelf!(void, "setCurrentProgress:", float)(progress); | |
196 } | |
197 | |
198 void setDuration (double duration) | |
199 { | |
200 return invokeObjcSelf!(void, "setDuration:", double)(duration); | |
201 } | |
202 | |
203 double duration () | |
204 { | |
205 return invokeObjcSelf!(double, "duration"); | |
206 } | |
207 | |
208 uint animationBlockingMode () | |
209 { | |
210 return invokeObjcSelf!(uint, "animationBlockingMode"); | |
211 } | |
212 | |
213 void setAnimationBlockingMode (uint animationBlockingMode) | |
214 { | |
215 return invokeObjcSelf!(void, "setAnimationBlockingMode:", uint)(animationBlockingMode); | |
216 } | |
217 | |
218 void setFrameRate (float framesPerSecond) | |
219 { | |
220 return invokeObjcSelf!(void, "setFrameRate:", float)(framesPerSecond); | |
221 } | |
222 | |
223 float frameRate () | |
224 { | |
225 return invokeObjcSelf!(float, "frameRate"); | |
226 } | |
227 | |
228 void setAnimationCurve (uint curve) | |
229 { | |
230 return invokeObjcSelf!(void, "setAnimationCurve:", uint)(curve); | |
231 } | |
232 | |
233 uint animationCurve () | |
234 { | |
235 return invokeObjcSelf!(uint, "animationCurve"); | |
236 } | |
237 | |
238 float currentValue () | |
239 { | |
240 return invokeObjcSelf!(float, "currentValue"); | |
241 } | |
242 | |
243 void setDelegate (Object delegate_) | |
244 { | |
245 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
246 } | |
247 | |
248 Object delegate_ () | |
249 { | |
250 return invokeObjcSelf!(Object, "delegate"); | |
251 } | |
252 | |
253 NSArray progressMarks () | |
254 { | |
255 return invokeObjcSelf!(NSArray, "progressMarks"); | |
256 } | |
257 | |
258 void setProgressMarks (NSArray progressMarks) | |
259 { | |
260 return invokeObjcSelf!(void, "setProgressMarks:", NSArray)(progressMarks); | |
261 } | |
262 | |
263 void addProgressMark (float progressMark) | |
264 { | |
265 return invokeObjcSelf!(void, "addProgressMark:", float)(progressMark); | |
266 } | |
267 | |
268 void removeProgressMark (float progressMark) | |
269 { | |
270 return invokeObjcSelf!(void, "removeProgressMark:", float)(progressMark); | |
271 } | |
272 | |
273 void startWhenAnimation (NSAnimation animation, float startProgress) | |
274 { | |
275 return invokeObjcSelf!(void, "startWhenAnimation:reachesProgress:", NSAnimation, float)(animation, startProgress); | |
276 } | |
277 | |
278 void stopWhenAnimation (NSAnimation animation, float stopProgress) | |
279 { | |
280 return invokeObjcSelf!(void, "stopWhenAnimation:reachesProgress:", NSAnimation, float)(animation, stopProgress); | |
281 } | |
282 | |
283 void clearStartAnimation () | |
284 { | |
285 return invokeObjcSelf!(void, "clearStartAnimation"); | |
286 } | |
287 | |
288 void clearStopAnimation () | |
289 { | |
290 return invokeObjcSelf!(void, "clearStopAnimation"); | |
291 } | |
292 | |
293 NSArray runLoopModesForAnimating () | |
294 { | |
295 return invokeObjcSelf!(NSArray, "runLoopModesForAnimating"); | |
296 } | |
297 | |
298 } | |
299 | |
300 class NSViewAnimation : NSAnimation | |
301 { | |
302 mixin (ObjcWrap); | |
303 | |
304 NSViewAnimation initWithViewAnimations (NSArray viewAnimations) | |
305 { | |
306 id result = invokeObjcSelf!(id, "initWithViewAnimations:", NSArray)(viewAnimations); | |
307 return result is this.objcObject ? this : (result !is null ? new NSViewAnimation(result) : null); | |
308 } | |
309 | |
310 this (NSArray viewAnimations) | |
311 { | |
312 super(NSViewAnimation.alloc.initWithViewAnimations(viewAnimations).objcObject); | |
313 } | |
314 | |
315 NSArray viewAnimations () | |
316 { | |
317 return invokeObjcSelf!(NSArray, "viewAnimations"); | |
318 } | |
319 | |
320 void setViewAnimations (NSArray viewAnimations) | |
321 { | |
322 return invokeObjcSelf!(void, "setViewAnimations:", NSArray)(viewAnimations); | |
323 } | |
324 } | |
325 | |
326 interface INSAnimatablePropertyContainer | |
327 { | |
328 Object animator (); | |
329 NSDictionary animations (); | |
330 void setAnimations (NSDictionary dict); | |
331 Object animationForKey (NSString key); | |
332 static Object defaultAnimationForKey (NSString key); | |
333 } | |
334 | |
335 const TNSAnimationDelegate = ` | |
336 | |
337 bool animationShouldStart (NSAnimation animation) | |
338 { | |
339 return invokeObjcSelf!(bool, "animationShouldStart:", NSAnimation)(animation); | |
340 } | |
341 | |
342 void animationDidStop (NSAnimation animation) | |
343 { | |
344 return invokeObjcSelf!(void, "animationDidStop:", NSAnimation)(animation); | |
345 } | |
346 | |
347 void animationDidEnd (NSAnimation animation) | |
348 { | |
349 return invokeObjcSelf!(void, "animationDidEnd:", NSAnimation)(animation); | |
350 } | |
351 | |
352 float animation (NSAnimation animation, float progress) | |
353 { | |
354 return invokeObjcSelf!(float, "animation:valueForProgress:", NSAnimation, float)(animation, progress); | |
355 } | |
356 | |
357 void animation (NSAnimation animation, float progress) | |
358 { | |
359 return invokeObjcSelf!(void, "animation:didReachProgressMark:", NSAnimation, float)(animation, progress); | |
360 } | |
361 | |
362 //mixin ObjcBindMethod!(animationShouldStart, "animationShouldStart:"); | |
363 //mixin ObjcBindMethod!(animationDidStop, "animationDidStop:"); | |
364 //mixin ObjcBindMethod!(animationDidEnd, "animationDidEnd:"); | |
365 //mixin ObjcBindMethod!(animation, "animation:valueForProgress:"); | |
366 //mixin ObjcBindMethod!(animation, "animation:didReachProgressMark:"); | |
367 | |
368 `; | |
369 |