mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 12:26:59 +01:00
Added a few notifications to PaintNodes.
This commit is contained in:
parent
9f8f6cb3b4
commit
50cf64b7f1
@ -10,6 +10,7 @@ void PaintNode::set_size(const Vector2i &size) {
|
||||
_size = size;
|
||||
|
||||
if (is_inside_tree()) {
|
||||
_propagate_notification_resized();
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -25,6 +26,14 @@ void PaintNode::set_draw_outline(const bool val) {
|
||||
}
|
||||
}
|
||||
|
||||
void PaintNode::save() {
|
||||
notification(NOTIFICATION_PAINT_PROJECT_PRE_SAVE);
|
||||
call("_save");
|
||||
notification(NOTIFICATION_PAINT_PROJECT_POST_SAVE);
|
||||
}
|
||||
void PaintNode::_save() {
|
||||
}
|
||||
|
||||
PoolVector2iArray PaintNode::util_get_pixels_in_line(const Vector2i &from, const Vector2i &to) {
|
||||
return PaintUtilities::get_pixels_in_line(from, to);
|
||||
}
|
||||
@ -88,6 +97,18 @@ String PaintNode::get_configuration_warning() const {
|
||||
return "This Node should be a child of a PaintProject!";
|
||||
}
|
||||
|
||||
void PaintNode::_propagate_notification_resized() {
|
||||
notification(NOTIFICATION_PAINT_NODE_RESIZED);
|
||||
|
||||
for (int i = 0; i < get_child_count(); ++i) {
|
||||
PaintNode *pn = Object::cast_to<PaintNode>(get_child(i));
|
||||
|
||||
if (pn) {
|
||||
pn->_propagate_notification_resized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PaintNode::PaintNode() {
|
||||
_draw_outline = true;
|
||||
}
|
||||
@ -119,6 +140,10 @@ void PaintNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_draw_outline", "val"), &PaintNode::set_draw_outline);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_outline"), "set_draw_outline", "get_draw_outline");
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_save"));
|
||||
ClassDB::bind_method(D_METHOD("save"), &PaintNode::save);
|
||||
ClassDB::bind_method(D_METHOD("_save"), &PaintNode::_save);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("util_get_pixels_in_line", "from", "to"), &PaintNode::util_get_pixels_in_line);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("util_to_1d_v", "p", "w"), &PaintNode::util_to_1d_v);
|
||||
@ -134,4 +159,8 @@ void PaintNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_forward_canvas_gui_input", "event"), &PaintNode::_forward_canvas_gui_input);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_paint_project"), &PaintNode::get_paint_project);
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_NODE_RESIZED);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_PRE_SAVE);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_POST_SAVE);
|
||||
}
|
||||
|
@ -11,12 +11,22 @@ class PaintNode : public Node2D {
|
||||
GDCLASS(PaintNode, Node2D);
|
||||
|
||||
public:
|
||||
enum {
|
||||
NOTIFICATION_PAINT_NODE_RESIZED = 2500,
|
||||
NOTIFICATION_PAINT_PROJECT_PRE_SAVE = 2501,
|
||||
NOTIFICATION_PAINT_PROJECT_POST_SAVE = 2502,
|
||||
};
|
||||
|
||||
|
||||
Vector2i get_size();
|
||||
void set_size(const Vector2i &size);
|
||||
|
||||
bool get_draw_outline();
|
||||
void set_draw_outline(const bool val);
|
||||
|
||||
void save();
|
||||
virtual void _save();
|
||||
|
||||
PoolVector2iArray util_get_pixels_in_line(const Vector2i &from, const Vector2i &to);
|
||||
|
||||
int util_to_1d_v(const Vector2i &p, int w);
|
||||
@ -34,6 +44,8 @@ public:
|
||||
|
||||
String get_configuration_warning() const;
|
||||
|
||||
virtual void _propagate_notification_resized();
|
||||
|
||||
PaintNode();
|
||||
~PaintNode();
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "paint_project.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "../ui/paint_canvas_background.h"
|
||||
#include "../ui/paint_visual_grid.h"
|
||||
#include "core/config/project_settings.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
|
||||
@ -77,6 +77,9 @@ void PaintProject::add_paint_visual_grid() {
|
||||
}
|
||||
}
|
||||
|
||||
void PaintProject::_propagate_notification_resized() {
|
||||
}
|
||||
|
||||
PaintProject::PaintProject() {
|
||||
_current_color = Color(1, 1, 1, 1);
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ public:
|
||||
void add_paint_canvas_backgorund();
|
||||
void add_paint_visual_grid();
|
||||
|
||||
void _propagate_notification_resized();
|
||||
|
||||
PaintProject();
|
||||
~PaintProject();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user