project_files/HedgewarsMobile/ValueTrackingSliderView.m
author koda
Tue, 07 Feb 2012 00:34:25 +0100
changeset 6634 e00762923086
permissions -rwxr-xr-x
ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6634
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     1
/*
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     4
 *
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     8
 *
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    13
 *
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    17
 *
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    18
 * File created on 06/02/2012.
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    19
 */
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    20
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    21
// class heavily based on: http://blog.neuwert-media.com/2011/04/customized-uislider-with-visual-value-tracking/
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    22
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    23
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    24
#import "ValueTrackingSliderView.h"
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    25
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    26
#pragma mark -
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    27
#pragma mark Private UIView subclass rendering the popup showing slider value
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    28
@interface SliderValuePopupView : UIView  
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    29
@property (nonatomic) float value;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    30
@property (nonatomic, retain) UIFont *font;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    31
@property (nonatomic, retain) NSString *text;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    32
@end
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    33
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    34
@implementation SliderValuePopupView
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    35
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    36
@synthesize value = _value;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    37
@synthesize font = _font;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    38
@synthesize text = _text;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    39
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    40
-(id) initWithFrame:(CGRect) frame {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    41
    self = [super initWithFrame:frame];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    42
    if (self) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    43
        self.font = [UIFont boldSystemFontOfSize:18];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    44
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    45
    return self;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    46
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    47
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    48
-(void) dealloc {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    49
    self.text = nil;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    50
    self.font = nil;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    51
    [super dealloc];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    52
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    53
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    54
-(void) drawRect:(CGRect) rect {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    55
    // Create the path for the rounded rectangle
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    56
    CGRect roundedRect = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, floorf(self.bounds.size.height * 0.8));
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    57
    UIBezierPath *roundedRectPath = [UIBezierPath bezierPathWithRoundedRect:roundedRect cornerRadius:6.0];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    58
    roundedRectPath.lineWidth = 2.0f;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    59
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    60
    // Create the arrow path
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    61
    UIBezierPath *arrowPath = [UIBezierPath bezierPath];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    62
    CGFloat midX = CGRectGetMidX(self.bounds);
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    63
    CGPoint p0 = CGPointMake(midX, CGRectGetMaxY(self.bounds));
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    64
    [arrowPath moveToPoint:p0];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    65
    [arrowPath addLineToPoint:CGPointMake((midX - 10.0), CGRectGetMaxY(roundedRect))];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    66
    [arrowPath addLineToPoint:CGPointMake((midX + 10.0), CGRectGetMaxY(roundedRect))];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    67
    [arrowPath closePath];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    68
    
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    69
    // Attach the arrow path to the rounded rect
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    70
    [roundedRectPath appendPath:arrowPath];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    71
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    72
    // Color various sections
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    73
    [[UIColor blackColor] setFill];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    74
    [roundedRectPath fill];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    75
    [[UIColor whiteColor] setStroke];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    76
    [roundedRectPath stroke];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    77
    [[UIColor whiteColor] setFill];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    78
    [arrowPath fill];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    79
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    80
    // Draw the text
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    81
    if (self.text) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    82
        [[UIColor lightYellowColor] set];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    83
        CGSize s = [_text sizeWithFont:self.font];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    84
        CGFloat yOffset = (roundedRect.size.height - s.height) / 2;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    85
        CGRect textRect = CGRectMake(roundedRect.origin.x, yOffset, roundedRect.size.width, s.height);
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    86
        
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    87
        [_text drawInRect:textRect 
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    88
                 withFont:self.font 
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    89
            lineBreakMode:UILineBreakModeWordWrap 
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    90
                alignment:UITextAlignmentCenter];    
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    91
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    92
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    93
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    94
@end
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    95
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    96
#pragma mark -
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    97
#pragma mark MNEValueTrackingSlider implementations
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    98
@implementation ValueTrackingSliderView
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
    99
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   100
@synthesize thumbRect, textValue;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   101
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   102
#pragma Private methods
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   103
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   104
-(void) _constructSlider {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   105
    valuePopupView = [[SliderValuePopupView alloc] initWithFrame:CGRectZero];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   106
    valuePopupView.backgroundColor = [UIColor clearColor];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   107
    valuePopupView.alpha = 0.0;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   108
    [self addSubview:valuePopupView];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   109
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   110
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   111
-(void) _fadePopupViewInAndOut:(BOOL)aFadeIn {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   112
    [UIView beginAnimations:nil context:NULL];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   113
    [UIView setAnimationDuration:0.25];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   114
    if (aFadeIn) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   115
        valuePopupView.alpha = 1.0;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   116
    } else {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   117
        valuePopupView.alpha = 0.0;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   118
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   119
    [UIView commitAnimations];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   120
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   121
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   122
-(void) _positionAndUpdatePopupView {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   123
    CGRect _thumbRect = self.thumbRect;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   124
    CGRect popupRect = CGRectOffset(_thumbRect, 0, -floorf(_thumbRect.size.height * 1.5));
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   125
    valuePopupView.frame = CGRectInset(popupRect, -100, -15);
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   126
    valuePopupView.text = self.textValue;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   127
    [valuePopupView setNeedsDisplay];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   128
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   129
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   130
#pragma mark Memory management
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   131
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   132
-(id) initWithFrame:(CGRect) frame {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   133
    self = [super initWithFrame:frame];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   134
    if (self) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   135
        [self _constructSlider];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   136
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   137
    return self;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   138
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   139
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   140
-(id) initWithCoder:(NSCoder *)aDecoder {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   141
    self = [super initWithCoder:aDecoder];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   142
    if (self) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   143
        [self _constructSlider];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   144
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   145
    return self;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   146
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   147
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   148
-(void) dealloc {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   149
    [valuePopupView release];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   150
    [textValue release];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   151
    [super dealloc];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   152
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   153
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   154
#pragma mark -
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   155
#pragma mark UIControl touch event tracking
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   156
-(BOOL) beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   157
    // Fade in and update the popup view
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   158
    CGPoint touchPoint = [touch locationInView:self];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   159
    // Check if the knob is touched. Only in this case show the popup-view
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   160
    if(CGRectContainsPoint(CGRectInset(self.thumbRect, -12.0, -12.0), touchPoint)) {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   161
        [self _positionAndUpdatePopupView];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   162
        [self _fadePopupViewInAndOut:YES]; 
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   163
    }
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   164
    return [super beginTrackingWithTouch:touch withEvent:event];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   165
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   166
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   167
-(BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   168
    // Update the popup view as slider knob is being moved
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   169
    [self _positionAndUpdatePopupView];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   170
    return [super continueTrackingWithTouch:touch withEvent:event];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   171
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   172
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   173
-(void) cancelTrackingWithEvent:(UIEvent *)event {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   174
    [super cancelTrackingWithEvent:event];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   175
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   176
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   177
-(void) endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   178
    // Fade out the popoup view
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   179
    [self _fadePopupViewInAndOut:NO];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   180
    [super endTrackingWithTouch:touch withEvent:event];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   181
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   182
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   183
#pragma mark -
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   184
#pragma mark Custom property accessors
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   185
-(CGRect) thumbRect {
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   186
    CGRect trackRect = [self trackRectForBounds:self.bounds];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   187
    CGRect thumbR = [self thumbRectForBounds:self.bounds 
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   188
                                         trackRect:trackRect
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   189
                                             value:self.value];
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   190
    return thumbR;
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   191
}
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   192
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents:
diff changeset
   193
@end