summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAndreas Haas <liu.gam3@gmail.com>2017-11-24 19:22:33 +0100
committerAndreas Haas <liu.gam3@gmail.com>2017-11-24 19:23:04 +0100
commitc76a9b99b00909fa6742e6618f84de71d9e06668 (patch)
tree39c5420c048ed1d0ae5209dc83935869cee48d8c /core
parentf5c513ca7beef75759cdff4d50760aebe7118df2 (diff)
Core: Bind InputEventGesture events.
Diffstat (limited to 'core')
-rw-r--r--core/os/input_event.cpp24
-rw-r--r--core/os/input_event.h9
-rw-r--r--core/register_core_types.cpp3
3 files changed, 36 insertions, 0 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 3cdd9ae0e0..9b2bd30868 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -939,6 +939,14 @@ void InputEventGesture::set_position(const Vector2 &p_pos) {
pos = p_pos;
}
+void InputEventGesture::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventGesture::set_position);
+ ClassDB::bind_method(D_METHOD("get_position"), &InputEventGesture::get_position);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
+}
+
Vector2 InputEventGesture::get_position() const {
return pos;
@@ -970,6 +978,14 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
return ev;
}
+void InputEventMagnifyGesture::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
+ ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor");
+}
+
InputEventMagnifyGesture::InputEventMagnifyGesture() {
factor = 1.0;
@@ -1000,6 +1016,14 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
return ev;
}
+void InputEventPanGesture::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta);
+ ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta");
+}
+
InputEventPanGesture::InputEventPanGesture() {
delta = Vector2(0, 0);
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 2cba60bede..614a3289ba 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -476,6 +476,9 @@ class InputEventGesture : public InputEventWithModifiers {
Vector2 pos;
+protected:
+ static void _bind_methods();
+
public:
void set_position(const Vector2 &p_pos);
Vector2 get_position() const;
@@ -486,6 +489,9 @@ class InputEventMagnifyGesture : public InputEventGesture {
GDCLASS(InputEventMagnifyGesture, InputEventGesture)
real_t factor;
+protected:
+ static void _bind_methods();
+
public:
void set_factor(real_t p_factor);
real_t get_factor() const;
@@ -500,6 +506,9 @@ class InputEventPanGesture : public InputEventGesture {
GDCLASS(InputEventPanGesture, InputEventGesture)
Vector2 delta;
+protected:
+ static void _bind_methods();
+
public:
void set_delta(const Vector2 &p_delta);
Vector2 get_delta() const;
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index baaf738b42..17f951e4f4 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -129,6 +129,9 @@ void register_core_types() {
ClassDB::register_class<InputEventScreenDrag>();
ClassDB::register_class<InputEventScreenTouch>();
ClassDB::register_class<InputEventAction>();
+ ClassDB::register_virtual_class<InputEventGesture>();
+ ClassDB::register_class<InputEventMagnifyGesture>();
+ ClassDB::register_class<InputEventPanGesture>();
ClassDB::register_class<FuncRef>();
ClassDB::register_virtual_class<StreamPeer>();