diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/control.cpp | 5 | ||||
-rw-r--r-- | scene/gui/control.h | 1 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 4 | ||||
-rw-r--r-- | scene/main/window.cpp | 5 | ||||
-rw-r--r-- | scene/main/window.h | 1 |
6 files changed, 16 insertions, 4 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fdf10e2f42..9f715be155 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1825,6 +1825,10 @@ Size2 Control::get_size() const { return data.size_cache; } +void Control::reset_size() { + set_size(Size2()); +} + Rect2 Control::get_global_rect() const { return Rect2(get_global_position(), get_size()); } @@ -2845,6 +2849,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_position", "position", "keep_offsets"), &Control::set_position, DEFVAL(false)); ClassDB::bind_method(D_METHOD("_set_position", "position"), &Control::_set_position); ClassDB::bind_method(D_METHOD("set_size", "size", "keep_offsets"), &Control::set_size, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("reset_size"), &Control::reset_size); ClassDB::bind_method(D_METHOD("_set_size", "size"), &Control::_set_size); ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); ClassDB::bind_method(D_METHOD("set_global_position", "position", "keep_offsets"), &Control::set_global_position, DEFVAL(false)); diff --git a/scene/gui/control.h b/scene/gui/control.h index 2eb714eae6..1a94cc68a6 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -401,6 +401,7 @@ public: void set_size(const Size2 &p_size, bool p_keep_offsets = false); Size2 get_size() const; + void reset_size(); Rect2 get_rect() const; Rect2 get_global_rect() const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 4a85cf2c45..69b08fda3c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -228,7 +228,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { if (b->is_pressed() && b->get_button_index() == MouseButton::RIGHT && context_menu_enabled) { _ensure_menu(); menu->set_position(get_screen_transform().xform(get_local_mouse_position())); - menu->set_size(Vector2(1, 1)); + menu->reset_size(); menu->popup(); grab_focus(); accept_event(); @@ -393,7 +393,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { _ensure_menu(); Point2 pos = Point2(get_caret_pixel_pos().x, (get_size().y + get_theme_font(SNAME("font"))->get_height(get_theme_font_size(SNAME("font_size")))) / 2); menu->set_position(get_global_transform().xform(pos)); - menu->set_size(Vector2(1, 1)); + menu->reset_size(); menu->popup(); menu->grab_focus(); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index ad1790f61d..c8f6ecdafd 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1595,7 +1595,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { _generate_context_menu(); menu->set_position(get_screen_transform().xform(mpos)); - menu->set_size(Vector2(1, 1)); + menu->reset_size(); menu->popup(); grab_focus(); } @@ -1828,7 +1828,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { _generate_context_menu(); adjust_viewport_to_caret(); menu->set_position(get_screen_transform().xform(get_caret_draw_pos())); - menu->set_size(Vector2(1, 1)); + menu->reset_size(); menu->popup(); menu->grab_focus(); } diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 5da5a183f7..20f8b30dc6 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -88,6 +88,10 @@ Size2i Window::get_size() const { return size; } +void Window::reset_size() { + set_size(Size2i()); +} + Size2i Window::get_real_size() const { if (window_id != DisplayServer::INVALID_WINDOW_ID) { return DisplayServer::get_singleton()->window_get_real_size(window_id); @@ -1410,6 +1414,7 @@ void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("set_size", "size"), &Window::set_size); ClassDB::bind_method(D_METHOD("get_size"), &Window::get_size); + ClassDB::bind_method(D_METHOD("reset_size"), &Window::reset_size); ClassDB::bind_method(D_METHOD("get_real_size"), &Window::get_real_size); diff --git a/scene/main/window.h b/scene/main/window.h index def6eab7b8..0b1075ff76 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -178,6 +178,7 @@ public: void set_size(const Size2i &p_size); Size2i get_size() const; + void reset_size(); Size2i get_real_size() const; |