annotate SliderViewController.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 b91a1859829a
children c2fffc8ea84d
rev   line source
rt300@36 1 //
rt300@36 2 // SliderViewController.m
rt300@36 3 // sonicZoom
rt300@36 4 //
rt300@36 5 // Created by Robert Tubb on 01/02/2013.
rt300@36 6 //
rt300@36 7 //
rt300@36 8
rt300@36 9 #import "SliderViewController.h"
rt300@43 10 #import "testApp.h"
rt300@36 11
rt300@36 12 @interface SliderViewController ()
rt300@36 13
rt300@36 14 @end
rt300@36 15
rt300@36 16 @implementation SliderViewController
rt300@36 17
rt300@36 18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
rt300@36 19 {
rt300@36 20 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
rt300@36 21 if (self) {
rt300@36 22 // Custom initialization
rt300@43 23 [self populateParamNames];
rt300@43 24 self.sliderArray = [[NSMutableArray alloc] init];
rt300@43 25
rt300@36 26 }
rt300@36 27 return self;
rt300@36 28 }
rt300@36 29
rt300@36 30 - (void)viewDidLoad
rt300@36 31 {
rt300@43 32 int left = 22;
rt300@44 33 int top = 10;
rt300@44 34 const int height = 50;
rt300@43 35 const int width = 337;
rt300@43 36
rt300@36 37 [super viewDidLoad];
rt300@43 38
rt300@43 39 for(int i=0;i<10;i++){
rt300@43 40
rt300@43 41 if(i==5){
rt300@44 42 top = 10;
rt300@43 43 left = left*3 + width;
rt300@43 44 }
rt300@43 45 SliderController * sliderV = [[SliderController alloc] initWithNibName:@"SliderController" bundle:nil delegate:self pID:i];
rt300@43 46
rt300@43 47 [self.view addSubview:sliderV.view];
rt300@43 48
rt300@43 49 sliderV.view.frame = CGRectMake(left,top,width,height);
rt300@43 50 [sliderV setPID:i];
rt300@43 51 NSLog(@"setting name to %@", self.paramNames[i]);
rt300@43 52 [sliderV changeLabel:self.paramNames[i] ];
rt300@43 53 [sliderV setParamValue:44];
rt300@44 54 if(i>=5){
rt300@44 55 [sliderV makeRed];
rt300@44 56 }
rt300@43 57 top += height;
rt300@43 58
rt300@43 59 [self.sliderArray addObject:sliderV]; // not working
rt300@43 60
rt300@43 61 }
rt300@43 62 int i = [self.sliderArray count];
rt300@43 63 NSLog(@"count: %d", i);
rt300@43 64
rt300@43 65 [(SliderController *)[self.sliderArray objectAtIndex:5] setParamValue:13];
rt300@43 66
rt300@36 67 }
rt300@36 68
rt300@36 69 - (void)didReceiveMemoryWarning
rt300@36 70 {
rt300@36 71 [super didReceiveMemoryWarning];
rt300@36 72 // Dispose of any resources that can be recreated.
rt300@36 73 }
rt300@36 74
rt300@36 75 - (void)setAppRef:(id)theOFApp{
rt300@36 76 self.theOFAppRef = theOFApp;
rt300@36 77
rt300@36 78 }
rt300@36 79
rt300@36 80 - (IBAction)show:(id)sender
rt300@36 81 {
rt300@36 82 self.theOFAppRef = sender;
rt300@36 83 self.view.hidden = NO;
rt300@36 84 }
rt300@43 85 - (IBAction)hide:(id)sender
rt300@43 86 {
rt300@43 87 self.theOFAppRef = sender;
rt300@43 88 self.view.hidden = YES;
rt300@43 89 }
rt300@37 90 - (void)dealloc {
rt300@43 91
rt300@37 92 [super dealloc];
rt300@37 93 }
rt300@37 94 - (void)viewDidUnload {
rt300@37 95 [super viewDidUnload];
rt300@37 96 }
rt300@43 97 - (void)slider:(int)which changedTo:(float)value{
rt300@43 98 // call testApp
rt300@43 99 ((testApp *)self.theOFAppRef)->sliderMoved(which,value);
rt300@43 100 }
rt300@43 101 - (void)setSlider:(int)which to:(float)value{
rt300@43 102 [[self.sliderArray objectAtIndex:which] setParamValue:value];
rt300@43 103 }
rt300@43 104 - (void)populateParamNames{
rt300@43 105
rt300@43 106
rt300@43 107 self.paramNames = [NSArray arrayWithObjects:
rt300@43 108 @"Transpose",@"1/4 note",@"1/6 note",@"1/7 note",@"1/8 note",
rt300@43 109 @"Waveform",@"Filter Type",@"Filter Cutoff",@"Envelope",@"FM amount",
rt300@43 110 nil];
rt300@43 111
rt300@43 112 }
rt300@36 113 @end