Renamed polygon editor's ControlPoint to PolygonControlPoint.

This commit is contained in:
Relintai 2022-06-13 17:45:23 +02:00
parent 6014b98720
commit 8178d526ba
2 changed files with 32 additions and 20 deletions

View File

@ -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<InputEvent> &event) {
void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &event) {
Ref<InputEventMouseButton> iemb = event;
Ref<InputEventMouseMotion> iemm = event;
@ -43,25 +43,35 @@ void ControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &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);
}

View File

@ -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<InputEvent> &event);
ControlPoint();
~ControlPoint();
PolygonControlPoint();
~PolygonControlPoint();
protected:
void _notification(int p_what);
static void _bind_methods();
bool moving = false;