mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-24 18:17:21 +01:00
Mostly done ControlPoint.
This commit is contained in:
parent
a12ee8f913
commit
6014b98720
@ -1,90 +1,67 @@
|
||||
|
||||
#include "control_point.h"
|
||||
|
||||
|
||||
bool ControlPoint::get_moving() const {
|
||||
return moving;
|
||||
return moving;
|
||||
}
|
||||
|
||||
void ControlPoint::set_moving(const bool val) {
|
||||
moving = val;
|
||||
moving = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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 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::_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) {
|
||||
rect_position = get_parent().transform_point(p) - OFFSET;
|
||||
void ControlPoint::initialize(const Vector2 &p) {
|
||||
set_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 (event is InputEventMouseButton) {
|
||||
|
||||
if (event.button_index == BUTTON_LEFT) {
|
||||
|
||||
if (event.pressed) {
|
||||
moving = true;
|
||||
if (iemb.is_valid()) {
|
||||
if (iemb->get_button_index() == BUTTON_LEFT) {
|
||||
if (iemb->is_pressed()) {
|
||||
moving = true;
|
||||
} else {
|
||||
moving = false;
|
||||
get_parent().update_controls();
|
||||
}
|
||||
} else if (iemb->get_button_index() == BUTTON_RIGHT && event->is_pressed()) {
|
||||
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);
|
||||
emit_signal("moved", get_index());
|
||||
}
|
||||
}
|
||||
|
||||
ControlPoint::ControlPoint() {
|
||||
moving = false;
|
||||
|
||||
else {
|
||||
moving = false;
|
||||
get_parent().update_controls();
|
||||
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")));
|
||||
|
||||
else if (event.button_index == BUTTON_RIGHT && event.pressed) {
|
||||
emit_signal("removed", get_index());
|
||||
ClassDB::bind_method(D_METHOD("get_moving"), &ControlPoint::get_moving);
|
||||
ClassDB::bind_method(D_METHOD("set_moving", "value"), &ControlPoint::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("_on_ControlPoint_gui_input", "event"), &ControlPoint::_on_ControlPoint_gui_input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (moving && event is InputEventMouseMotion) {
|
||||
rect_position += event.relative;
|
||||
emit_signal("moved", get_index());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ControlPoint::ControlPoint() {
|
||||
moving = false;
|
||||
}
|
||||
|
||||
ControlPoint::~ControlPoint() {
|
||||
}
|
||||
|
||||
|
||||
static void ControlPoint::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_moving"), &ControlPoint::get_moving);
|
||||
ClassDB::bind_method(D_METHOD("set_moving", "value"), &ControlPoint::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("_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
|
||||
#define CONTROL_POINT_H
|
||||
|
||||
#include "scene/gui/control.h"
|
||||
|
||||
#include "core/os/input_event.h"
|
||||
|
||||
class ControlPoint : public Control {
|
||||
GDCLASS(ControlPoint, Control);
|
||||
GDCLASS(ControlPoint, Control);
|
||||
|
||||
public:
|
||||
public:
|
||||
bool get_moving() const;
|
||||
void set_moving(const bool val);
|
||||
|
||||
bool get_moving() const;
|
||||
void set_moving(const bool val);
|
||||
void _draw();
|
||||
void initialize(const Vector2 &p);
|
||||
|
||||
void _draw();
|
||||
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:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
bool moving = false;
|
||||
const OFFSET : Vector2 = Vector2(3, 3);
|
||||
signal moved(index);
|
||||
signal removed(index);
|
||||
bool moving = false;
|
||||
const Vector2 OFFSET = Vector2(3, 3);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user