2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
2024-06-10 02:25:43 +08:00
|
|
|
https://axmol.dev/
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
2023-06-11 13:08:08 +08:00
|
|
|
#include "2d/Node.h"
|
|
|
|
#include "renderer/GroupCommand.h"
|
|
|
|
#include "renderer/CustomCommand.h"
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
class GridBase;
|
|
|
|
/**
|
|
|
|
* @addtogroup _2d
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Base class for Grid Node.
|
|
|
|
*/
|
|
|
|
|
2022-07-16 10:43:05 +08:00
|
|
|
class AX_DLL NodeGrid : public Node
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Create a Grid Node.
|
|
|
|
*
|
|
|
|
* @return An autorelease Grid Node.
|
|
|
|
*/
|
|
|
|
static NodeGrid* create();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
static NodeGrid* create(const Rect& rect);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Get a Grid Node.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @return Return a GridBase.
|
|
|
|
*/
|
|
|
|
GridBase* getGrid() { return _nodeGrid; }
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
|
|
|
const GridBase* getGrid() const { return _nodeGrid; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes a grid object that is used when applying effects.
|
|
|
|
*
|
|
|
|
* @param grid A Grid object that is used when applying effects.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setGrid(GridBase* grid);
|
|
|
|
|
|
|
|
/** Set the Grid Target.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param target A Node is used to set the Grid Target.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setTarget(Node* target);
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* @brief Set the effect grid rect.
|
|
|
|
* @param gridRect The effect grid rect.
|
|
|
|
*/
|
|
|
|
void setGridRect(const Rect& gridRect) { _gridRect = gridRect; }
|
|
|
|
/**
|
|
|
|
* @brief Get the effect grid rect.
|
|
|
|
* @return Return the effect grid rect.
|
|
|
|
*/
|
|
|
|
const Rect& getGridRect() const { return _gridRect; }
|
|
|
|
|
|
|
|
// overrides
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-03-18 21:46:07 +08:00
|
|
|
NodeGrid();
|
2019-11-23 20:27:39 +08:00
|
|
|
virtual ~NodeGrid();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onGridBeginDraw();
|
|
|
|
void onGridEndDraw();
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Node* _gridTarget = nullptr;
|
2019-11-23 20:27:39 +08:00
|
|
|
GridBase* _nodeGrid = nullptr;
|
|
|
|
CustomCommand _gridBeginCommand;
|
|
|
|
CustomCommand _gridEndCommand;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Rect _gridRect = Rect::ZERO;
|
|
|
|
|
|
|
|
private:
|
2022-07-16 10:43:05 +08:00
|
|
|
AX_DISALLOW_COPY_AND_ASSIGN(NodeGrid);
|
2019-11-23 20:27:39 +08:00
|
|
|
};
|
|
|
|
/** @} */
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|