diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/viewport.cpp | 1 | ||||
-rw-r--r-- | scene/main/window.cpp | 20 | ||||
-rw-r--r-- | scene/main/window.h | 5 |
3 files changed, 26 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 7ca1f9d3ec..9c7e04c433 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1256,6 +1256,7 @@ void Viewport::_gui_show_tooltip() { panel->set_transient(true); panel->set_flag(Window::FLAG_NO_FOCUS, true); panel->set_flag(Window::FLAG_POPUP, false); + panel->set_flag(Window::FLAG_MOUSE_PASSTHROUGH, true); panel->set_wrap_controls(true); panel->add_child(base_tooltip); panel->gui_parent = this; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index c5dbfffd7b..4baedc8c14 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -489,6 +489,7 @@ void Window::_make_window() { ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID); DisplayServer::get_singleton()->window_set_max_size(Size2i(), window_id); DisplayServer::get_singleton()->window_set_min_size(Size2i(), window_id); + DisplayServer::get_singleton()->window_set_mouse_passthrough(mpath, window_id); String tr_title = atr(title); #ifdef DEBUG_ENABLED if (window_id == DisplayServer::MAIN_WINDOW_ID) { @@ -1235,6 +1236,18 @@ DisplayServer::WindowID Window::get_window_id() const { return window_id; } +void Window::set_mouse_passthrough_polygon(const Vector<Vector2> &p_region) { + mpath = p_region; + if (window_id == DisplayServer::INVALID_WINDOW_ID) { + return; + } + DisplayServer::get_singleton()->window_set_mouse_passthrough(mpath, window_id); +} + +Vector<Vector2> Window::get_mouse_passthrough_polygon() const { + return mpath; +} + void Window::set_wrap_controls(bool p_enable) { wrap_controls = p_enable; if (wrap_controls) { @@ -2163,6 +2176,9 @@ void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &Window::set_use_font_oversampling); ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &Window::is_using_font_oversampling); + ClassDB::bind_method(D_METHOD("set_mouse_passthrough_polygon", "polygon"), &Window::set_mouse_passthrough_polygon); + ClassDB::bind_method(D_METHOD("get_mouse_passthrough_polygon"), &Window::get_mouse_passthrough_polygon); + ClassDB::bind_method(D_METHOD("set_wrap_controls", "enable"), &Window::set_wrap_controls); ClassDB::bind_method(D_METHOD("is_wrapping_controls"), &Window::is_wrapping_controls); ClassDB::bind_method(D_METHOD("child_controls_changed"), &Window::child_controls_changed); @@ -2243,6 +2259,8 @@ void Window::_bind_methods() { } ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen", PROPERTY_HINT_ENUM, screen_hints), "set_current_screen", "get_current_screen"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "mouse_passthrough_polygon"), "set_mouse_passthrough_polygon", "get_mouse_passthrough_polygon"); + ADD_GROUP("Flags", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls"); @@ -2255,6 +2273,7 @@ void Window::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unfocusable"), "set_flag", "get_flag", FLAG_NO_FOCUS); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "popup_window"), "set_flag", "get_flag", FLAG_POPUP); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "extend_to_title"), "set_flag", "get_flag", FLAG_EXTEND_TO_TITLE); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "mouse_passthrough"), "set_flag", "get_flag", FLAG_MOUSE_PASSTHROUGH); ADD_GROUP("Limits", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size", PROPERTY_HINT_NONE, "suffix:px"), "set_min_size", "get_min_size"); @@ -2302,6 +2321,7 @@ void Window::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_NO_FOCUS); BIND_ENUM_CONSTANT(FLAG_POPUP); BIND_ENUM_CONSTANT(FLAG_EXTEND_TO_TITLE); + BIND_ENUM_CONSTANT(FLAG_MOUSE_PASSTHROUGH); BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_DISABLED); diff --git a/scene/main/window.h b/scene/main/window.h index b4887437a1..d819ca7c60 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -59,6 +59,7 @@ public: FLAG_NO_FOCUS = DisplayServer::WINDOW_FLAG_NO_FOCUS, FLAG_POPUP = DisplayServer::WINDOW_FLAG_POPUP, FLAG_EXTEND_TO_TITLE = DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE, + FLAG_MOUSE_PASSTHROUGH = DisplayServer::WINDOW_FLAG_MOUSE_PASSTHROUGH, FLAG_MAX = DisplayServer::WINDOW_FLAG_MAX, }; @@ -101,6 +102,7 @@ private: mutable Size2i size = Size2i(DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_SIZE); mutable Size2i min_size; mutable Size2i max_size; + mutable Vector<Vector2> mpath; mutable Mode mode = MODE_WINDOWED; mutable bool flags[FLAG_MAX] = {}; bool visible = true; @@ -281,6 +283,9 @@ public: void set_use_font_oversampling(bool p_oversampling); bool is_using_font_oversampling() const; + void set_mouse_passthrough_polygon(const Vector<Vector2> &p_region); + Vector<Vector2> get_mouse_passthrough_polygon() const; + void set_wrap_controls(bool p_enable); bool is_wrapping_controls() const; void child_controls_changed(); |