|
@@ -1402,7 +1402,7 @@ Control *Viewport::gui_find_control(const Point2 &p_global) {
|
|
xform = sw->get_canvas_transform();
|
|
xform = sw->get_canvas_transform();
|
|
}
|
|
}
|
|
|
|
|
|
- Control *ret = _gui_find_control_at_pos(sw, p_global, xform, gui.focus_inv_xform);
|
|
|
|
|
|
+ Control *ret = _gui_find_control_at_pos(sw, p_global, xform);
|
|
if (ret) {
|
|
if (ret) {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1411,7 +1411,7 @@ Control *Viewport::gui_find_control(const Point2 &p_global) {
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
-Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform) {
|
|
|
|
|
|
+Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform) {
|
|
if (!p_node->is_visible()) {
|
|
if (!p_node->is_visible()) {
|
|
return nullptr; // Canvas item hidden, discard.
|
|
return nullptr; // Canvas item hidden, discard.
|
|
}
|
|
}
|
|
@@ -1431,7 +1431,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- Control *ret = _gui_find_control_at_pos(ci, p_global, matrix, r_inv_xform);
|
|
|
|
|
|
+ Control *ret = _gui_find_control_at_pos(ci, p_global, matrix);
|
|
if (ret) {
|
|
if (ret) {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1449,7 +1449,6 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
|
|
|
|
|
|
Control *drag_preview = _gui_get_drag_preview();
|
|
Control *drag_preview = _gui_get_drag_preview();
|
|
if (!drag_preview || (c != drag_preview && !drag_preview->is_ancestor_of(c))) {
|
|
if (!drag_preview || (c != drag_preview && !drag_preview->is_ancestor_of(c))) {
|
|
- r_inv_xform = matrix;
|
|
|
|
return c;
|
|
return c;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1496,12 +1495,11 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
|
|
|
|
Point2 mpos = mb->get_position();
|
|
Point2 mpos = mb->get_position();
|
|
if (mb->is_pressed()) {
|
|
if (mb->is_pressed()) {
|
|
- Size2 pos = mpos;
|
|
|
|
if (!gui.mouse_focus_mask.is_empty()) {
|
|
if (!gui.mouse_focus_mask.is_empty()) {
|
|
// Do not steal mouse focus and stuff while a focus mask exists.
|
|
// Do not steal mouse focus and stuff while a focus mask exists.
|
|
gui.mouse_focus_mask.set_flag(mouse_button_to_mask(mb->get_button_index()));
|
|
gui.mouse_focus_mask.set_flag(mouse_button_to_mask(mb->get_button_index()));
|
|
} else {
|
|
} else {
|
|
- gui.mouse_focus = gui_find_control(pos);
|
|
|
|
|
|
+ gui.mouse_focus = gui_find_control(mpos);
|
|
gui.last_mouse_focus = gui.mouse_focus;
|
|
gui.last_mouse_focus = gui.mouse_focus;
|
|
|
|
|
|
if (!gui.mouse_focus) {
|
|
if (!gui.mouse_focus) {
|
|
@@ -1520,10 +1518,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
|
|
|
|
mb = mb->xformed_by(Transform2D()); // Make a copy of the event.
|
|
mb = mb->xformed_by(Transform2D()); // Make a copy of the event.
|
|
|
|
|
|
- mb->set_global_position(pos);
|
|
|
|
-
|
|
|
|
- pos = gui.focus_inv_xform.xform(pos);
|
|
|
|
-
|
|
|
|
|
|
+ Point2 pos = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(mpos);
|
|
mb->set_position(pos);
|
|
mb->set_position(pos);
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
@@ -1587,11 +1582,8 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- Size2 pos = mpos;
|
|
|
|
-
|
|
|
|
mb = mb->xformed_by(Transform2D()); // Make a copy.
|
|
mb = mb->xformed_by(Transform2D()); // Make a copy.
|
|
- mb->set_global_position(pos);
|
|
|
|
- pos = gui.focus_inv_xform.xform(pos);
|
|
|
|
|
|
+ Point2 pos = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(mpos);
|
|
mb->set_position(pos);
|
|
mb->set_position(pos);
|
|
|
|
|
|
Control *mouse_focus = gui.mouse_focus;
|
|
Control *mouse_focus = gui.mouse_focus;
|
|
@@ -1894,11 +1886,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
bool stopped = false;
|
|
bool stopped = false;
|
|
if (over->can_process()) {
|
|
if (over->can_process()) {
|
|
touch_event = touch_event->xformed_by(Transform2D()); // Make a copy.
|
|
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);
|
|
|
|
- }
|
|
|
|
|
|
+ pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
|
|
touch_event->set_position(pos);
|
|
touch_event->set_position(pos);
|
|
stopped = _gui_call_input(over, touch_event);
|
|
stopped = _gui_call_input(over, touch_event);
|
|
}
|
|
}
|
|
@@ -1913,11 +1901,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
Control *over = control_id.is_valid() ? Object::cast_to<Control>(ObjectDB::get_instance(control_id)) : nullptr;
|
|
Control *over = control_id.is_valid() ? Object::cast_to<Control>(ObjectDB::get_instance(control_id)) : nullptr;
|
|
if (over && over->can_process()) {
|
|
if (over && over->can_process()) {
|
|
touch_event = touch_event->xformed_by(Transform2D()); // Make a copy.
|
|
touch_event = touch_event->xformed_by(Transform2D()); // Make a copy.
|
|
- if (over == gui.last_mouse_focus) {
|
|
|
|
- pos = gui.focus_inv_xform.xform(pos);
|
|
|
|
- } else {
|
|
|
|
- pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
|
|
|
|
- }
|
|
|
|
|
|
+ pos = gui.last_mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(pos);
|
|
touch_event->set_position(pos);
|
|
touch_event->set_position(pos);
|
|
|
|
|
|
stopped = _gui_call_input(over, touch_event);
|
|
stopped = _gui_call_input(over, touch_event);
|
|
@@ -1943,11 +1927,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|
bool stopped = false;
|
|
bool stopped = false;
|
|
if (over->can_process()) {
|
|
if (over->can_process()) {
|
|
gesture_event = gesture_event->xformed_by(Transform2D()); // Make a copy.
|
|
gesture_event = gesture_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);
|
|
|
|
- }
|
|
|
|
|
|
+ pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
|
|
gesture_event->set_position(pos);
|
|
gesture_event->set_position(pos);
|
|
stopped = _gui_call_input(over, gesture_event);
|
|
stopped = _gui_call_input(over, gesture_event);
|
|
}
|
|
}
|
|
@@ -2394,7 +2374,6 @@ void Viewport::_post_gui_grab_click_focus() {
|
|
}
|
|
}
|
|
|
|
|
|
gui.mouse_focus = focus_grabber;
|
|
gui.mouse_focus = focus_grabber;
|
|
- gui.focus_inv_xform = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse();
|
|
|
|
click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
|
|
click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|