/
AppController.m
149 lines (111 loc) · 3.29 KB
/
AppController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// AppController.m
// Animated Mandelbrot
//
// Created by Jon Stacey on 2/7/09.
// Copyright 2009 Jon Stacey. All rights reserved.
//
#import "AppController.h"
#import "ControlsController.h"
@implementation AppController
#pragma mark -
#pragma mark Initialization Methods
// -------------------------------------------------------------------------------
// Initialization Methods
// -------------------------------------------------------------------------------
- (id)init
{
if (self != [super init])
return nil;
// Set maximum and minimum default values
minMaxDwell = 128;
maxMaxDwell = 16384;
minEscapeRadius = 2;
maxEscapeRadius = 128;
minFrameRate = 1;
maxFrameRate = 99;
minDuration = 1;
maxDuration = 999;
return self;
}
#pragma mark -
#pragma mark Validation Delegate Methods
// -------------------------------------------------------------------------------
// Validates maxDwell
// -------------------------------------------------------------------------------
- (BOOL)validateMaxDwell:(id *)ioValue
error:(NSError **)outError
{
int value = [*ioValue intValue];
[self willChangeValueForKey:@"maxDwell"];
debug_NSLog(@"Changing maxDwell");
if (value < minMaxDwell)
maxDwell = minMaxDwell;
else if (value > maxMaxDwell)
maxDwell = maxMaxDwell;
else
maxDwell = value;
[self didChangeValueForKey:@"maxDwell"];
return YES;
}
// -------------------------------------------------------------------------------
// Validates escapeRadius
// -------------------------------------------------------------------------------
- (BOOL)validateEscapeRadius:(id *)ioValue
error:(NSError **)outError
{
int value = [*ioValue intValue];
[self willChangeValueForKey:@"escapeRadius"];
debug_NSLog(@"Changing escapeRadius");
if (value < minEscapeRadius)
escapeRadius = minEscapeRadius;
else if (value > maxEscapeRadius)
escapeRadius = maxEscapeRadius;
else
escapeRadius = value;
[self didChangeValueForKey:@"escapeRadius"];
return YES;
}
// -------------------------------------------------------------------------------
// Validates frameRate
// -------------------------------------------------------------------------------
- (BOOL)validateFrameRate:(id *)ioValue
error:(NSError **)outError
{
int value = [*ioValue intValue];
[self willChangeValueForKey:@"frameRate"];
debug_NSLog(@"Changing frameRate");
if (value < minFrameRate)
frameRate = minFrameRate;
else if (value > maxFrameRate)
frameRate = maxFrameRate;
else
frameRate = value;
[self didChangeValueForKey:@"frameRate"];
return YES;
}
// -------------------------------------------------------------------------------
// Validates duration
// -------------------------------------------------------------------------------
- (BOOL)validateDuration:(id *)ioValue
error:(NSError **)outError
{
int value = [*ioValue intValue];
[self willChangeValueForKey:@"duration"];
debug_NSLog(@"Changing duration");
if (value < minDuration)
duration = minDuration;
else if (value > maxDuration)
duration = maxDuration;
else
duration = value;
[self didChangeValueForKey:@"duration"];
return YES;
}
#pragma mark -
#pragma mark Synthesized Methods
@synthesize maxDwell;
@synthesize escapeRadius;
@synthesize frameRate;
@synthesize duration;
@end