CCControlUtils.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2012 cocos2d-x.org
  3. * http://www.cocos2d-x.org
  4. *
  5. *
  6. * Copyright 2012 Stewart Hamilton-Arrandale.
  7. * http://creativewax.co.uk
  8. *
  9. * Modified by Yannick Loriot.
  10. * http://yannickloriot.com
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13. * of this software and associated documentation files (the "Software"), to deal
  14. * in the Software without restriction, including without limitation the rights
  15. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. * copies of the Software, and to permit persons to whom the Software is
  17. * furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included in
  20. * all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  28. * THE SOFTWARE.
  29. *
  30. *
  31. * Converted to c++ / cocos2d-x by Angus C
  32. */
  33. #ifndef __CCCONTROL_UTILS_H__
  34. #define __CCCONTROL_UTILS_H__
  35. #include "2d/CCSprite.h"
  36. #include "../../ExtensionMacros.h"
  37. #include "extensions/ExtensionExport.h"
  38. NS_CC_EXT_BEGIN
  39. typedef struct
  40. {
  41. double r; // percent
  42. double g; // percent
  43. double b; // percent
  44. double a; // percent
  45. } RGBA;
  46. typedef struct
  47. {
  48. double h; // angle in degrees
  49. double s; // percent
  50. double v; // percent
  51. } HSV;
  52. /**
  53. * @addtogroup GUI
  54. * @{
  55. * @addtogroup control_extension
  56. * @{
  57. */
  58. //helper class to store Color3B's in mutable arrays
  59. class CC_EX_DLL Color3bObject : public Ref
  60. {
  61. public:
  62. Color3B value;
  63. /**
  64. * @js NA
  65. * @lua NA
  66. */
  67. Color3bObject(Color3B s_value):value(s_value){}
  68. };
  69. class CC_EX_DLL ControlUtils
  70. {
  71. public:
  72. /**
  73. * @js NA
  74. * @lua NA
  75. */
  76. static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vec2 pos, Vec2 anchor);
  77. /**
  78. * @js NA
  79. * @lua NA
  80. */
  81. static HSV HSVfromRGB(RGBA value);
  82. /**
  83. * @js NA
  84. * @lua NA
  85. */
  86. static RGBA RGBfromHSV(HSV value);
  87. /**
  88. * @js NA
  89. * @lua NA
  90. */
  91. static Rect RectUnion(const Rect& src1, const Rect& src2);
  92. };
  93. // end of GUI group
  94. /// @}
  95. /// @}
  96. NS_CC_EXT_END
  97. #endif