annotate TopButtonViewController.mm @ 44:a1e75b94c505

Snap to eval points. Double tap to go to preset (doesn't quite work yet). Coloured locks. Changed Question 2. Fixed some leaks.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 22 Apr 2013 18:32:34 +0100
parents df7c08faf541
children 1e266647840d
rev   line source
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@24 75 }
rt300@24 76
rt300@24 77 - (IBAction)pausePressed:(id)sender {
rt300@24 78 ((testApp *)self.theOFAppRef)->seqStartStop(false);
rt300@24 79 self.pauseButton.enabled = false;
rt300@24 80 self.playButton.enabled = true;
rt300@24 81 }
rt300@24 82
rt300@24 83 - (IBAction)savePressed:(id)sender {
rt300@24 84 cout << "SAVE PRESET\n";
rt300@24 85 presetManager.showNameDialog();
rt300@24 86 }
rt300@24 87
rt300@44 88 // this is crap
rt300@24 89 - (IBAction)lockSequencePressed:(id)sender {
rt300@24 90 UIBarButtonItem *button = (UIBarButtonItem *)sender;
rt300@37 91 if([button.title isEqualToString:@"Lock X"]){
rt300@24 92 ((testApp *)self.theOFAppRef)->lockSequencerPressed(true);
rt300@37 93 button.title = @"Unlock X";
rt300@44 94 // if other one is locked , ulock it
rt300@44 95 if([self.lockYButton.title isEqualToString:@"Unlock Y"]){
rt300@44 96 ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
rt300@44 97 self.lockYButton.title = @"Lock Y";
rt300@44 98 }
rt300@37 99 }else if([button.title isEqualToString:@"Unlock X"]){
rt300@24 100 ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
rt300@37 101 button.title = @"Lock X";
rt300@24 102 }else{
rt300@24 103 NSLog(@"button title error");
rt300@24 104 }
rt300@24 105 }
rt300@24 106
rt300@24 107 - (IBAction)lockSynthPressed:(id)sender {
rt300@24 108 UIBarButtonItem *button = (UIBarButtonItem *)sender;
rt300@37 109 if([button.title isEqualToString:@"Lock Y"]){
rt300@24 110 ((testApp *)self.theOFAppRef)->lockSynthPressed(true);
rt300@37 111 button.title = @"Unlock Y";
rt300@44 112 // if other one is locked , ulock it
rt300@44 113 if([self.lockXButton.title isEqualToString:@"Unlock X"]){
rt300@44 114 ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
rt300@44 115 self.lockXButton.title = @"Lock X";
rt300@44 116 }
rt300@44 117
rt300@37 118 }else if([button.title isEqualToString:@"Unlock Y"]){
rt300@24 119 ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
rt300@37 120 button.title = @"Lock Y";
rt300@24 121 }else{
rt300@24 122 NSLog(@"button title error");
rt300@24 123 }
rt300@24 124 }
rt300@32 125 -(void)unlockAll{
rt300@32 126
rt300@32 127 }
rt300@24 128 - (IBAction)qPressed:(id)sender {
rt300@24 129 ((testApp *)self.theOFAppRef)->showQuestionnaire();
rt300@24 130 }
rt300@24 131
rt300@25 132 - (IBAction)randomise:(id)sender {
rt300@25 133 ((testApp *)self.theOFAppRef)->randomise();
rt300@25 134 }
rt300@25 135
rt300@26 136 - (IBAction)helpPressed:(id)sender {
rt300@27 137 ((testApp *)self.theOFAppRef)->showHelp();
rt300@26 138
rt300@27 139 }
rt300@27 140
rt300@27 141 - (IBAction)newUser:(id)sender {
rt300@27 142 ((testApp *)self.theOFAppRef)->setupNewUser();
rt300@26 143 }
rt300@26 144
rt300@36 145 - (IBAction)nextSequence:(id)sender {
rt300@36 146 ((testApp *)self.theOFAppRef)->nextSequence();
rt300@36 147 }
rt300@36 148
rt300@38 149 - (IBAction)smoothSwitchChanged:(id)sender {
rt300@38 150 UISwitch * smoothswitch = (UISwitch *)sender;
rt300@38 151 NSLog(@"SMOOTH SWITCH %d", smoothswitch.on);
rt300@38 152 ((testApp *)self.theOFAppRef)->setInterp(smoothswitch.on);
rt300@39 153
rt300@38 154 }
rt300@38 155
rt300@24 156 - (IBAction)show:(id)sender
rt300@24 157 {
rt300@24 158 self.theOFAppRef = sender;
rt300@24 159 self.view.hidden = NO;
rt300@24 160 }
rt300@38 161 - (void)enableSmoothSwitch:(id)sender{
rt300@38 162 self.smoothToggle.hidden = NO;
rt300@38 163 self.smoothText.hidden = NO;
rt300@38 164 }
rt300@26 165 /*
rt300@26 166 helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
rt300@26 167 [ofxiPhoneGetGLParentView() addSubview:helpViewController.view];
rt300@26 168 [helpViewController hide:(id)this];
rt300@26 169 */
rt300@24 170 - (void)dealloc {
rt300@24 171 [_playButton release];
rt300@24 172 [_pauseButton release];
rt300@25 173 [_qButton release];
rt300@27 174
rt300@29 175 [_newUserButton release];
rt300@38 176 [_smoothText release];
rt300@38 177 [_smoothSwitch release];
rt300@38 178 [_smoothToggle release];
rt300@38 179 [_savePresetButton release];
rt300@44 180 [_lockXButton release];
rt300@44 181 [_lockYButton release];
rt300@24 182 [super dealloc];
rt300@24 183 }
rt300@24 184 - (void)viewDidUnload {
rt300@24 185 [self setPlayButton:nil];
rt300@24 186 [self setPauseButton:nil];
rt300@25 187 [self setQButton:nil];
rt300@29 188 [self setNewUserButton:nil];
rt300@38 189 [self setSmoothText:nil];
rt300@38 190 [self setSmoothSwitch:nil];
rt300@38 191 [self setSmoothToggle:nil];
rt300@38 192 [self setSavePresetButton:nil];
rt300@44 193 [self setLockXButton:nil];
rt300@44 194 [self setLockYButton:nil];
rt300@24 195 [super viewDidUnload];
rt300@24 196 }
rt300@24 197 @end