diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-19 09:07:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-19 09:07:07 +0100 |
commit | 417698c2023397f801951358565c6016fd6202f4 (patch) | |
tree | 9b749047304f1a26f0efacba0dd803e18cc83118 /scene | |
parent | 8aed7c1c09e7f6fa902d607d86cc8f6688bf3fb5 (diff) | |
parent | 415042ac89d1c9c7f8ca97fa83fc1165350a01da (diff) |
Merge pull request #58042 from Sauermann/fix-viewport-border-notifications
Fix Viewport mouse enter+exit notifications
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/subviewport_container.cpp | 18 | ||||
-rw-r--r-- | scene/gui/subviewport_container.h | 1 | ||||
-rw-r--r-- | scene/main/node.cpp | 3 | ||||
-rw-r--r-- | scene/main/node.h | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 4 | ||||
-rw-r--r-- | scene/main/window.cpp | 2 |
6 files changed, 28 insertions, 2 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index ce78c286f5..c66e145bc4 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -148,6 +148,24 @@ void SubViewportContainer::_notification(int p_what) { } } } break; + + case NOTIFICATION_MOUSE_ENTER: { + _notify_viewports(NOTIFICATION_VP_MOUSE_ENTER); + } break; + + case NOTIFICATION_MOUSE_EXIT: { + _notify_viewports(NOTIFICATION_VP_MOUSE_EXIT); + } break; + } +} + +void SubViewportContainer::_notify_viewports(int p_notification) { + for (int i = 0; i < get_child_count(); i++) { + SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); + if (!c) { + continue; + } + c->notification(p_notification); } } diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index 3138a6144c..f52f01e4e2 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -38,6 +38,7 @@ class SubViewportContainer : public Container { bool stretch = false; int shrink = 1; + void _notify_viewports(int p_notification); protected: void _notification(int p_what); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 560e1eccbb..211667ce38 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2863,6 +2863,9 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_CLOSE_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_SIZE_CHANGED); + BIND_CONSTANT(NOTIFICATION_WM_DPI_CHANGE); + BIND_CONSTANT(NOTIFICATION_VP_MOUSE_ENTER); + BIND_CONSTANT(NOTIFICATION_VP_MOUSE_EXIT); BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING); BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED); BIND_CONSTANT(NOTIFICATION_WM_ABOUT); diff --git a/scene/main/node.h b/scene/main/node.h index 48412bbf94..8e49f871a7 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -268,6 +268,8 @@ public: NOTIFICATION_WM_GO_BACK_REQUEST = 1007, NOTIFICATION_WM_SIZE_CHANGED = 1008, NOTIFICATION_WM_DPI_CHANGE = 1009, + NOTIFICATION_VP_MOUSE_ENTER = 1010, + NOTIFICATION_VP_MOUSE_EXIT = 1011, NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING, NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED, diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 2831e76fba..691482808a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -496,11 +496,11 @@ void Viewport::_notification(int p_what) { #endif // _3D_DISABLED } break; - case NOTIFICATION_WM_MOUSE_ENTER: { + case NOTIFICATION_VP_MOUSE_ENTER: { gui.mouse_in_window = true; } break; - case NOTIFICATION_WM_MOUSE_EXIT: { + case NOTIFICATION_VP_MOUSE_EXIT: { gui.mouse_in_window = false; _drop_physics_mouseover(); _drop_mouse_over(); diff --git a/scene/main/window.cpp b/scene/main/window.cpp index e7a575f40a..0ce556d36c 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -340,9 +340,11 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: { _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER); emit_signal(SNAME("mouse_entered")); + notification(NOTIFICATION_VP_MOUSE_ENTER); DisplayServer::get_singleton()->cursor_set_shape(DisplayServer::CURSOR_ARROW); //restore cursor shape } break; case DisplayServer::WINDOW_EVENT_MOUSE_EXIT: { + notification(NOTIFICATION_VP_MOUSE_EXIT); _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_EXIT); emit_signal(SNAME("mouse_exited")); } break; |