annotate SliderViewController.mm @ 43:b91a1859829a

used UIkit sliders
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 19 Apr 2013 18:50:04 +0100
parents 8ed7522deaaa
children a1e75b94c505
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@43 33 int top = 3;
rt300@43 34 const int height = 62;
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@43 42 top = 0;
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@43 54 top += height;
rt300@43 55
rt300@43 56 [self.sliderArray addObject:sliderV]; // not working
rt300@43 57
rt300@43 58 }
rt300@43 59 int i = [self.sliderArray count];
rt300@43 60 NSLog(@"count: %d", i);
rt300@43 61
rt300@43 62 [(SliderController *)[self.sliderArray objectAtIndex:5] setParamValue:13];
rt300@43 63
rt300@36 64 }
rt300@36 65
rt300@36 66 - (void)didReceiveMemoryWarning
rt300@36 67 {
rt300@36 68 [super didReceiveMemoryWarning];
rt300@36 69 // Dispose of any resources that can be recreated.
rt300@36 70 }
rt300@36 71
rt300@36 72 - (void)setAppRef:(id)theOFApp{
rt300@36 73 self.theOFAppRef = theOFApp;
rt300@36 74
rt300@36 75 }
rt300@36 76
rt300@36 77 - (IBAction)show:(id)sender
rt300@36 78 {
rt300@36 79 self.theOFAppRef = sender;
rt300@36 80 self.view.hidden = NO;
rt300@36 81 }
rt300@43 82 - (IBAction)hide:(id)sender
rt300@43 83 {
rt300@43 84 self.theOFAppRef = sender;
rt300@43 85 self.view.hidden = YES;
rt300@43 86 }
rt300@37 87 - (void)dealloc {
rt300@43 88
rt300@37 89 [super dealloc];
rt300@37 90 }
rt300@37 91 - (void)viewDidUnload {
rt300@37 92 [super viewDidUnload];
rt300@37 93 }
rt300@43 94 - (void)slider:(int)which changedTo:(float)value{
rt300@43 95 // call testApp
rt300@43 96 ((testApp *)self.theOFAppRef)->sliderMoved(which,value);
rt300@43 97 }
rt300@43 98 - (void)setSlider:(int)which to:(float)value{
rt300@43 99 NSLog(@"set slider to");
rt300@43 100 [[self.sliderArray objectAtIndex:which] setParamValue:value];
rt300@43 101 }
rt300@43 102 - (void)populateParamNames{
rt300@43 103
rt300@43 104
rt300@43 105 self.paramNames = [NSArray arrayWithObjects:
rt300@43 106 @"Transpose",@"1/4 note",@"1/6 note",@"1/7 note",@"1/8 note",
rt300@43 107 @"Waveform",@"Filter Type",@"Filter Cutoff",@"Envelope",@"FM amount",
rt300@43 108 nil];
rt300@43 109
rt300@43 110 }
rt300@36 111 @end