XcodeでQuartz Composer Applicationを選択
Introduction.qtzを編集
CounterのInputを3つともPublish.
AppController.hを編集#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
@interface AppController : NSObject
{
IBOutlet QCView* qcView;
}
- (IBAction)increase:(id)sender;
- (IBAction)decrease:(id)sender;
- (IBAction)reset:(id)sender;
@end
AppController.mを編集#import "AppController.h"
@implementation AppController
- (void) awakeFromNib
{
if(![qcView loadCompositionFromFile:[[NSBundle mainBundle] pathForResource:@"Introduction" ofType:@"qtz"]]) {
NSLog(@"Could not load composition");
}
}
- (void)windowWillClose:(NSNotification *)notification
{
[NSApp terminate:self];
}
- (IBAction)increase:(id)sender
{
[qcView setValue:[NSNumber numberWithBool:YES] forInputKey:@"Increasing_Signal"];
[self performSelector:@selector(endEvent:) withObject:nil afterDelay:0.1];
}
- (IBAction)decrease:(id)sender
{
[qcView setValue:[NSNumber numberWithBool:YES] forInputKey:@"Decreasing_Signal"];
[self performSelector:@selector(endEvent:) withObject:nil afterDelay:0.1];
}
- (IBAction)reset:(id)sender
{
[qcView setValue:[NSNumber numberWithBool:YES] forInputKey:@"Reset_Signal"];
[self performSelector:@selector(endEvent:) withObject:nil afterDelay:0.1];
}
- (void)endEvent:(id)obj
{
[qcView setValue:[NSNumber numberWithBool:NO] forInputKey:@"Increasing_Signal"];
[qcView setValue:[NSNumber numberWithBool:NO] forInputKey:@"Decreasing_Signal"];
[qcView setValue:[NSNumber numberWithBool:NO] forInputKey:@"Reset_Signal"];
}
@end
MainMenu.xibを編集
'+'をAppControllerのincrease, '-'をAppControllerのdecrease, 'Clear'をAppControllerのresetへ接続.
結果
とりあえず動いたけどパルス的なSignalってこうやっていれるしか無いのかしら?
サンプル探せばもっと賢いのがあるんだろうなぁ…。
0 件のコメント:
コメントを投稿