From 8178d526baf19da20cecf56a35d87ade7507b48e Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 13 Jun 2022 17:45:23 +0200 Subject: [PATCH] Renamed polygon editor's ControlPoint to PolygonControlPoint. --- ...ol_point.cpp => polygon_control_point.cpp} | 38 ++++++++++++------- ...ontrol_point.h => polygon_control_point.h} | 14 ++++--- 2 files changed, 32 insertions(+), 20 deletions(-) rename modules/material_maker/editor/widgets/polygon_edit/{control_point.cpp => polygon_control_point.cpp} (56%) rename modules/material_maker/editor/widgets/polygon_edit/{control_point.h => polygon_control_point.h} (61%) diff --git a/modules/material_maker/editor/widgets/polygon_edit/control_point.cpp b/modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.cpp similarity index 56% rename from modules/material_maker/editor/widgets/polygon_edit/control_point.cpp rename to modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.cpp index ef2c0d058..544eb8373 100644 --- a/modules/material_maker/editor/widgets/polygon_edit/control_point.cpp +++ b/modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.cpp @@ -1,26 +1,26 @@ -#include "control_point.h" +#include "polygon_control_point.h" -bool ControlPoint::get_moving() const { +bool PolygonControlPoint::get_moving() const { return moving; } -void ControlPoint::set_moving(const bool val) { +void PolygonControlPoint::set_moving(const bool val) { moving = val; } -void ControlPoint::_draw() { +void PolygonControlPoint::_draw() { // var current_theme : Theme = get_node("/root/MainWindow").theme; // var color : Color = current_theme.get_color("font_color", "Label"); Color color = Color(1, 1, 1, 1); draw_rect(Rect2(0, 0, 7, 7), color); } -void ControlPoint::initialize(const Vector2 &p) { +void PolygonControlPoint::initialize(const Vector2 &p) { set_rect_position(get_parent().transform_point(p) - OFFSET); } -void ControlPoint::_on_ControlPoint_gui_input(const Ref &event) { +void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref &event) { Ref iemb = event; Ref iemm = event; @@ -43,25 +43,35 @@ void ControlPoint::_on_ControlPoint_gui_input(const Ref &event) { } } -ControlPoint::ControlPoint() { +PolygonControlPoint::PolygonControlPoint() { moving = false; set_custom_minimum_size(Vector2(7, 7)); } -ControlPoint::~ControlPoint() { +PolygonControlPoint::~PolygonControlPoint() { } -void ControlPoint::_bind_methods() { +void PolygonControlPoint::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_DRAW: { + _draw(); + } break; + default: { + } break; + } +} + +void PolygonControlPoint::_bind_methods() { ADD_SIGNAL(MethodInfo("moved", PropertyInfo(Variant::INT, "index"))); ADD_SIGNAL(MethodInfo("removed", PropertyInfo(Variant::INT, "index"))); - ClassDB::bind_method(D_METHOD("get_moving"), &ControlPoint::get_moving); - ClassDB::bind_method(D_METHOD("set_moving", "value"), &ControlPoint::set_moving); + ClassDB::bind_method(D_METHOD("get_moving"), &PolygonControlPoint::get_moving); + ClassDB::bind_method(D_METHOD("set_moving", "value"), &PolygonControlPoint::set_moving); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "moving"), "set_moving", "get_moving"); - //ClassDB::bind_method(D_METHOD("_draw"), &ControlPoint::_draw); - ClassDB::bind_method(D_METHOD("initialize", "p"), &ControlPoint::initialize); + //ClassDB::bind_method(D_METHOD("_draw"), &PolygonControlPoint::_draw); + ClassDB::bind_method(D_METHOD("initialize", "p"), &PolygonControlPoint::initialize); - ClassDB::bind_method(D_METHOD("_on_ControlPoint_gui_input", "event"), &ControlPoint::_on_ControlPoint_gui_input); + ClassDB::bind_method(D_METHOD("_on_ControlPoint_gui_input", "event"), &PolygonControlPoint::_on_ControlPoint_gui_input); } diff --git a/modules/material_maker/editor/widgets/polygon_edit/control_point.h b/modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.h similarity index 61% rename from modules/material_maker/editor/widgets/polygon_edit/control_point.h rename to modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.h index 54f948c11..841def6d9 100644 --- a/modules/material_maker/editor/widgets/polygon_edit/control_point.h +++ b/modules/material_maker/editor/widgets/polygon_edit/polygon_control_point.h @@ -1,12 +1,12 @@ -#ifndef CONTROL_POINT_H -#define CONTROL_POINT_H +#ifndef POLYGON_CONTROL_POINT_H +#define POLYGON_CONTROL_POINT_H #include "scene/gui/control.h" #include "core/os/input_event.h" -class ControlPoint : public Control { - GDCLASS(ControlPoint, Control); +class PolygonControlPoint : public Control { + GDCLASS(PolygonControlPoint, Control); public: bool get_moving() const; @@ -17,10 +17,12 @@ public: void _on_ControlPoint_gui_input(const Ref &event); - ControlPoint(); - ~ControlPoint(); + PolygonControlPoint(); + ~PolygonControlPoint(); protected: + void _notification(int p_what); + static void _bind_methods(); bool moving = false;