/Classes/Slider.h

http://github.com/kstenerud/ObjectAL-for-iPhone · C Header · 87 lines · 39 code · 12 blank · 36 comment · 0 complexity · b854b456635fcfd108eef5aff8e5b770 MD5 · raw file

  1. //
  2. // Slider.h
  3. //
  4. // Created by Karl Stenerud on 10-05-30.
  5. //
  6. #import "TouchableNode.h"
  7. /**
  8. * A slider control. Contains a "knob" object, which slides along a "track" object.
  9. * Both the track and the knob are supplied at object creation time, and the slider
  10. * adjusts its contentSize according to the knob and track's size as well as their scale factor. <br>
  11. * This means that you can prescale the knob and/or track and still have a functioning slider.
  12. */
  13. @interface Slider : TouchableNode <CCRGBAProtocol>
  14. {
  15. CCNode* track;
  16. CCNode* knob;
  17. id target;
  18. SEL moveSelector;
  19. SEL dropSelector;
  20. CCScaleTo* scaleUpAction;
  21. CCScaleTo* scaleDownAction;
  22. }
  23. /** The position (value) of the slider in the track, as a proportion from 0.0 to 1.0 */
  24. @property(readwrite,assign) float value;
  25. /** Create a slider.
  26. * @param track The node to use as a track.
  27. * @param knob The node to use as a knob.
  28. * @param padding The amount of padding to add to the touchable area.
  29. * @param target the target to notify of events.
  30. * @param moveSelector the selector to call when the knob is moved (nil = ignore).
  31. * @param dropSelector The selector to call when the knob is dropped (nil = ignore).
  32. * @return a new slider.
  33. */
  34. + (id) sliderWithTrack:(CCNode*) track
  35. knob:(CCNode*) knob
  36. padding:(CGSize) padding
  37. target:(id) target
  38. moveSelector:(SEL) moveSelector
  39. dropSelector:(SEL) dropSelector;
  40. /** Initialize a slider.
  41. * @param track The node to use as a track.
  42. * @param knob The node to use as a knob.
  43. * @param padding The amount of padding to add to the touchable area.
  44. * @param target the target to notify of events.
  45. * @param moveSelector the selector to call when the knob is moved (nil = ignore).
  46. * @param dropSelector The selector to call when the knob is dropped (nil = ignore).
  47. * @return The initialized slider.
  48. */
  49. - (id) initWithTrack:(CCNode*) track
  50. knob:(CCNode*) knob
  51. padding:(CGSize) padding
  52. target:(id) target
  53. moveSelector:(SEL) moveSelector
  54. dropSelector:(SEL) dropSelector;
  55. @end
  56. /**
  57. * A slider that operates in the vertical direction.
  58. */
  59. @interface VerticalSlider: Slider
  60. {
  61. float horizontalLock;
  62. float verticalMax;
  63. float verticalMin;
  64. }
  65. @end
  66. /**
  67. * A slider that operates in the horizontal direction.
  68. */
  69. @interface HorizontalSlider: Slider
  70. {
  71. float verticalLock;
  72. float horizontalMax;
  73. float horizontalMin;
  74. }
  75. @end