summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp87
1 files changed, 85 insertions, 2 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 76b281ebac..ee9323ca1d 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2028,6 +2028,89 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
+ Ref<InputEventScreenTouch> touch_event = p_event;
+ if (touch_event.is_valid()) {
+
+ Size2 pos = touch_event->get_position();
+ if (touch_event->is_pressed()) {
+
+ Control *over = _gui_find_control(pos);
+ if (over) {
+
+ if (!gui.modal_stack.empty()) {
+
+ Control *top = gui.modal_stack.back()->get();
+ if (over != top && !top->is_a_parent_of(over)) {
+
+ return;
+ }
+ }
+ if (over->can_process()) {
+
+ touch_event = touch_event->xformed_by(Transform2D()); //make a copy
+ if (over == gui.mouse_focus) {
+ pos = gui.focus_inv_xform.xform(pos);
+ } else {
+ pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
+ }
+ touch_event->set_position(pos);
+ _gui_call_input(over, touch_event);
+ }
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ } else if (gui.mouse_focus) {
+
+ if (gui.mouse_focus->can_process()) {
+
+ touch_event = touch_event->xformed_by(Transform2D()); //make a copy
+ touch_event->set_position(gui.focus_inv_xform.xform(pos));
+
+ _gui_call_input(gui.mouse_focus, touch_event);
+ }
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ }
+
+ Ref<InputEventScreenDrag> drag_event = p_event;
+ if (drag_event.is_valid()) {
+
+ Control *over = gui.mouse_focus;
+ if (!over) {
+ over = _gui_find_control(drag_event->get_position());
+ }
+ if (over) {
+
+ if (!gui.modal_stack.empty()) {
+
+ Control *top = gui.modal_stack.back()->get();
+ if (over != top && !top->is_a_parent_of(over)) {
+
+ return;
+ }
+ }
+ if (over->can_process()) {
+
+ Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
+ Size2 pos = localizer.xform(drag_event->get_position());
+ Vector2 speed = localizer.basis_xform(drag_event->get_speed());
+ Vector2 rel = localizer.basis_xform(drag_event->get_relative());
+
+ drag_event = drag_event->xformed_by(Transform2D()); //make a copy
+
+ drag_event->set_speed(speed);
+ drag_event->set_relative(rel);
+ drag_event->set_position(pos);
+
+ _gui_call_input(over, drag_event);
+ }
+
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ }
+
if (mm.is_null() && mb.is_null() && p_event->is_action_type()) {
if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
@@ -2303,7 +2386,7 @@ List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
gui.modal_stack.push_back(p_control);
if (gui.key_focus)
- p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_ID());
+ p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_id());
else
p_control->_modal_set_prev_focus_owner(0);
@@ -2769,7 +2852,7 @@ Viewport::Viewport() {
set_shadow_atlas_quadrant_subdiv(2, SHADOW_ATLAS_QUADRANT_SUBDIV_16);
set_shadow_atlas_quadrant_subdiv(3, SHADOW_ATLAS_QUADRANT_SUBDIV_64);
- String id = itos(get_instance_ID());
+ String id = itos(get_instance_id());
input_group = "_vp_input" + id;
gui_input_group = "_vp_gui_input" + id;
unhandled_input_group = "_vp_unhandled_input" + id;