mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-08 13:01:49 +02:00
Now PaintVisualGrid and PaintCanvasBackground inherits from PaintNode.
This commit is contained in:
parent
c0da82ab92
commit
b823759397
@ -24,8 +24,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_canvas_background.h"
|
#include "paint_canvas_background.h"
|
||||||
|
|
||||||
#include "../nodes/paint_node.h"
|
|
||||||
|
|
||||||
int PaintCanvasBackground::get_grid_size() const {
|
int PaintCanvasBackground::get_grid_size() const {
|
||||||
return _grid_size;
|
return _grid_size;
|
||||||
}
|
}
|
||||||
@ -53,22 +51,6 @@ void PaintCanvasBackground::set_grid_white(const Color &val) {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintNode *PaintCanvasBackground::get_paint_node() {
|
|
||||||
Node *p = this;
|
|
||||||
|
|
||||||
while (p) {
|
|
||||||
PaintNode *pn = Object::cast_to<PaintNode>(p);
|
|
||||||
|
|
||||||
if (pn) {
|
|
||||||
return pn;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = p->get_parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaintCanvasBackground::PaintCanvasBackground() {
|
PaintCanvasBackground::PaintCanvasBackground() {
|
||||||
_grid_size = 8;
|
_grid_size = 8;
|
||||||
|
|
||||||
@ -83,7 +65,7 @@ void PaintCanvasBackground::_notification(int p_what) {
|
|||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE:
|
case NOTIFICATION_ENTER_TREE:
|
||||||
case PaintNode::NOTIFICATION_PARENT_PAINT_NODE_RESIZED: {
|
case PaintNode::NOTIFICATION_PARENT_PAINT_NODE_RESIZED: {
|
||||||
PaintNode *pn = get_paint_node();
|
PaintNode *pn = get_parent_paint_node();
|
||||||
|
|
||||||
if (pn) {
|
if (pn) {
|
||||||
set_size(pn->get_size());
|
set_size(pn->get_size());
|
||||||
|
@ -25,17 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scene/gui/texture_rect.h"
|
#include "../nodes/paint_node.h"
|
||||||
|
|
||||||
#include "core/object/reference.h"
|
class PaintCanvasBackground : public PaintNode {
|
||||||
|
GDCLASS(PaintCanvasBackground, PaintNode);
|
||||||
class ShaderMaterial;
|
|
||||||
class Shader;
|
|
||||||
class Image;
|
|
||||||
class PaintNode;
|
|
||||||
|
|
||||||
class PaintCanvasBackground : public TextureRect {
|
|
||||||
GDCLASS(PaintCanvasBackground, TextureRect);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int get_grid_size() const;
|
int get_grid_size() const;
|
||||||
@ -46,9 +39,7 @@ public:
|
|||||||
|
|
||||||
Color get_grid_white() const;
|
Color get_grid_white() const;
|
||||||
void set_grid_white(const Color &val);
|
void set_grid_white(const Color &val);
|
||||||
|
|
||||||
PaintNode *get_paint_node();
|
|
||||||
|
|
||||||
PaintCanvasBackground();
|
PaintCanvasBackground();
|
||||||
~PaintCanvasBackground();
|
~PaintCanvasBackground();
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_visual_grid.h"
|
#include "paint_visual_grid.h"
|
||||||
|
|
||||||
#include "../nodes/paint_node.h"
|
|
||||||
|
|
||||||
int PaintVisualGrid::get_grid_size() {
|
int PaintVisualGrid::get_grid_size() {
|
||||||
return _grid_size;
|
return _grid_size;
|
||||||
}
|
}
|
||||||
@ -42,27 +40,11 @@ void PaintVisualGrid::set_grid_color(const Color &val) {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintNode *PaintVisualGrid::get_paint_node() {
|
|
||||||
Node *p = this;
|
|
||||||
|
|
||||||
while (p) {
|
|
||||||
PaintNode *pn = Object::cast_to<PaintNode>(p);
|
|
||||||
|
|
||||||
if (pn) {
|
|
||||||
return pn;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = p->get_parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaintVisualGrid::_notification(int p_what) {
|
void PaintVisualGrid::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE:
|
case NOTIFICATION_ENTER_TREE:
|
||||||
case PaintNode::NOTIFICATION_PARENT_PAINT_NODE_RESIZED: {
|
case PaintNode::NOTIFICATION_PARENT_PAINT_NODE_RESIZED: {
|
||||||
PaintNode *pn = get_paint_node();
|
PaintNode *pn = get_parent_paint_node();
|
||||||
|
|
||||||
if (pn) {
|
if (pn) {
|
||||||
set_size(pn->get_size());
|
set_size(pn->get_size());
|
||||||
|
@ -25,12 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scene/gui/control.h"
|
#include "../nodes/paint_node.h"
|
||||||
|
|
||||||
class PaintNode;
|
class PaintVisualGrid : public PaintNode {
|
||||||
|
GDCLASS(PaintVisualGrid, PaintNode);
|
||||||
class PaintVisualGrid : public Control {
|
|
||||||
GDCLASS(PaintVisualGrid, Control);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int get_grid_size();
|
int get_grid_size();
|
||||||
@ -39,8 +37,6 @@ public:
|
|||||||
Color get_grid_color();
|
Color get_grid_color();
|
||||||
void set_grid_color(const Color &val);
|
void set_grid_color(const Color &val);
|
||||||
|
|
||||||
PaintNode *get_paint_node();
|
|
||||||
|
|
||||||
PaintVisualGrid();
|
PaintVisualGrid();
|
||||||
~PaintVisualGrid();
|
~PaintVisualGrid();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user