view TopButtonViewController.mm @ 49:178642d134a7 tip

xtra files
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 01 May 2013 17:34:33 +0100
parents 1e266647840d
children
line wrap: on
line source
//
//  TopButtonViewController.m
//  sonicZoom
//
//  Created by Robert Tubb on 31/01/2013.
//
//

#import "TopButtonViewController.h"
#import "testApp.h"
#import "presetManager.h"

extern PresetManager presetManager;


@interface TopButtonViewController ()

@end

@implementation TopButtonViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.playButton.enabled = true;
    self.pauseButton.enabled = false;
    self.qButton.enabled = false;
    self.newUserButton.enabled = true;
    //------------------------
    // Get the reference to the current toolbar buttons
    //NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy];
    
    // This is how you remove the button from the toolbar and animate it
    //[toolbarButtons removeObject:self.qButton];
    //[self setToolbarItems:toolbarButtons animated:YES];
    
    // This is how you add the button to the toolbar and animate it
    /*
    if (![toolbarButtons containsObject:self.qButton]) {
        [toolbarButtons addObject:self.qButton];
        [self setToolbarItems:toolbarButtons animated:YES];
    }
    */
    
}

- (void)enableQuestionButton{
    self.qButton.enabled = true;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setAppRef:(id)theOFApp{
    self.theOFAppRef = theOFApp;
    
}

- (IBAction)playPressed:(id)sender {
    ((testApp *)self.theOFAppRef)->seqStartStop(true);
    self.playButton.enabled = false;
    self.pauseButton.enabled = true;
    self.seqNumText.text = [NSString stringWithFormat:@"%d", ((testApp *)self.theOFAppRef)->currentSequence];
}

- (IBAction)pausePressed:(id)sender {
    ((testApp *)self.theOFAppRef)->seqStartStop(false);
    self.pauseButton.enabled = false;
    self.playButton.enabled = true;
}

- (IBAction)savePressed:(id)sender {
    cout << "SAVE PRESET\n";
    presetManager.showNameDialog();
}

// this is crap
- (IBAction)lockSequencePressed:(id)sender {
    UIBarButtonItem *button = (UIBarButtonItem *)sender;
    if([button.title isEqualToString:@"Lock X"]){
        ((testApp *)self.theOFAppRef)->lockSequencerPressed(true);
        button.title = @"Unlock X";
        // if other one is locked , ulock it
        if([self.lockYButton.title isEqualToString:@"Unlock Y"]){
            ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
            self.lockYButton.title = @"Lock Y";
        }
    }else if([button.title isEqualToString:@"Unlock X"]){
        ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
        button.title = @"Lock X";
    }else{
        NSLog(@"button title error");
    }
}

- (IBAction)lockSynthPressed:(id)sender {
    UIBarButtonItem *button = (UIBarButtonItem *)sender;
    if([button.title isEqualToString:@"Lock Y"]){
        ((testApp *)self.theOFAppRef)->lockSynthPressed(true);
        button.title = @"Unlock Y";
        // if other one is locked , ulock it
        if([self.lockXButton.title isEqualToString:@"Unlock X"]){
            ((testApp *)self.theOFAppRef)->lockSequencerPressed(false);
            self.lockXButton.title = @"Lock X";
        }
        
    }else if([button.title isEqualToString:@"Unlock Y"]){
        ((testApp *)self.theOFAppRef)->lockSynthPressed(false);
        button.title = @"Lock Y";
    }else{
        NSLog(@"button title error");
    }
}
-(void)unlockAll{
    
}
- (IBAction)qPressed:(id)sender {
    ((testApp *)self.theOFAppRef)->showQuestionnaire();
}

- (IBAction)randomise:(id)sender {
    ((testApp *)self.theOFAppRef)->randomise();
    int seqNum = ((testApp *)self.theOFAppRef)->nextSequence();
    self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum];
}

- (IBAction)helpPressed:(id)sender {
    ((testApp *)self.theOFAppRef)->showHelp();

}

- (IBAction)newUser:(id)sender {
    ((testApp *)self.theOFAppRef)->setupNewUser();
}

- (IBAction)nextSequence:(id)sender {
    int seqNum = ((testApp *)self.theOFAppRef)->nextSequence();
    self.seqNumText.text = [NSString stringWithFormat:@"%d", seqNum];
}

- (IBAction)smoothSwitchChanged:(id)sender {
    UISwitch * smoothswitch = (UISwitch *)sender;
    NSLog(@"SMOOTH SWITCH %d", smoothswitch.on);
    ((testApp *)self.theOFAppRef)->setInterp(smoothswitch.on);

}

- (IBAction)show:(id)sender
{
    self.theOFAppRef = sender;
    self.view.hidden = NO;
}
- (void)enableSmoothSwitch:(id)sender{
    self.smoothToggle.hidden = NO;
    self.smoothText.hidden = NO;
}
/*
 helpViewController	= [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
 [ofxiPhoneGetGLParentView() addSubview:helpViewController.view];
 [helpViewController hide:(id)this];
 */
- (void)dealloc {
    [_playButton release];
    [_pauseButton release];
    [_qButton release];

    [_newUserButton release];
    [_smoothText release];
    [_smoothSwitch release];
    [_smoothToggle release];
    [_savePresetButton release];
    [_lockXButton release];
    [_lockYButton release];
    [_seqNumText release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setPlayButton:nil];
    [self setPauseButton:nil];
    [self setQButton:nil];
    [self setNewUserButton:nil];
    [self setSmoothText:nil];
    [self setSmoothSwitch:nil];
    [self setSmoothToggle:nil];
    [self setSavePresetButton:nil];
    [self setLockXButton:nil];
    [self setLockYButton:nil];
    [self setSeqNumText:nil];
    [super viewDidUnload];
}
@end