//
//  SliderController.m
//  sonicZoom
//
//  Created by Robert Tubb on 19/04/2013.
//
//

#import "SliderController.h"

@interface SliderController ()

@end

@implementation SliderController

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

-(id)initWithNibName:(NSString *)nibNameOrNil
              bundle:(NSBundle *)nibBundleOrNil
            delegate:(id)delegate
                 pID:(int)pID
{
    self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    self.delegate = delegate; // the sliderviewcontroller
    self.pID = pID;
    return self;
}

- (void) setID:(NSInteger) paramID{
    self.pID = paramID;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_paramName release];
    [_theSlider release];
    [_valueText release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setParamName:nil];
    [self setTheSlider:nil];
    [self setValueText:nil];
    [super viewDidUnload];
}
- (IBAction)sliderChanged:(id)sender {
    // touch evt changed slider. send to super view (?)
    
    self.valueText.text = [NSString stringWithFormat:@"%3.0f", self.theSlider.value];
    
    [(SliderViewController *)self.delegate slider: self.pID changedTo: self.theSlider.value];
}

-(void) changeLabel:(NSString *) name{
    // change the name of the slider param
    self.paramName.text = name;
    
}
-(void) setParamValue:(NSInteger) val{
    self.theSlider.value = val;
    self.valueText.text = [NSString stringWithFormat:@"%3.0f", self.theSlider.value];
}
-(void) makeRed{
    UIColor * red = [[UIColor alloc] initWithRed:1 green:0 blue:0 alpha:1];
    self.theSlider.minimumTrackTintColor = red;
    [red release];
}
@end
