CCControlSaturationBrightnessPicker.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2012 cocos2d-x.org
  3. * http://www.cocos2d-x.org
  4. *
  5. * Copyright 2012 Stewart Hamilton-Arrandale.
  6. * http://creativewax.co.uk
  7. *
  8. * Modified by Yannick Loriot.
  9. * http://yannickloriot.com
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12. * of this software and associated documentation files (the "Software"), to deal
  13. * in the Software without restriction, including without limitation the rights
  14. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15. * copies of the Software, and to permit persons to whom the Software is
  16. * furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included in
  19. * all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27. * THE SOFTWARE.
  28. *
  29. * Converted to c++ / cocos2d-x by Angus C
  30. */
  31. #ifndef __CCCONTROL_SATURATION_PICKER_H__
  32. #define __CCCONTROL_SATURATION_PICKER_H__
  33. #include "CCControl.h"
  34. #include "CCInvocation.h"
  35. #include "extensions/ExtensionExport.h"
  36. NS_CC_EXT_BEGIN
  37. /**
  38. * @addtogroup GUI
  39. * @{
  40. * @addtogroup control_extension
  41. * @{
  42. */
  43. class CC_EX_DLL ControlSaturationBrightnessPicker : public Control
  44. {
  45. /** Contains the receiver's current saturation value. */
  46. CC_SYNTHESIZE_READONLY(float, _saturation, Saturation);
  47. /** Contains the receiver's current brightness value. */
  48. CC_SYNTHESIZE_READONLY(float, _brightness, Brightness);
  49. //not sure if these need to be there actually. I suppose someone might want to access the sprite?
  50. CC_SYNTHESIZE_READONLY(Sprite*, _background, Background);
  51. CC_SYNTHESIZE_READONLY(Sprite*, _overlay, Overlay);
  52. CC_SYNTHESIZE_READONLY(Sprite*, _shadow, Shadow);
  53. CC_SYNTHESIZE_READONLY(Sprite*, _slider, Slider);
  54. CC_SYNTHESIZE_READONLY(Vec2, _startPos, StartPos);
  55. protected:
  56. int boxPos;
  57. int boxSize;
  58. public:
  59. /**
  60. * @js ctor
  61. */
  62. ControlSaturationBrightnessPicker();
  63. /**
  64. * @js NA
  65. * @lua NA
  66. */
  67. virtual ~ControlSaturationBrightnessPicker();
  68. virtual bool initWithTargetAndPos(Node* target, Vec2 pos);
  69. static ControlSaturationBrightnessPicker* create(Node* target, Vec2 pos);
  70. virtual void setEnabled(bool enabled) override;
  71. /**
  72. * @js NA
  73. * @lua NA
  74. */
  75. virtual void updateWithHSV(HSV hsv);
  76. /**
  77. * @js NA
  78. * @lua NA
  79. */
  80. virtual void updateDraggerWithHSV(HSV hsv);
  81. protected:
  82. void updateSliderPosition(Vec2 location);
  83. bool checkSliderPosition(Vec2 location);
  84. virtual bool onTouchBegan(Touch* touch, Event* pEvent) override;
  85. virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
  86. };
  87. // end of GUI group
  88. /// @}
  89. /// @}
  90. NS_CC_EXT_END
  91. #endif