rt300@24: // rt300@24: // TopButtonViewController.m rt300@24: // sonicZoom rt300@24: // rt300@24: // Created by Robert Tubb on 31/01/2013. rt300@24: // rt300@24: // rt300@24: rt300@24: #import "TopButtonViewController.h" rt300@24: #import "testApp.h" rt300@24: #import "presetManager.h" rt300@24: rt300@24: extern PresetManager presetManager; rt300@24: rt300@24: rt300@24: @interface TopButtonViewController () rt300@24: rt300@24: @end rt300@24: rt300@24: @implementation TopButtonViewController rt300@24: rt300@24: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil rt300@24: { rt300@24: self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; rt300@24: if (self) { rt300@24: // Custom initialization rt300@24: } rt300@24: return self; rt300@24: } rt300@24: rt300@24: - (void)viewDidLoad rt300@24: { rt300@24: [super viewDidLoad]; rt300@24: // Do any additional setup after loading the view from its nib. rt300@24: self.playButton.enabled = true; rt300@24: self.pauseButton.enabled = false; rt300@36: self.qButton.enabled = false; rt300@29: self.newUserButton.enabled = true; rt300@29: //------------------------ rt300@29: // Get the reference to the current toolbar buttons rt300@36: //NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy]; rt300@29: rt300@29: // This is how you remove the button from the toolbar and animate it rt300@36: //[toolbarButtons removeObject:self.qButton]; rt300@36: //[self setToolbarItems:toolbarButtons animated:YES]; rt300@29: rt300@29: // This is how you add the button to the toolbar and animate it rt300@29: /* rt300@29: if (![toolbarButtons containsObject:self.qButton]) { rt300@29: [toolbarButtons addObject:self.qButton]; rt300@29: [self setToolbarItems:toolbarButtons animated:YES]; rt300@29: } rt300@29: */ rt300@29: rt300@24: } rt300@24: rt300@25: - (void)enableQuestionButton{ rt300@25: self.qButton.enabled = true; rt300@25: } rt300@24: - (void)didReceiveMemoryWarning rt300@24: { rt300@24: [super didReceiveMemoryWarning]; rt300@24: // Dispose of any resources that can be recreated. rt300@24: } rt300@24: rt300@24: - (void)setAppRef:(id)theOFApp{ rt300@24: self.theOFAppRef = theOFApp; rt300@24: rt300@24: } rt300@24: rt300@24: - (IBAction)playPressed:(id)sender { rt300@24: ((testApp *)self.theOFAppRef)->seqStartStop(true); rt300@24: self.playButton.enabled = false; rt300@24: self.pauseButton.enabled = true; rt300@46: self.seqNumText.text = [NSString stringWithFormat:@"%d", ((testApp *)self.theOFAppRef)->currentSequence]; rt300@24: } rt300@24: rt300@24: - (IBAction)pausePressed:(id)sender { rt300@24: ((testApp *)self.theOFAppRef)->seqStartStop(false); rt300@24: self.pauseButton.enabled = false; rt300@24: self.playButton.enabled = true; rt300@24: } rt300@24: rt300@24: - (IBAction)savePressed:(id)sender { rt300@24: cout << "SAVE PRESET\n"; rt300@24: presetManager.showNameDialog(); rt300@24: } rt300@24: rt300@44: // this is crap rt300@24: - (IBAction)lockSequencePressed:(id)sender { rt300@24: UIBarButtonItem *button = (UIBarButtonItem *)sender; rt300@37: if([button.title isEqualToString:@"Lock X"]){ rt300@24: ((testApp *)self.theOFAppRef)->lockSequencerPressed(true); rt300@37: button.title = @"Unlock X"; rt300@44: // if other one is locked , ulock it rt300@44: if([self.lockYButton.title isEqualToString:@"Unlock Y"]){ rt300@44: ((testApp *)self.theOFAppRef)->lockSynthPressed(false); rt300@44: self.lockYButton.title = @"Lock Y"; rt300@44: } rt300@37: }else if([button.title isEqualToString:@"Unlock X"]){ rt300@24: ((testApp *)self.theOFAppRef)->lockSequencerPressed(false); rt300@37: button.title = @"Lock X"; rt300@24: }else{ rt300@24: NSLog(@"button title error"); rt300@24: } rt300@24: } rt300@24: rt300@24: - (IBAction)lockSynthPressed:(id)sender { rt300@24: UIBarButtonItem *button = (UIBarButtonItem *)sender; rt300@37: if([button.title isEqualToString:@"Lock Y"]){ rt300@24: ((testApp *)self.theOFAppRef)->lockSynthPressed(true); rt300@37: button.title = @"Unlock Y"; rt300@44: // if other one is locked , ulock it rt300@44: if([self.lockXButton.title isEqualToString:@"Unlock X"]){ rt300@44: ((testApp *)self.theOFAppRef)->lockSequencerPressed(false); rt300@44: self.lockXButton.title = @"Lock X"; rt300@44: } rt300@44: rt300@37: }else if([button.title isEqualToString:@"Unlock Y"]){ rt300@24: ((testApp *)self.theOFAppRef)->lockSynthPressed(false); rt300@37: button.title = @"Lock Y"; rt300@24: }else{ rt300@24: NSLog(@"button title error"); rt300@24: } rt300@24: } rt300@32: -(void)unlockAll{ rt300@32: rt300@32: } rt300@24: - (IBAction)qPressed:(id)sender { rt300@24: ((testApp *)self.theOFAppRef)->showQuestionnaire(); rt300@24: } rt300@24: rt300@25: - (IBAction)randomise:(id)sender { rt300@25: ((testApp *)self.theOFAppRef)->randomise(); rt300@46: int seqNum = ((testApp *)self.theOFAppRef)->nextSequence(); rt300@46: self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum]; rt300@25: } rt300@25: rt300@26: - (IBAction)helpPressed:(id)sender { rt300@27: ((testApp *)self.theOFAppRef)->showHelp(); rt300@26: rt300@27: } rt300@27: rt300@27: - (IBAction)newUser:(id)sender { rt300@27: ((testApp *)self.theOFAppRef)->setupNewUser(); rt300@26: } rt300@26: rt300@36: - (IBAction)nextSequence:(id)sender { rt300@46: int seqNum = ((testApp *)self.theOFAppRef)->nextSequence(); rt300@46: self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum]; rt300@36: } rt300@36: rt300@38: - (IBAction)smoothSwitchChanged:(id)sender { rt300@38: UISwitch * smoothswitch = (UISwitch *)sender; rt300@38: NSLog(@"SMOOTH SWITCH %d", smoothswitch.on); rt300@38: ((testApp *)self.theOFAppRef)->setInterp(smoothswitch.on); rt300@39: rt300@38: } rt300@38: rt300@24: - (IBAction)show:(id)sender rt300@24: { rt300@24: self.theOFAppRef = sender; rt300@24: self.view.hidden = NO; rt300@24: } rt300@38: - (void)enableSmoothSwitch:(id)sender{ rt300@38: self.smoothToggle.hidden = NO; rt300@38: self.smoothText.hidden = NO; rt300@38: } rt300@26: /* rt300@26: helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil]; rt300@26: [ofxiPhoneGetGLParentView() addSubview:helpViewController.view]; rt300@26: [helpViewController hide:(id)this]; rt300@26: */ rt300@24: - (void)dealloc { rt300@24: [_playButton release]; rt300@24: [_pauseButton release]; rt300@25: [_qButton release]; rt300@27: rt300@29: [_newUserButton release]; rt300@38: [_smoothText release]; rt300@38: [_smoothSwitch release]; rt300@38: [_smoothToggle release]; rt300@38: [_savePresetButton release]; rt300@44: [_lockXButton release]; rt300@44: [_lockYButton release]; rt300@46: [_seqNumText release]; rt300@24: [super dealloc]; rt300@24: } rt300@24: - (void)viewDidUnload { rt300@24: [self setPlayButton:nil]; rt300@24: [self setPauseButton:nil]; rt300@25: [self setQButton:nil]; rt300@29: [self setNewUserButton:nil]; rt300@38: [self setSmoothText:nil]; rt300@38: [self setSmoothSwitch:nil]; rt300@38: [self setSmoothToggle:nil]; rt300@38: [self setSavePresetButton:nil]; rt300@44: [self setLockXButton:nil]; rt300@44: [self setLockYButton:nil]; rt300@46: [self setSeqNumText:nil]; rt300@24: [super viewDidUnload]; rt300@24: } rt300@24: @end