mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-27 03:19:19 +01:00
Mostly done ControlPoint.
This commit is contained in:
parent
a12ee8f913
commit
6014b98720
@ -1,90 +1,67 @@
|
|||||||
|
|
||||||
#include "control_point.h"
|
#include "control_point.h"
|
||||||
|
|
||||||
|
|
||||||
bool ControlPoint::get_moving() const {
|
bool ControlPoint::get_moving() const {
|
||||||
return moving;
|
return moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPoint::set_moving(const bool val) {
|
void ControlPoint::set_moving(const bool val) {
|
||||||
moving = val;
|
moving = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlPoint::_draw() {
|
||||||
|
|
||||||
//tool;
|
|
||||||
bool moving = false;
|
|
||||||
const OFFSET : Vector2 = Vector2(3, 3);
|
|
||||||
signal moved(index);
|
|
||||||
signal removed(index);
|
|
||||||
|
|
||||||
void ControlPoint::_draw() {
|
|
||||||
// var current_theme : Theme = get_node("/root/MainWindow").theme;
|
// var current_theme : Theme = get_node("/root/MainWindow").theme;
|
||||||
// var color : Color = current_theme.get_color("font_color", "Label");
|
// var color : Color = current_theme.get_color("font_color", "Label");
|
||||||
Color color = Color(1, 1, 1, 1);
|
Color color = Color(1, 1, 1, 1);
|
||||||
draw_rect(Rect2(0, 0, 7, 7), color);
|
draw_rect(Rect2(0, 0, 7, 7), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlPoint::initialize(const Vector2 &p) {
|
||||||
void ControlPoint::initialize(const Vector2 &p) {
|
set_rect_position(get_parent().transform_point(p) - OFFSET);
|
||||||
rect_position = get_parent().transform_point(p) - OFFSET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &event) {
|
||||||
|
Ref<InputEventMouseButton> iemb = event;
|
||||||
|
Ref<InputEventMouseMotion> iemm = event;
|
||||||
|
|
||||||
void ControlPoint::_on_ControlPoint_gui_input(const Variant &event) {
|
if (iemb.is_valid()) {
|
||||||
|
if (iemb->get_button_index() == BUTTON_LEFT) {
|
||||||
if (event is InputEventMouseButton) {
|
if (iemb->is_pressed()) {
|
||||||
|
|
||||||
if (event.button_index == BUTTON_LEFT) {
|
|
||||||
|
|
||||||
if (event.pressed) {
|
|
||||||
moving = true;
|
moving = true;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
|
|
||||||
else {
|
|
||||||
moving = false;
|
moving = false;
|
||||||
get_parent().update_controls();
|
get_parent().update_controls();
|
||||||
}
|
}
|
||||||
|
} else if (iemb->get_button_index() == BUTTON_RIGHT && event->is_pressed()) {
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
else if (event.button_index == BUTTON_RIGHT && event.pressed) {
|
|
||||||
emit_signal("removed", get_index());
|
emit_signal("removed", get_index());
|
||||||
}
|
}
|
||||||
|
} else if (moving && iemm.is_valid()) {
|
||||||
}
|
Vector2 rect_position = get_position();
|
||||||
|
rect_position += iemm->get_relative();
|
||||||
|
set_position(rect_position);
|
||||||
else if (moving && event is InputEventMouseMotion) {
|
|
||||||
rect_position += event.relative;
|
|
||||||
emit_signal("moved", get_index());
|
emit_signal("moved", get_index());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
ControlPoint::ControlPoint() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlPoint::ControlPoint() {
|
|
||||||
moving = false;
|
moving = false;
|
||||||
}
|
|
||||||
|
|
||||||
ControlPoint::~ControlPoint() {
|
set_custom_minimum_size(Vector2(7, 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlPoint::~ControlPoint() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlPoint::_bind_methods() {
|
||||||
|
ADD_SIGNAL(MethodInfo("moved", PropertyInfo(Variant::INT, "index")));
|
||||||
|
ADD_SIGNAL(MethodInfo("removed", PropertyInfo(Variant::INT, "index")));
|
||||||
|
|
||||||
static void ControlPoint::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_moving"), &ControlPoint::get_moving);
|
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("set_moving", "value"), &ControlPoint::set_moving);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "moving"), "set_moving", "get_moving");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "moving"), "set_moving", "get_moving");
|
||||||
|
|
||||||
|
//ClassDB::bind_method(D_METHOD("_draw"), &ControlPoint::_draw);
|
||||||
ClassDB::bind_method(D_METHOD("_draw"), &ControlPoint::_draw);
|
|
||||||
ClassDB::bind_method(D_METHOD("initialize", "p"), &ControlPoint::initialize);
|
ClassDB::bind_method(D_METHOD("initialize", "p"), &ControlPoint::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"), &ControlPoint::_on_ControlPoint_gui_input);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
void construct() {
|
|
||||||
|
|
||||||
//Script: res://addons/mat_maker_gd/widgets/polygon_edit/control_point.gd
|
|
||||||
Control *controlpoint = memnew(Control);
|
|
||||||
controlpoint->set_name("ControlPoint");
|
|
||||||
|
|
||||||
controlpoint->set_name("ControlPoint");
|
|
||||||
//controlpoint->set("name", ControlPoint));
|
|
||||||
|
|
||||||
controlpoint->set_filename("res://addons/mat_maker_gd/widgets/polygon_edit/control_point.tscn");
|
|
||||||
//controlpoint->set("filename", "res://addons/mat_maker_gd/widgets/polygon_edit/control_point.tscn");
|
|
||||||
|
|
||||||
controlpoint->set_margin_left(56.986401);
|
|
||||||
//controlpoint->set("margin_left", 56.986401);
|
|
||||||
|
|
||||||
controlpoint->set_margin_top(33.8615);
|
|
||||||
//controlpoint->set("margin_top", 33.8615);
|
|
||||||
|
|
||||||
controlpoint->set_margin_right(63.986401);
|
|
||||||
//controlpoint->set("margin_right", 63.986401);
|
|
||||||
|
|
||||||
controlpoint->set_margin_bottom(40.8615);
|
|
||||||
//controlpoint->set("margin_bottom", 40.8615);
|
|
||||||
|
|
||||||
controlpoint->set_rect_position(Vector2(56.986401, 33.8615));
|
|
||||||
//controlpoint->set("rect_position", Vector2(56.986401, 33.8615));
|
|
||||||
|
|
||||||
controlpoint->set_rect_global_position(Vector2(56.986401, 33.8615));
|
|
||||||
//controlpoint->set("rect_global_position", Vector2(56.986401, 33.8615));
|
|
||||||
|
|
||||||
controlpoint->set_rect_size(Vector2(7, 7));
|
|
||||||
//controlpoint->set("rect_size", Vector2(7, 7));
|
|
||||||
|
|
||||||
controlpoint->set_rect_min_size(Vector2(7, 7));
|
|
||||||
//controlpoint->set("rect_min_size", Vector2(7, 7));
|
|
||||||
|
|
||||||
//controlpoint property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +1,30 @@
|
|||||||
#ifndef CONTROL_POINT_H
|
#ifndef CONTROL_POINT_H
|
||||||
#define CONTROL_POINT_H
|
#define CONTROL_POINT_H
|
||||||
|
|
||||||
|
#include "scene/gui/control.h"
|
||||||
|
|
||||||
|
#include "core/os/input_event.h"
|
||||||
|
|
||||||
class ControlPoint : public Control {
|
class ControlPoint : public Control {
|
||||||
GDCLASS(ControlPoint, Control);
|
GDCLASS(ControlPoint, Control);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool get_moving() const;
|
bool get_moving() const;
|
||||||
void set_moving(const bool val);
|
void set_moving(const bool val);
|
||||||
|
|
||||||
void _draw();
|
void _draw();
|
||||||
void initialize(const Vector2 &p);
|
void initialize(const Vector2 &p);
|
||||||
void _on_ControlPoint_gui_input(const Variant &event);
|
|
||||||
|
void _on_ControlPoint_gui_input(const Ref<InputEvent> &event);
|
||||||
|
|
||||||
ControlPoint();
|
ControlPoint();
|
||||||
~ControlPoint();
|
~ControlPoint();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
|
||||||
bool moving = false;
|
bool moving = false;
|
||||||
const OFFSET : Vector2 = Vector2(3, 3);
|
const Vector2 OFFSET = Vector2(3, 3);
|
||||||
signal moved(index);
|
|
||||||
signal removed(index);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user