rt300@24
|
1 //
|
rt300@24
|
2 // TopButtonViewController.m
|
rt300@24
|
3 // sonicZoom
|
rt300@24
|
4 //
|
rt300@24
|
5 // Created by Robert Tubb on 31/01/2013.
|
rt300@24
|
6 //
|
rt300@24
|
7 //
|
rt300@24
|
8
|
rt300@24
|
9 #import "TopButtonViewController.h"
|
rt300@24
|
10 #import "testApp.h"
|
rt300@24
|
11 #import "presetManager.h"
|
rt300@24
|
12
|
rt300@24
|
13 extern PresetManager presetManager;
|
rt300@24
|
14
|
rt300@24
|
15
|
rt300@24
|
16 @interface TopButtonViewController ()
|
rt300@24
|
17
|
rt300@24
|
18 @end
|
rt300@24
|
19
|
rt300@24
|
20 @implementation TopButtonViewController
|
rt300@24
|
21
|
rt300@24
|
22 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
rt300@24
|
23 {
|
rt300@24
|
24 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
rt300@24
|
25 if (self) {
|
rt300@24
|
26 // Custom initialization
|
rt300@24
|
27 }
|
rt300@24
|
28 return self;
|
rt300@24
|
29 }
|
rt300@24
|
30
|
rt300@24
|
31 - (void)viewDidLoad
|
rt300@24
|
32 {
|
rt300@24
|
33 [super viewDidLoad];
|
rt300@24
|
34 // Do any additional setup after loading the view from its nib.
|
rt300@24
|
35 self.playButton.enabled = true;
|
rt300@24
|
36 self.pauseButton.enabled = false;
|
rt300@36
|
37 self.qButton.enabled = false;
|
rt300@29
|
38 self.newUserButton.enabled = true;
|
rt300@29
|
39 //------------------------
|
rt300@29
|
40 // Get the reference to the current toolbar buttons
|
rt300@36
|
41 //NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy];
|
rt300@29
|
42
|
rt300@29
|
43 // This is how you remove the button from the toolbar and animate it
|
rt300@36
|
44 //[toolbarButtons removeObject:self.qButton];
|
rt300@36
|
45 //[self setToolbarItems:toolbarButtons animated:YES];
|
rt300@29
|
46
|
rt300@29
|
47 // This is how you add the button to the toolbar and animate it
|
rt300@29
|
48 /*
|
rt300@29
|
49 if (![toolbarButtons containsObject:self.qButton]) {
|
rt300@29
|
50 [toolbarButtons addObject:self.qButton];
|
rt300@29
|
51 [self setToolbarItems:toolbarButtons animated:YES];
|
rt300@29
|
52 }
|
rt300@29
|
53 */
|
rt300@29
|
54
|
rt300@24
|
55 }
|
rt300@24
|
56
|
rt300@25
|
57 - (void)enableQuestionButton{
|
rt300@25
|
58 self.qButton.enabled = true;
|
rt300@25
|
59 }
|
rt300@24
|
60 - (void)didReceiveMemoryWarning
|
rt300@24
|
61 {
|
rt300@24
|
62 [super didReceiveMemoryWarning];
|
rt300@24
|
63 // Dispose of any resources that can be recreated.
|
rt300@24
|
64 }
|
rt300@24
|
65
|
rt300@24
|
66 - (void)setAppRef:(id)theOFApp{
|
rt300@24
|
67 self.theOFAppRef = theOFApp;
|
rt300@24
|
68
|
rt300@24
|
69 }
|
rt300@24
|
70
|
rt300@24
|
71 - (IBAction)playPressed:(id)sender {
|
rt300@24
|
72 ((testApp *)self.theOFAppRef)->seqStartStop(true);
|
rt300@24
|
73 self.playButton.enabled = false;
|
rt300@24
|
74 self.pauseButton.enabled = true;
|
rt300@46
|
75 self.seqNumText.text = [NSString stringWithFormat:@"%d", ((testApp *)self.theOFAppRef)->currentSequence];
|
rt300@24
|
76 }
|
rt300@24
|
77
|
rt300@24
|
78 - (IBAction)pausePressed:(id)sender {
|
rt300@24
|
79 ((testApp *)self.theOFAppRef)->seqStartStop(false);
|
rt300@24
|
80 self.pauseButton.enabled = false;
|
rt300@24
|
81 self.playButton.enabled = true;
|
rt300@24
|
82 }
|
rt300@24
|
83
|
rt300@24
|
84 - (IBAction)savePressed:(id)sender {
|
rt300@24
|
85 cout << "SAVE PRESET\n";
|
rt300@24
|
86 presetManager.showNameDialog();
|
rt300@24
|
87 }
|
rt300@24
|
88
|
rt300@44
|
89 // this is crap
|
rt300@24
|
90 - (IBAction)lockSequencePressed:(id)sender {
|
rt300@24
|
91 UIBarButtonItem *button = (UIBarButtonItem *)sender;
|
rt300@37
|
92 if([button.title isEqualToString:@"Lock X"]){
|
rt300@24
|
93 ((testApp *)self.theOFAppRef)->lockSequencerPressed(true);
|
rt300@37
|
94 button.title = @"Unlock X";
|
rt300@44
|
95 // if other one is locked , ulock it
|
rt300@44
|
96 if([self.lockYButton.title isEqualToString:@"Unlock Y"]){
|
rt300@44
|
97 ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
|
rt300@44
|
98 self.lockYButton.title = @"Lock Y";
|
rt300@44
|
99 }
|
rt300@37
|
100 }else if([button.title isEqualToString:@"Unlock X"]){
|
rt300@24
|
101 ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
|
rt300@37
|
102 button.title = @"Lock X";
|
rt300@24
|
103 }else{
|
rt300@24
|
104 NSLog(@"button title error");
|
rt300@24
|
105 }
|
rt300@24
|
106 }
|
rt300@24
|
107
|
rt300@24
|
108 - (IBAction)lockSynthPressed:(id)sender {
|
rt300@24
|
109 UIBarButtonItem *button = (UIBarButtonItem *)sender;
|
rt300@37
|
110 if([button.title isEqualToString:@"Lock Y"]){
|
rt300@24
|
111 ((testApp *)self.theOFAppRef)->lockSynthPressed(true);
|
rt300@37
|
112 button.title = @"Unlock Y";
|
rt300@44
|
113 // if other one is locked , ulock it
|
rt300@44
|
114 if([self.lockXButton.title isEqualToString:@"Unlock X"]){
|
rt300@44
|
115 ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
|
rt300@44
|
116 self.lockXButton.title = @"Lock X";
|
rt300@44
|
117 }
|
rt300@44
|
118
|
rt300@37
|
119 }else if([button.title isEqualToString:@"Unlock Y"]){
|
rt300@24
|
120 ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
|
rt300@37
|
121 button.title = @"Lock Y";
|
rt300@24
|
122 }else{
|
rt300@24
|
123 NSLog(@"button title error");
|
rt300@24
|
124 }
|
rt300@24
|
125 }
|
rt300@32
|
126 -(void)unlockAll{
|
rt300@32
|
127
|
rt300@32
|
128 }
|
rt300@24
|
129 - (IBAction)qPressed:(id)sender {
|
rt300@24
|
130 ((testApp *)self.theOFAppRef)->showQuestionnaire();
|
rt300@24
|
131 }
|
rt300@24
|
132
|
rt300@25
|
133 - (IBAction)randomise:(id)sender {
|
rt300@25
|
134 ((testApp *)self.theOFAppRef)->randomise();
|
rt300@46
|
135 int seqNum = ((testApp *)self.theOFAppRef)->nextSequence();
|
rt300@46
|
136 self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum];
|
rt300@25
|
137 }
|
rt300@25
|
138
|
rt300@26
|
139 - (IBAction)helpPressed:(id)sender {
|
rt300@27
|
140 ((testApp *)self.theOFAppRef)->showHelp();
|
rt300@26
|
141
|
rt300@27
|
142 }
|
rt300@27
|
143
|
rt300@27
|
144 - (IBAction)newUser:(id)sender {
|
rt300@27
|
145 ((testApp *)self.theOFAppRef)->setupNewUser();
|
rt300@26
|
146 }
|
rt300@26
|
147
|
rt300@36
|
148 - (IBAction)nextSequence:(id)sender {
|
rt300@46
|
149 int seqNum = ((testApp *)self.theOFAppRef)->nextSequence();
|
rt300@46
|
150 self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum];
|
rt300@36
|
151 }
|
rt300@36
|
152
|
rt300@38
|
153 - (IBAction)smoothSwitchChanged:(id)sender {
|
rt300@38
|
154 UISwitch * smoothswitch = (UISwitch *)sender;
|
rt300@38
|
155 NSLog(@"SMOOTH SWITCH %d", smoothswitch.on);
|
rt300@38
|
156 ((testApp *)self.theOFAppRef)->setInterp(smoothswitch.on);
|
rt300@39
|
157
|
rt300@38
|
158 }
|
rt300@38
|
159
|
rt300@24
|
160 - (IBAction)show:(id)sender
|
rt300@24
|
161 {
|
rt300@24
|
162 self.theOFAppRef = sender;
|
rt300@24
|
163 self.view.hidden = NO;
|
rt300@24
|
164 }
|
rt300@38
|
165 - (void)enableSmoothSwitch:(id)sender{
|
rt300@38
|
166 self.smoothToggle.hidden = NO;
|
rt300@38
|
167 self.smoothText.hidden = NO;
|
rt300@38
|
168 }
|
rt300@26
|
169 /*
|
rt300@26
|
170 helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
|
rt300@26
|
171 [ofxiPhoneGetGLParentView() addSubview:helpViewController.view];
|
rt300@26
|
172 [helpViewController hide:(id)this];
|
rt300@26
|
173 */
|
rt300@24
|
174 - (void)dealloc {
|
rt300@24
|
175 [_playButton release];
|
rt300@24
|
176 [_pauseButton release];
|
rt300@25
|
177 [_qButton release];
|
rt300@27
|
178
|
rt300@29
|
179 [_newUserButton release];
|
rt300@38
|
180 [_smoothText release];
|
rt300@38
|
181 [_smoothSwitch release];
|
rt300@38
|
182 [_smoothToggle release];
|
rt300@38
|
183 [_savePresetButton release];
|
rt300@44
|
184 [_lockXButton release];
|
rt300@44
|
185 [_lockYButton release];
|
rt300@46
|
186 [_seqNumText release];
|
rt300@24
|
187 [super dealloc];
|
rt300@24
|
188 }
|
rt300@24
|
189 - (void)viewDidUnload {
|
rt300@24
|
190 [self setPlayButton:nil];
|
rt300@24
|
191 [self setPauseButton:nil];
|
rt300@25
|
192 [self setQButton:nil];
|
rt300@29
|
193 [self setNewUserButton:nil];
|
rt300@38
|
194 [self setSmoothText:nil];
|
rt300@38
|
195 [self setSmoothSwitch:nil];
|
rt300@38
|
196 [self setSmoothToggle:nil];
|
rt300@38
|
197 [self setSavePresetButton:nil];
|
rt300@44
|
198 [self setLockXButton:nil];
|
rt300@44
|
199 [self setLockYButton:nil];
|
rt300@46
|
200 [self setSeqNumText:nil];
|
rt300@24
|
201 [super viewDidUnload];
|
rt300@24
|
202 }
|
rt300@24
|
203 @end
|