|
| 1 | +/* |
| 2 | + * CCControlPotentiometer.h |
| 3 | + * |
| 4 | + * Copyright 2015 Volodin Andrey. All rights reserved. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + * |
| 24 | + */ |
| 25 | +#import "CCControl.h" |
| 26 | + |
| 27 | +@class CCProgressNode, CCSprite, CCColor; |
| 28 | + |
| 29 | +/** |
| 30 | + * Potentiometer control for Cocos2D. |
| 31 | + * |
| 32 | + * A CCPotentiometer object is a visual control used to select a |
| 33 | + * single value in a circular motion from a continuous range of values. |
| 34 | + * An indicator notes the current value of the potentiometer and can be |
| 35 | + * moved by the user to change the setting. |
| 36 | + */ |
| 37 | +@interface CCPotentiometer : CCControl { |
| 38 | +@public |
| 39 | + float _value; |
| 40 | + float _minimumValue; |
| 41 | + float _maximumValue; |
| 42 | + |
| 43 | +@protected |
| 44 | + CCSprite *_thumbSprite; |
| 45 | + CCSprite *_trackSprite; |
| 46 | + CCProgressNode *_progressTimer; |
| 47 | +} |
| 48 | +#pragma mark Contructors - Initializers |
| 49 | +/** @name Creating Potentiometers */ |
| 50 | + |
| 51 | +/** |
| 52 | + * Initializes a potentiometer with a track sprite and a progress bar. |
| 53 | + * |
| 54 | + * @param trackSprite CCSprite, that is used as a background. |
| 55 | + * @param progressTimer CCProgressTimer, that is used as a progress bar. |
| 56 | + * @param thumbSprite CCSprite, that is used as a thumb. |
| 57 | + */ |
| 58 | +- (id)initWithTrackSprite:(CCSprite *)trackSprite progressSprite:(CCProgressNode *)progressTimer thumbSprite:(CCSprite *)thumbSprite; |
| 59 | + |
| 60 | +/** |
| 61 | + * Creates potentiometer with a track filename and a progress filename. |
| 62 | + * |
| 63 | + * @see initWithTrackSprite:progressSprite:thumbSprite: |
| 64 | + */ |
| 65 | ++ (id)potentiometerWithTrackFile:(NSString *)backgroundFile progressFile:(NSString *)progressFile thumbFile:(NSString *)thumbFile; |
| 66 | + |
| 67 | +#pragma mark - Properties |
| 68 | +#pragma mark Accessing the Potentiometer’s Value |
| 69 | +/** @name Accessing the Potentiometer’s Value */ |
| 70 | +/** |
| 71 | + * @abstract Contains the receiver’s current value. |
| 72 | + * @discussion Setting this property causes the receiver to redraw itself |
| 73 | + * using the new value. To render an animated transition from the current |
| 74 | + * value to the new value, you should use the setValue:animated: method |
| 75 | + * instead. |
| 76 | + * |
| 77 | + * If you try to set a value that is below the minimum or above the maximum |
| 78 | + * value, the minimum or maximum value is set instead. The default value of |
| 79 | + * this property is 0.0. |
| 80 | + */ |
| 81 | +@property (nonatomic, assign) float value; |
| 82 | + |
| 83 | +/** |
| 84 | + * @abstract Sets the receiver’s current value, allowing you to animate the |
| 85 | + * change visually. |
| 86 | + * |
| 87 | + * @param value The new value to assign to the value property. |
| 88 | + * @param animated Specify YES to animate the change in value when the |
| 89 | + * receiver is redrawn; otherwise, specify NO to draw the receiver with the |
| 90 | + * new value only. Animations are performed asynchronously and do not block |
| 91 | + * the calling thread. |
| 92 | + * @discussion If you try to set a value that is below the minimum or above |
| 93 | + * the maximum value, the minimum or maximum value is set instead. The |
| 94 | + * default value of this property is 0.0. |
| 95 | + * @see value |
| 96 | + */ |
| 97 | +- (void)setValue:(float)value animated:(BOOL)animated; |
| 98 | + |
| 99 | +#pragma mark Accessing the Potentiometer’s Value Limits |
| 100 | +/** @name Accessing the Potentiometer’s Value Limits */ |
| 101 | +/** Contains the minimum value of the receiver. |
| 102 | + * The default value of this property is 0.0. */ |
| 103 | +@property (nonatomic, assign) float minimumValue; |
| 104 | +/** Contains the maximum value of the receiver. |
| 105 | + * The default value of this property is 1.0. */ |
| 106 | +@property (nonatomic, assign) float maximumValue; |
| 107 | + |
| 108 | +#pragma mark Customizing the Appearance of the Slider |
| 109 | +/** @name Customizing the Appearance of the Slider */ |
| 110 | + |
| 111 | +/** |
| 112 | + * @abstract The color used to tint the appearance of the thumb when the |
| 113 | + * potentiometer is pushed. |
| 114 | + * @discussion The default color is ccGRAY. |
| 115 | + */ |
| 116 | +@property(nonatomic, assign) CCColor* onThumbTintColor; |
| 117 | + |
| 118 | +#pragma mark - Public Methods |
| 119 | + |
| 120 | +@end |
0 commit comments