CCNodeGrid.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __MISCNODE_CCGRID_NODE_H__
  22. #define __MISCNODE_CCGRID_NODE_H__
  23. #include "2d/CCNode.h"
  24. #include "renderer/CCGroupCommand.h"
  25. #include "renderer/CCCustomCommand.h"
  26. NS_CC_BEGIN
  27. class GridBase;
  28. /**
  29. * @addtogroup _2d
  30. * @{
  31. */
  32. /**
  33. * @brief Base class for Grid Node.
  34. */
  35. class CC_DLL NodeGrid : public Node
  36. {
  37. public:
  38. /** Create a Grid Node.
  39. *
  40. * @return An autorelease Grid Node.
  41. */
  42. static NodeGrid* create();
  43. static NodeGrid* create(const Rect& rect);
  44. /** Get a Grid Node.
  45. *
  46. * @return Return a GridBase.
  47. */
  48. GridBase* getGrid() { return _nodeGrid; }
  49. /**
  50. * @js NA
  51. */
  52. const GridBase* getGrid() const { return _nodeGrid; }
  53. /**
  54. * Changes a grid object that is used when applying effects.
  55. *
  56. * @param grid A Grid object that is used when applying effects.
  57. */
  58. void setGrid(GridBase *grid);
  59. /** Set the Grid Target.
  60. *
  61. * @param target A Node is used to set the Grid Target.
  62. */
  63. void setTarget(Node *target);
  64. /**
  65. * @brief Set the effect grid rect.
  66. * @param gridRect The effect grid rect.
  67. */
  68. void setGridRect(const Rect& gridRect) { _gridRect = gridRect; }
  69. /**
  70. * @brief Get the effect grid rect.
  71. * @return Return the effect grid rect.
  72. */
  73. const Rect& getGridRect() const { return _gridRect; }
  74. // overrides
  75. virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
  76. CC_CONSTRUCTOR_ACCESS:
  77. NodeGrid();
  78. virtual ~NodeGrid();
  79. protected:
  80. void onGridBeginDraw();
  81. void onGridEndDraw();
  82. Node* _gridTarget;
  83. GridBase* _nodeGrid;
  84. GroupCommand _groupCommand;
  85. CustomCommand _gridBeginCommand;
  86. CustomCommand _gridEndCommand;
  87. Rect _gridRect;
  88. private:
  89. CC_DISALLOW_COPY_AND_ASSIGN(NodeGrid);
  90. };
  91. /** @} */
  92. NS_CC_END
  93. #endif