From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- scene/gui/base_button.cpp | 45 ----- scene/gui/base_button.h | 3 - scene/gui/box_container.cpp | 15 -- scene/gui/box_container.h | 3 - scene/gui/button.cpp | 27 --- scene/gui/button.h | 1 - scene/gui/center_container.cpp | 9 - scene/gui/center_container.h | 1 - scene/gui/check_box.cpp | 5 - scene/gui/check_box.h | 1 - scene/gui/check_button.cpp | 6 - scene/gui/check_button.h | 1 - scene/gui/color_picker.cpp | 53 ------ scene/gui/color_picker.h | 2 - scene/gui/color_rect.cpp | 5 - scene/gui/container.cpp | 15 -- scene/gui/container.h | 1 - scene/gui/control.cpp | 212 ---------------------- scene/gui/control.h | 3 - scene/gui/dialogs.cpp | 24 --- scene/gui/dialogs.h | 2 - scene/gui/file_dialog.cpp | 78 -------- scene/gui/file_dialog.h | 1 - scene/gui/gradient_edit.cpp | 18 -- scene/gui/gradient_edit.h | 1 - scene/gui/graph_edit.cpp | 104 ----------- scene/gui/graph_edit.h | 3 - scene/gui/graph_node.cpp | 52 ------ scene/gui/graph_node.h | 1 - scene/gui/grid_container.cpp | 9 - scene/gui/grid_container.h | 1 - scene/gui/item_list.cpp | 126 ------------- scene/gui/item_list.h | 2 - scene/gui/label.cpp | 58 ------ scene/gui/label.h | 2 - scene/gui/line_edit.cpp | 101 ----------- scene/gui/line_edit.h | 2 - scene/gui/link_button.cpp | 14 -- scene/gui/link_button.h | 1 - scene/gui/margin_container.cpp | 6 - scene/gui/menu_button.cpp | 14 -- scene/gui/menu_button.h | 1 - scene/gui/nine_patch_rect.cpp | 15 -- scene/gui/nine_patch_rect.h | 1 - scene/gui/option_button.cpp | 39 ---- scene/gui/option_button.h | 1 - scene/gui/panel.cpp | 2 - scene/gui/panel.h | 1 - scene/gui/panel_container.cpp | 6 - scene/gui/panel_container.h | 1 - scene/gui/popup.cpp | 12 -- scene/gui/popup.h | 2 - scene/gui/popup_menu.cpp | 131 -------------- scene/gui/popup_menu.h | 1 - scene/gui/progress_bar.cpp | 8 - scene/gui/progress_bar.h | 1 - scene/gui/range.cpp | 34 ---- scene/gui/range.h | 1 - scene/gui/reference_rect.cpp | 2 - scene/gui/reference_rect.h | 1 - scene/gui/rich_text_effect.cpp | 1 - scene/gui/rich_text_label.cpp | 175 ------------------ scene/gui/rich_text_label.h | 3 - scene/gui/scroll_bar.cpp | 64 ------- scene/gui/scroll_bar.h | 4 - scene/gui/scroll_container.cpp | 42 ----- scene/gui/scroll_container.h | 1 - scene/gui/separator.cpp | 8 - scene/gui/separator.h | 3 - scene/gui/shortcut.cpp | 6 - scene/gui/shortcut.h | 1 - scene/gui/slider.cpp | 27 --- scene/gui/slider.h | 3 - scene/gui/spin_box.cpp | 33 ---- scene/gui/spin_box.h | 1 - scene/gui/split_container.cpp | 35 ---- scene/gui/split_container.h | 3 - scene/gui/subviewport_container.cpp | 20 --- scene/gui/subviewport_container.h | 1 - scene/gui/tab_container.cpp | 56 ------ scene/gui/tab_container.h | 1 - scene/gui/tabs.cpp | 58 ------ scene/gui/tabs.h | 2 - scene/gui/text_edit.cpp | 321 --------------------------------- scene/gui/text_edit.h | 7 - scene/gui/texture_button.cpp | 22 --- scene/gui/texture_button.h | 1 - scene/gui/texture_progress.cpp | 10 -- scene/gui/texture_progress.h | 1 - scene/gui/texture_rect.cpp | 16 -- scene/gui/texture_rect.h | 1 - scene/gui/tree.cpp | 345 ------------------------------------ scene/gui/tree.h | 6 - scene/gui/video_player.cpp | 43 ----- scene/gui/video_player.h | 2 - 95 files changed, 2611 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 1cdc6f8057..79e1102f6b 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -35,7 +35,6 @@ #include "scene/scene_string_names.h" void BaseButton::_unpress_group() { - if (!button_group.is_valid()) return; @@ -52,7 +51,6 @@ void BaseButton::_unpress_group() { } void BaseButton::_gui_input(Ref p_event) { - if (status.disabled) // no interaction with disabled button return; @@ -78,9 +76,7 @@ void BaseButton::_gui_input(Ref p_event) { } void BaseButton::_notification(int p_what) { - if (p_what == NOTIFICATION_MOUSE_ENTER) { - status.hovering = true; update(); } @@ -90,7 +86,6 @@ void BaseButton::_notification(int p_what) { update(); } if (p_what == NOTIFICATION_DRAG_BEGIN || p_what == NOTIFICATION_SCROLL_BEGIN) { - if (status.press_attempt) { status.press_attempt = false; update(); @@ -98,13 +93,11 @@ void BaseButton::_notification(int p_what) { } if (p_what == NOTIFICATION_FOCUS_ENTER) { - status.hovering = true; update(); } if (p_what == NOTIFICATION_FOCUS_EXIT) { - if (status.press_attempt) { status.press_attempt = false; status.hovering = false; @@ -116,7 +109,6 @@ void BaseButton::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE || (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree())) { - if (!toggle_mode) { status.pressed = false; } @@ -127,7 +119,6 @@ void BaseButton::_notification(int p_what) { } void BaseButton::_pressed() { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_pressed); } @@ -136,7 +127,6 @@ void BaseButton::_pressed() { } void BaseButton::_toggled(bool p_pressed) { - if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, p_pressed); } @@ -145,7 +135,6 @@ void BaseButton::_toggled(bool p_pressed) { } void BaseButton::on_action_event(Ref p_event) { - if (p_event->is_pressed()) { status.press_attempt = true; status.pressing_inside = true; @@ -210,12 +199,10 @@ void BaseButton::set_disabled(bool p_disabled) { } bool BaseButton::is_disabled() const { - return status.disabled; } void BaseButton::set_pressed(bool p_pressed) { - if (!toggle_mode) return; if (status.pressed == p_pressed) @@ -232,22 +219,18 @@ void BaseButton::set_pressed(bool p_pressed) { } bool BaseButton::is_pressing() const { - return status.press_attempt; } bool BaseButton::is_pressed() const { - return toggle_mode ? status.pressed : status.press_attempt; } bool BaseButton::is_hovered() const { - return status.hovering; } BaseButton::DrawMode BaseButton::get_draw_mode() const { - if (status.disabled) { return DRAW_DISABLED; }; @@ -262,12 +245,10 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { bool pressing; if (status.press_attempt) { - pressing = (status.pressing_inside || keep_pressed_outside); if (status.pressed) pressing = !pressing; } else { - pressing = status.pressed; } @@ -281,47 +262,38 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { } void BaseButton::set_toggle_mode(bool p_on) { - toggle_mode = p_on; } bool BaseButton::is_toggle_mode() const { - return toggle_mode; } void BaseButton::set_shortcut_in_tooltip(bool p_on) { - shortcut_in_tooltip = p_on; } bool BaseButton::is_shortcut_in_tooltip_enabled() const { - return shortcut_in_tooltip; } void BaseButton::set_action_mode(ActionMode p_mode) { - action_mode = p_mode; } BaseButton::ActionMode BaseButton::get_action_mode() const { - return action_mode; } void BaseButton::set_button_mask(int p_mask) { - button_mask = p_mask; } int BaseButton::get_button_mask() const { - return button_mask; } void BaseButton::set_enabled_focus_mode(FocusMode p_mode) { - enabled_focus_mode = p_mode; if (!status.disabled) { set_focus_mode(p_mode); @@ -329,22 +301,18 @@ void BaseButton::set_enabled_focus_mode(FocusMode p_mode) { } Control::FocusMode BaseButton::get_enabled_focus_mode() const { - return enabled_focus_mode; } void BaseButton::set_keep_pressed_outside(bool p_on) { - keep_pressed_outside = p_on; } bool BaseButton::is_keep_pressed_outside() const { - return keep_pressed_outside; } void BaseButton::set_shortcut(const Ref &p_shortcut) { - shortcut = p_shortcut; set_process_unhandled_input(shortcut.is_valid()); } @@ -354,15 +322,12 @@ Ref BaseButton::get_shortcut() const { } void BaseButton::_unhandled_input(Ref p_event) { - if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { - on_action_event(p_event); } } String BaseButton::get_tooltip(const Point2 &p_pos) const { - String tooltip = Control::get_tooltip(p_pos); if (shortcut_in_tooltip && shortcut.is_valid() && shortcut->is_valid()) { String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")"; @@ -375,7 +340,6 @@ String BaseButton::get_tooltip(const Point2 &p_pos) const { } void BaseButton::set_button_group(const Ref &p_group) { - if (button_group.is_valid()) { button_group->buttons.erase(this); } @@ -390,12 +354,10 @@ void BaseButton::set_button_group(const Ref &p_group) { } Ref BaseButton::get_button_group() const { - return button_group; } void BaseButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &BaseButton::_gui_input); ClassDB::bind_method(D_METHOD("_unhandled_input"), &BaseButton::_unhandled_input); ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &BaseButton::set_pressed); @@ -452,7 +414,6 @@ void BaseButton::_bind_methods() { } BaseButton::BaseButton() { - toggle_mode = false; shortcut_in_tooltip = true; keep_pressed_outside = false; @@ -468,21 +429,18 @@ BaseButton::BaseButton() { } BaseButton::~BaseButton() { - if (button_group.is_valid()) { button_group->buttons.erase(this); } } void ButtonGroup::get_buttons(List *r_buttons) { - for (Set::Element *E = buttons.front(); E; E = E->next()) { r_buttons->push_back(E->get()); } } Array ButtonGroup::_get_buttons() { - Array btns; for (Set::Element *E = buttons.front(); E; E = E->next()) { btns.push_back(E->get()); @@ -492,7 +450,6 @@ Array ButtonGroup::_get_buttons() { } BaseButton *ButtonGroup::get_pressed_button() { - for (Set::Element *E = buttons.front(); E; E = E->next()) { if (E->get()->is_pressed()) return E->get(); @@ -502,12 +459,10 @@ BaseButton *ButtonGroup::get_pressed_button() { } void ButtonGroup::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button); ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons); } ButtonGroup::ButtonGroup() { - set_local_to_scene(true); } diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index 21757488a6..05a975e266 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -36,7 +36,6 @@ class ButtonGroup; class BaseButton : public Control { - GDCLASS(BaseButton, Control); public: @@ -55,7 +54,6 @@ private: ActionMode action_mode; struct Status { - bool pressed; bool hovering; bool press_attempt; @@ -136,7 +134,6 @@ VARIANT_ENUM_CAST(BaseButton::DrawMode) VARIANT_ENUM_CAST(BaseButton::ActionMode) class ButtonGroup : public Resource { - GDCLASS(ButtonGroup, Resource); friend class BaseButton; Set buttons; diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 0da6e0fdfa..5252f3f2f2 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -33,14 +33,12 @@ #include "margin_container.h" struct _MinSizeCache { - int min_size; bool will_stretch; int final_size; }; void BoxContainer::_resort() { - /** First pass, determine minimum size AND amount of stretchable elements */ Size2i new_size = get_size(); @@ -105,7 +103,6 @@ void BoxContainer::_resort() { bool refit_successful = true; //assume refit-test will go well for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; @@ -158,7 +155,6 @@ void BoxContainer::_resort() { int idx = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; @@ -187,10 +183,8 @@ void BoxContainer::_resort() { Rect2 rect; if (vertical) { - rect = Rect2(0, from, new_size.width, size); } else { - rect = Rect2(from, 0, size, new_size.height); } @@ -202,7 +196,6 @@ void BoxContainer::_resort() { } Size2 BoxContainer::get_minimum_size() const { - /* Calculate MINIMUM SIZE */ Size2i minimum; @@ -247,15 +240,11 @@ Size2 BoxContainer::get_minimum_size() const { } void BoxContainer::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_SORT_CHILDREN: { - _resort(); } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); } break; } @@ -271,7 +260,6 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const { } void BoxContainer::add_spacer(bool p_begin) { - Control *c = memnew(Control); c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events @@ -286,13 +274,11 @@ void BoxContainer::add_spacer(bool p_begin) { } BoxContainer::BoxContainer(bool p_vertical) { - vertical = p_vertical; align = ALIGN_BEGIN; } void BoxContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_spacer", "begin"), &BoxContainer::add_spacer); ClassDB::bind_method(D_METHOD("get_alignment"), &BoxContainer::get_alignment); ClassDB::bind_method(D_METHOD("set_alignment", "alignment"), &BoxContainer::set_alignment); @@ -305,7 +291,6 @@ void BoxContainer::_bind_methods() { } MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) { - Label *l = memnew(Label); l->set_text(p_label); add_child(l); diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h index 0d7deda364..cc6f6349df 100644 --- a/scene/gui/box_container.h +++ b/scene/gui/box_container.h @@ -34,7 +34,6 @@ #include "scene/gui/container.h" class BoxContainer : public Container { - GDCLASS(BoxContainer, Container); public: @@ -67,7 +66,6 @@ public: }; class HBoxContainer : public BoxContainer { - GDCLASS(HBoxContainer, BoxContainer); public: @@ -77,7 +75,6 @@ public: class MarginContainer; class VBoxContainer : public BoxContainer { - GDCLASS(VBoxContainer, BoxContainer); public: diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 1f8487c173..cf1ff059bf 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -34,7 +34,6 @@ #include "servers/rendering_server.h" Size2 Button::get_minimum_size() const { - Size2 minsize = get_theme_font("font")->get_string_size(xl_text); if (clip_text) minsize.width = 0; @@ -47,7 +46,6 @@ Size2 Button::get_minimum_size() const { _icon = icon; if (!_icon.is_null()) { - minsize.height = MAX(minsize.height, _icon->get_height()); minsize.width += _icon->get_width(); if (xl_text != "") @@ -59,21 +57,17 @@ Size2 Button::get_minimum_size() const { } void Button::_set_internal_margin(Margin p_margin, float p_value) { - _internal_margin[p_margin] = p_value; } void Button::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_TRANSLATION_CHANGED: { - xl_text = tr(text); minimum_size_changed(); update(); } break; case NOTIFICATION_DRAW: { - RID ci = get_canvas_item(); Size2 size = get_size(); Color color; @@ -83,7 +77,6 @@ void Button::_notification(int p_what) { switch (get_draw_mode()) { case DRAW_NORMAL: { - style = get_theme_stylebox("normal"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -92,7 +85,6 @@ void Button::_notification(int p_what) { color_icon = get_theme_color("icon_color_normal"); } break; case DRAW_HOVER_PRESSED: { - if (has_theme_stylebox("hover_pressed") && has_theme_stylebox_override("hover_pressed")) { style = get_theme_stylebox("hover_pressed"); if (!flat) @@ -109,7 +101,6 @@ void Button::_notification(int p_what) { [[fallthrough]]; } case DRAW_PRESSED: { - style = get_theme_stylebox("pressed"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -122,7 +113,6 @@ void Button::_notification(int p_what) { } break; case DRAW_HOVER: { - style = get_theme_stylebox("hover"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -132,7 +122,6 @@ void Button::_notification(int p_what) { } break; case DRAW_DISABLED: { - style = get_theme_stylebox("disabled"); if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); @@ -144,7 +133,6 @@ void Button::_notification(int p_what) { } if (has_focus()) { - Ref style2 = get_theme_stylebox("focus"); style2->draw(ci, Rect2(Point2(), size)); } @@ -158,7 +146,6 @@ void Button::_notification(int p_what) { Rect2 icon_region = Rect2(); if (!_icon.is_null()) { - int valign = size.height - style->get_minimum_size().y; if (is_disabled()) { color_icon.a = 0.4; @@ -235,7 +222,6 @@ void Button::_notification(int p_what) { } void Button::set_text(const String &p_text) { - if (text == p_text) return; text = p_text; @@ -245,12 +231,10 @@ void Button::set_text(const String &p_text) { minimum_size_changed(); } String Button::get_text() const { - return text; } void Button::set_icon(const Ref &p_icon) { - if (icon == p_icon) return; icon = p_icon; @@ -260,59 +244,49 @@ void Button::set_icon(const Ref &p_icon) { } Ref Button::get_icon() const { - return icon; } void Button::set_expand_icon(bool p_expand_icon) { - expand_icon = p_expand_icon; update(); minimum_size_changed(); } bool Button::is_expand_icon() const { - return expand_icon; } void Button::set_flat(bool p_flat) { - flat = p_flat; update(); _change_notify("flat"); } bool Button::is_flat() const { - return flat; } void Button::set_clip_text(bool p_clip_text) { - clip_text = p_clip_text; update(); minimum_size_changed(); } bool Button::get_clip_text() const { - return clip_text; } void Button::set_text_align(TextAlign p_align) { - align = p_align; update(); } Button::TextAlign Button::get_text_align() const { - return align; } void Button::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_text", "text"), &Button::set_text); ClassDB::bind_method(D_METHOD("get_text"), &Button::get_text); ClassDB::bind_method(D_METHOD("set_button_icon", "texture"), &Button::set_icon); @@ -339,7 +313,6 @@ void Button::_bind_methods() { } Button::Button(const String &p_text) { - flat = false; clip_text = false; expand_icon = false; diff --git a/scene/gui/button.h b/scene/gui/button.h index 3135b98578..e757badd3e 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -34,7 +34,6 @@ #include "scene/gui/base_button.h" class Button : public BaseButton { - GDCLASS(Button, BaseButton); public: diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp index 64d6885bc8..ff2b5ea17e 100644 --- a/scene/gui/center_container.cpp +++ b/scene/gui/center_container.cpp @@ -31,12 +31,10 @@ #include "center_container.h" Size2 CenterContainer::get_minimum_size() const { - if (use_top_left) return Size2(); Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c) continue; @@ -53,7 +51,6 @@ Size2 CenterContainer::get_minimum_size() const { } void CenterContainer::set_use_top_left(bool p_enable) { - if (use_top_left == p_enable) { return; } @@ -65,17 +62,13 @@ void CenterContainer::set_use_top_left(bool p_enable) { } bool CenterContainer::is_using_top_left() const { - return use_top_left; } void CenterContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Size2 size = get_size(); for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to(get_child(i)); if (!c) continue; @@ -90,7 +83,6 @@ void CenterContainer::_notification(int p_what) { } void CenterContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_top_left", "enable"), &CenterContainer::set_use_top_left); ClassDB::bind_method(D_METHOD("is_using_top_left"), &CenterContainer::is_using_top_left); @@ -98,6 +90,5 @@ void CenterContainer::_bind_methods() { } CenterContainer::CenterContainer() { - use_top_left = false; } diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h index 98733f384d..ae9f87db16 100644 --- a/scene/gui/center_container.h +++ b/scene/gui/center_container.h @@ -34,7 +34,6 @@ #include "scene/gui/container.h" class CenterContainer : public Container { - GDCLASS(CenterContainer, Container); bool use_top_left; diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 470450e3ed..8681b9bda7 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -51,7 +51,6 @@ Size2 CheckBox::get_icon_size() const { } Size2 CheckBox::get_minimum_size() const { - Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; @@ -65,12 +64,9 @@ Size2 CheckBox::get_minimum_size() const { } void CheckBox::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED) { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); Ref on = Control::get_theme_icon(is_radio() ? "radio_checked" : "checked"); @@ -89,7 +85,6 @@ void CheckBox::_notification(int p_what) { } bool CheckBox::is_radio() { - return get_button_group().is_valid(); } diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h index 7c8f8c11d6..58f7cce55e 100644 --- a/scene/gui/check_box.h +++ b/scene/gui/check_box.h @@ -36,7 +36,6 @@ @author Mariano Suligoy */ class CheckBox : public Button { - GDCLASS(CheckBox, Button); protected: diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 96484424f8..041a28a0be 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -34,7 +34,6 @@ #include "servers/rendering_server.h" Size2 CheckButton::get_icon_size() const { - Ref on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on"); Ref off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off"); Size2 tex_size = Size2(0, 0); @@ -47,7 +46,6 @@ Size2 CheckButton::get_icon_size() const { } Size2 CheckButton::get_minimum_size() const { - Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; @@ -60,12 +58,9 @@ Size2 CheckButton::get_minimum_size() const { } void CheckButton::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED) { - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); Ref on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on"); @@ -86,7 +81,6 @@ void CheckButton::_notification(int p_what) { } CheckButton::CheckButton() { - set_toggle_mode(true); set_text_align(ALIGN_LEFT); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index 3599c26a4c..8bbad0b4b3 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -36,7 +36,6 @@ @author Juan Linietsky */ class CheckButton : public Button { - GDCLASS(CheckButton, Button); protected: diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 63878a0b26..1730df6bb3 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -41,17 +41,14 @@ #include "scene/main/window.h" void ColorPicker::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); bt_add_preset->set_icon(get_theme_icon("add_preset")); _update_controls(); } break; case NOTIFICATION_ENTER_TREE: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); bt_add_preset->set_icon(get_theme_icon("add_preset")); @@ -68,18 +65,15 @@ void ColorPicker::_notification(int p_what) { #endif } break; case NOTIFICATION_PARENTED: { - for (int i = 0; i < 4; i++) set_margin((Margin)i, get_theme_constant("margin")); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - Popup *p = Object::cast_to(get_parent()); if (p) p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant("margin") * 2, get_combined_minimum_size().height + get_theme_constant("margin") * 2)); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (screen != nullptr && screen->is_visible()) screen->hide(); } break; @@ -87,12 +81,10 @@ void ColorPicker::_notification(int p_what) { } void ColorPicker::set_focus_on_line_edit() { - c_text->call_deferred("grab_focus"); } void ColorPicker::_update_controls() { - const char *rgb[3] = { "R", "G", "B" }; const char *hsv[3] = { "H", "S", "V" }; @@ -127,7 +119,6 @@ void ColorPicker::_update_controls() { } void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) { - color = p_color; if (color != last_hsv) { h = color.get_h(); @@ -143,12 +134,10 @@ void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) { } void ColorPicker::set_pick_color(const Color &p_color) { - _set_pick_color(p_color, true); //because setters can't have more arguments } void ColorPicker::set_edit_alpha(bool p_show) { - edit_alpha = p_show; _update_controls(); @@ -160,12 +149,10 @@ void ColorPicker::set_edit_alpha(bool p_show) { } bool ColorPicker::is_editing_alpha() const { - return edit_alpha; } void ColorPicker::_value_changed(double) { - if (updating) return; @@ -185,7 +172,6 @@ void ColorPicker::_value_changed(double) { } void ColorPicker::_html_entered(const String &p_html) { - if (updating || text_is_constructor || !c_text->is_visible()) return; @@ -202,11 +188,9 @@ void ColorPicker::_html_entered(const String &p_html) { } void ColorPicker::_update_color(bool p_update_sliders) { - updating = true; if (p_update_sliders) { - if (hsv_mode_enabled) { for (int i = 0; i < 4; i++) { scroll[i]->set_step(1.0); @@ -266,7 +250,6 @@ void ColorPicker::_update_presets() { } void ColorPicker::_text_type_toggled() { - text_is_constructor = !text_is_constructor; if (text_is_constructor) { text_type->set_text(""); @@ -283,12 +266,10 @@ void ColorPicker::_text_type_toggled() { } Color ColorPicker::get_pick_color() const { - return color; } void ColorPicker::add_preset(const Color &p_color) { - if (presets.find(p_color)) { presets.move_to_back(presets.find(p_color)); } else { @@ -305,7 +286,6 @@ void ColorPicker::add_preset(const Color &p_color) { } void ColorPicker::erase_preset(const Color &p_color) { - if (presets.find(p_color)) { presets.erase(presets.find(p_color)); preset->update(); @@ -320,7 +300,6 @@ void ColorPicker::erase_preset(const Color &p_color) { } PackedColorArray ColorPicker::get_presets() const { - PackedColorArray arr; arr.resize(presets.size()); for (int i = 0; i < presets.size(); i++) { @@ -330,7 +309,6 @@ PackedColorArray ColorPicker::get_presets() const { } void ColorPicker::set_hsv_mode(bool p_enabled) { - if (hsv_mode_enabled == p_enabled || raw_mode_enabled) return; hsv_mode_enabled = p_enabled; @@ -345,12 +323,10 @@ void ColorPicker::set_hsv_mode(bool p_enabled) { } bool ColorPicker::is_hsv_mode() const { - return hsv_mode_enabled; } void ColorPicker::set_raw_mode(bool p_enabled) { - if (raw_mode_enabled == p_enabled || hsv_mode_enabled) return; raw_mode_enabled = p_enabled; @@ -365,7 +341,6 @@ void ColorPicker::set_raw_mode(bool p_enabled) { } bool ColorPicker::is_raw_mode() const { - return raw_mode_enabled; } @@ -458,7 +433,6 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } void ColorPicker::_uv_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { @@ -501,11 +475,9 @@ void ColorPicker::_uv_input(const Ref &p_event) { } void ColorPicker::_w_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { - if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { changing_color = true; float y = CLAMP((float)bev->get_position().y, 0, w_edit->get_size().height); @@ -526,7 +498,6 @@ void ColorPicker::_w_input(const Ref &p_event) { Ref mev = p_event; if (mev.is_valid()) { - if (!changing_color) return; float y = CLAMP((float)mev->get_position().y, 0, w_edit->get_size().height); @@ -541,7 +512,6 @@ void ColorPicker::_w_input(const Ref &p_event) { } void ColorPicker::_preset_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid()) { @@ -569,7 +539,6 @@ void ColorPicker::_preset_input(const Ref &p_event) { Ref mev = p_event; if (mev.is_valid()) { - int index = mev->get_position().x * presets.size(); if (preset->get_size().x != 0) { index /= preset->get_size().x; @@ -581,7 +550,6 @@ void ColorPicker::_preset_input(const Ref &p_event) { } void ColorPicker::_screen_input(const Ref &p_event) { - Ref bev = p_event; if (bev.is_valid() && bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) { emit_signal("color_changed", color); @@ -596,7 +564,6 @@ void ColorPicker::_screen_input(const Ref &p_event) { Ref img = r->get_texture()->get_data(); if (img.is_valid() && !img->empty()) { - Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position(); Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y); @@ -688,7 +655,6 @@ bool ColorPicker::are_presets_visible() const { } void ColorPicker::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPicker::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPicker::get_pick_color); ClassDB::bind_method(D_METHOD("set_hsv_mode"), &ColorPicker::set_hsv_mode); @@ -722,7 +688,6 @@ void ColorPicker::_bind_methods() { ColorPicker::ColorPicker() : BoxContainer(true) { - updating = true; edit_alpha = true; text_is_constructor = false; @@ -779,7 +744,6 @@ ColorPicker::ColorPicker() : vbr->set_h_size_flags(SIZE_EXPAND_FILL); for (int i = 0; i < 4; i++) { - HBoxContainer *hbc = memnew(HBoxContainer); labels[i] = memnew(Label()); @@ -826,13 +790,11 @@ ColorPicker::ColorPicker() : text_type->set_text("#"); text_type->set_tooltip(TTR("Switch between hexadecimal and code values.")); if (Engine::get_singleton()->is_editor_hint()) { - #ifdef TOOLS_ENABLED text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon. #endif text_type->connect("pressed", callable_mp(this, &ColorPicker::_text_type_toggled)); } else { - text_type->set_flat(true); text_type->set_mouse_filter(MOUSE_FILTER_IGNORE); } @@ -873,19 +835,16 @@ ColorPicker::ColorPicker() : ///////////////// void ColorPickerButton::_color_changed(const Color &p_color) { - color = p_color; update(); emit_signal("color_changed", color); } void ColorPickerButton::_modal_closed() { - emit_signal("popup_closed"); } void ColorPickerButton::pressed() { - _update_picker(); popup->set_as_minsize(); @@ -904,7 +863,6 @@ void ColorPickerButton::pressed() { if (i & 1) { cp_rect.position.x = get_screen_position().x; } else { - cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - get_size().x)); } @@ -918,10 +876,8 @@ void ColorPickerButton::pressed() { } void ColorPickerButton::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { - const Ref normal = get_theme_stylebox("normal"); const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size()); draw_texture_rect(Control::get_theme_icon("bg", "ColorPickerButton"), r, true); @@ -933,7 +889,6 @@ void ColorPickerButton::_notification(int p_what) { } } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (popup) popup->hide(); } break; @@ -947,7 +902,6 @@ void ColorPickerButton::_notification(int p_what) { } void ColorPickerButton::set_pick_color(const Color &p_color) { - color = p_color; if (picker) { picker->set_pick_color(p_color); @@ -956,12 +910,10 @@ void ColorPickerButton::set_pick_color(const Color &p_color) { update(); } Color ColorPickerButton::get_pick_color() const { - return color; } void ColorPickerButton::set_edit_alpha(bool p_show) { - edit_alpha = p_show; if (picker) { picker->set_edit_alpha(p_show); @@ -969,18 +921,15 @@ void ColorPickerButton::set_edit_alpha(bool p_show) { } bool ColorPickerButton::is_editing_alpha() const { - return edit_alpha; } ColorPicker *ColorPickerButton::get_picker() { - _update_picker(); return picker; } PopupPanel *ColorPickerButton::get_popup() { - _update_picker(); return popup; } @@ -1004,7 +953,6 @@ void ColorPickerButton::_update_picker() { } void ColorPickerButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPickerButton::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPickerButton::get_pick_color); ClassDB::bind_method(D_METHOD("get_picker"), &ColorPickerButton::get_picker); @@ -1020,7 +968,6 @@ void ColorPickerButton::_bind_methods() { } ColorPickerButton::ColorPickerButton() { - // Initialization is now done deferred, // this improves performance in the inspector as the color picker // can be expensive to initialize. diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index dde2f37135..31ae92f4e4 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -44,7 +44,6 @@ #include "scene/gui/tool_button.h" class ColorPicker : public BoxContainer { - GDCLASS(ColorPicker, BoxContainer); private: @@ -139,7 +138,6 @@ public: }; class ColorPickerButton : public Button { - GDCLASS(ColorPickerButton, Button); PopupPanel *popup; diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index 61260e153c..627e589c02 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -31,25 +31,21 @@ #include "color_rect.h" void ColorRect::set_frame_color(const Color &p_color) { - color = p_color; update(); } Color ColorRect::get_frame_color() const { - return color; } void ColorRect::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { draw_rect(Rect2(Point2(), get_size()), color); } } void ColorRect::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_frame_color", "color"), &ColorRect::set_frame_color); ClassDB::bind_method(D_METHOD("get_frame_color"), &ColorRect::get_frame_color); @@ -57,6 +53,5 @@ void ColorRect::_bind_methods() { } ColorRect::ColorRect() { - color = Color(1, 1, 1); } diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 41f33bb719..5bde293648 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -33,7 +33,6 @@ #include "scene/scene_string_names.h" void Container::_child_minsize_changed() { - //Size2 ms = get_combined_minimum_size(); //if (ms.width > get_size().width || ms.height > get_size().height) { minimum_size_changed(); @@ -41,7 +40,6 @@ void Container::_child_minsize_changed() { } void Container::add_child_notify(Node *p_child) { - Control::add_child_notify(p_child); Control *control = Object::cast_to(p_child); @@ -57,7 +55,6 @@ void Container::add_child_notify(Node *p_child) { } void Container::move_child_notify(Node *p_child) { - Control::move_child_notify(p_child); if (!Object::cast_to(p_child)) @@ -68,7 +65,6 @@ void Container::move_child_notify(Node *p_child) { } void Container::remove_child_notify(Node *p_child) { - Control::remove_child_notify(p_child); Control *control = Object::cast_to(p_child); @@ -84,7 +80,6 @@ void Container::remove_child_notify(Node *p_child) { } void Container::_sort_children() { - if (!is_inside_tree()) return; @@ -94,7 +89,6 @@ void Container::_sort_children() { } void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) { - ERR_FAIL_COND(!p_child); ERR_FAIL_COND(p_child->get_parent() != this); @@ -133,7 +127,6 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) { } void Container::queue_sort() { - if (!is_inside_tree()) return; @@ -145,23 +138,18 @@ void Container::queue_sort() { } void Container::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { pending_sort = false; queue_sort(); } break; case NOTIFICATION_RESIZED: { - queue_sort(); } break; case NOTIFICATION_THEME_CHANGED: { - queue_sort(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) { queue_sort(); } @@ -170,7 +158,6 @@ void Container::_notification(int p_what) { } String Container::get_configuration_warning() const { - String warning = Control::get_configuration_warning(); if (get_class() == "Container" && get_script().is_null()) { @@ -183,7 +170,6 @@ String Container::get_configuration_warning() const { } void Container::_bind_methods() { - ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children); ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort); @@ -194,7 +180,6 @@ void Container::_bind_methods() { } Container::Container() { - pending_sort = false; // All containers should let mouse events pass by default. set_mouse_filter(MOUSE_FILTER_PASS); diff --git a/scene/gui/container.h b/scene/gui/container.h index 0b736d9790..c8db5ee28f 100644 --- a/scene/gui/container.h +++ b/scene/gui/container.h @@ -34,7 +34,6 @@ #include "scene/gui/control.h" class Container : public Control { - GDCLASS(Container, Control); bool pending_sort; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index b710ba4803..3dbdd4dfab 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -49,7 +49,6 @@ #ifdef TOOLS_ENABLED Dictionary Control::_edit_get_state() const { - Dictionary s; s["rotation"] = get_rotation(); s["scale"] = get_scale(); @@ -70,7 +69,6 @@ Dictionary Control::_edit_get_state() const { } void Control::_edit_set_state(const Dictionary &p_state) { - Dictionary state = p_state; set_rotation(state["rotation"]); @@ -162,7 +160,6 @@ Size2 Control::_edit_get_minimum_size() const { #endif void Control::set_custom_minimum_size(const Size2 &p_custom) { - if (p_custom == data.custom_minimum_size) return; data.custom_minimum_size = p_custom; @@ -170,12 +167,10 @@ void Control::set_custom_minimum_size(const Size2 &p_custom) { } Size2 Control::get_custom_minimum_size() const { - return data.custom_minimum_size; } void Control::_update_minimum_size_cache() { - Size2 minsize = get_minimum_size(); minsize.x = MAX(minsize.x, data.custom_minimum_size.x); minsize.y = MAX(minsize.y, data.custom_minimum_size.y); @@ -192,7 +187,6 @@ void Control::_update_minimum_size_cache() { } Size2 Control::get_combined_minimum_size() const { - if (!data.minimum_size_valid) { const_cast(this)->_update_minimum_size_cache(); } @@ -200,7 +194,6 @@ Size2 Control::get_combined_minimum_size() const { } Transform2D Control::_get_internal_transform() const { - Transform2D rot_scale; rot_scale.set_rotation_and_scale(data.rotation, data.scale); Transform2D offset; @@ -210,14 +203,12 @@ Transform2D Control::_get_internal_transform() const { } bool Control::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (!name.begins_with("custom")) { return false; } if (p_value.get_type() == Variant::NIL) { - if (name.begins_with("custom_icons/")) { String dname = name.get_slicec('/', 1); if (data.icon_override.has(dname)) { @@ -283,7 +274,6 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) { } void Control::_update_minimum_size() { - if (!is_inside_tree()) return; @@ -302,7 +292,6 @@ void Control::_update_minimum_size() { } bool Control::_get(const StringName &p_name, Variant &r_ret) const { - String sname = p_name; if (!sname.begins_with("custom")) { @@ -338,7 +327,6 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const { return true; } void Control::_get_property_list(List *p_list) const { - Ref theme = Theme::get_default(); /* Using the default theme since the properties below are meant for editor only if (data.theme.is_valid()) { @@ -353,7 +341,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_icon_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.icon_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -365,7 +352,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_shader_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.shader_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -377,7 +363,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_stylebox_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.style_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -389,7 +374,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_font_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -401,7 +385,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_color_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.color_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -413,7 +396,6 @@ void Control::_get_property_list(List *p_list) const { List names; theme->get_constant_list(get_class_name(), &names); for (List::Element *E = names.front(); E; E = E->next()) { - uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.constant_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -424,19 +406,16 @@ void Control::_get_property_list(List *p_list) const { } Control *Control::get_parent_control() const { - return data.parent; } void Control::_resize(const Size2 &p_size) { - _size_changed(); } //moved theme configuration here, so controls can set up even if still not inside active scene void Control::add_child_notify(Node *p_child) { - Control *child_c = Object::cast_to(p_child); if (child_c && child_c->data.theme.is_null() && (data.theme_owner || data.theme_owner_window)) { @@ -451,7 +430,6 @@ void Control::add_child_notify(Node *p_child) { } void Control::remove_child_notify(Node *p_child) { - Control *child_c = Object::cast_to(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { @@ -466,7 +444,6 @@ void Control::remove_child_notify(Node *p_child) { } void Control::_update_canvas_item_transform() { - Transform2D xform = _get_internal_transform(); xform[2] += get_position(); @@ -474,24 +451,19 @@ void Control::_update_canvas_item_transform() { } void Control::_notification(int p_notification) { - switch (p_notification) { - case NOTIFICATION_ENTER_TREE: { - } break; case NOTIFICATION_POST_ENTER_TREE: { data.minimum_size_valid = false; _size_changed(); } break; case NOTIFICATION_EXIT_TREE: { - get_viewport()->_gui_remove_control(this); } break; case NOTIFICATION_ENTER_CANVAS: { - data.parent = Object::cast_to(get_parent()); Node *parent = this; //meh @@ -499,7 +471,6 @@ void Control::_notification(int p_notification) { bool subwindow = false; while (parent) { - parent = parent->get_parent(); if (!parent) @@ -516,7 +487,6 @@ void Control::_notification(int p_notification) { if (parent_control) { break; } else if (ci) { - } else { break; } @@ -536,7 +506,6 @@ void Control::_notification(int p_notification) { data.parent_canvas_item = get_parent_item(); if (data.parent_canvas_item) { - data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed)); } else { //connect viewport @@ -544,9 +513,7 @@ void Control::_notification(int p_notification) { } } break; case NOTIFICATION_EXIT_CANVAS: { - if (data.parent_canvas_item) { - data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); data.parent_canvas_item = nullptr; } else if (!is_set_as_toplevel()) { @@ -576,11 +543,9 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_RESIZED: { - emit_signal(SceneStringNames::get_singleton()->resized); } break; case NOTIFICATION_DRAW: { - _update_canvas_item_transform(); RenderingServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size())); RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents); @@ -588,33 +553,26 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_MOUSE_ENTER: { - emit_signal(SceneStringNames::get_singleton()->mouse_entered); } break; case NOTIFICATION_MOUSE_EXIT: { - emit_signal(SceneStringNames::get_singleton()->mouse_exited); } break; case NOTIFICATION_FOCUS_ENTER: { - emit_signal(SceneStringNames::get_singleton()->focus_entered); update(); } break; case NOTIFICATION_FOCUS_EXIT: { - emit_signal(SceneStringNames::get_singleton()->focus_exited); update(); } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); update(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (!is_visible_in_tree()) { - if (get_viewport() != nullptr) get_viewport()->_gui_hid_control(this); @@ -630,14 +588,12 @@ void Control::_notification(int p_notification) { } bool Control::clips_input() const { - if (get_script_instance()) { return get_script_instance()->call(SceneStringNames::get_singleton()->_clips_input); } return false; } bool Control::has_point(const Point2 &p_point) const { - if (get_script_instance()) { Variant v = p_point; const Variant *p = &v; @@ -655,7 +611,6 @@ bool Control::has_point(const Point2 &p_point) const { } void Control::set_drag_forwarding(Control *p_target) { - if (p_target) data.drag_owner = p_target->get_instance_id(); else @@ -663,7 +618,6 @@ void Control::set_drag_forwarding(Control *p_target) { } Variant Control::get_drag_data(const Point2 &p_point) { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -685,7 +639,6 @@ Variant Control::get_drag_data(const Point2 &p_point) { } bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -706,7 +659,6 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const return Variant(); } void Control::drop_data(const Point2 &p_point, const Variant &p_data) { - if (data.drag_owner.is_valid()) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { @@ -727,7 +679,6 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) { } void Control::force_drag(const Variant &p_data, Control *p_control) { - ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(p_data.get_type() == Variant::NIL); @@ -735,17 +686,14 @@ void Control::force_drag(const Variant &p_data, Control *p_control) { } void Control::set_drag_preview(Control *p_control) { - ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!get_viewport()->gui_is_dragging()); get_viewport()->_gui_set_drag_preview(this, p_control); } Size2 Control::get_minimum_size() const { - ScriptInstance *si = const_cast(this)->get_script_instance(); if (si) { - Callable::CallError ce; Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) @@ -756,13 +704,11 @@ Size2 Control::get_minimum_size() const { template bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, T &r_ret, T (Theme::*get_func)(const StringName &, const StringName &) const, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) { - // try with custom themes Control *theme_owner = p_theme_owner; Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - StringName class_name = p_type; while (class_name != StringName()) { @@ -792,7 +738,6 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win theme_owner = parent_w->theme_owner; theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = nullptr; theme_owner_window = nullptr; } @@ -802,13 +747,11 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win } bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) { - // try with custom themes Control *theme_owner = p_theme_owner; Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - StringName class_name = p_type; while (class_name != StringName()) { @@ -836,7 +779,6 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind theme_owner = parent_w->theme_owner; theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = nullptr; theme_owner_window = nullptr; } @@ -846,9 +788,7 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind } Ref Control::get_theme_icon(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { - const Ref *tex = data.icon_override.getptr(p_name); if (tex) return *tex; @@ -860,7 +800,6 @@ Ref Control::get_theme_icon(const StringName &p_name, const StringNam } Ref Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref icon; if (_find_theme_item(p_theme_owner, p_theme_owner_window, icon, &Theme::get_icon, &Theme::has_icon, p_name, p_type)) { @@ -877,9 +816,7 @@ Ref Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_ } Ref Control::get_theme_shader(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { - const Ref *sdr = data.shader_override.getptr(p_name); if (sdr) return *sdr; @@ -891,7 +828,6 @@ Ref Control::get_theme_shader(const StringName &p_name, const StringName } Ref Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref shader; if (_find_theme_item(p_theme_owner, p_theme_owner_window, shader, &Theme::get_shader, &Theme::has_shader, p_name, p_type)) { @@ -908,7 +844,6 @@ Ref Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_w } Ref Control::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Ref *style = data.style_override.getptr(p_name); if (style) @@ -921,7 +856,6 @@ Ref Control::get_theme_stylebox(const StringName &p_name, const String } Ref Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref stylebox; if (_find_theme_item(p_theme_owner, p_theme_owner_window, stylebox, &Theme::get_stylebox, &Theme::has_stylebox, p_name, p_type)) { @@ -938,7 +872,6 @@ Ref Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_own } Ref Control::get_theme_font(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Ref *font = data.font_override.getptr(p_name); if (font) @@ -951,7 +884,6 @@ Ref Control::get_theme_font(const StringName &p_name, const StringName &p_ } Ref Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Ref font; if (_find_theme_item(p_theme_owner, p_theme_owner_window, font, &Theme::get_font, &Theme::has_font, p_name, p_type)) { @@ -968,7 +900,6 @@ Ref Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_windo } Color Control::get_theme_color(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const Color *color = data.color_override.getptr(p_name); if (color) @@ -981,7 +912,6 @@ Color Control::get_theme_color(const StringName &p_name, const StringName &p_typ } Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - Color color; if (_find_theme_item(p_theme_owner, p_theme_owner_window, color, &Theme::get_color, &Theme::has_color, p_name, p_type)) { @@ -997,7 +927,6 @@ Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, } int Control::get_theme_constant(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { const int *constant = data.constant_override.getptr(p_name); if (constant) @@ -1010,7 +939,6 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_ty } int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - int constant; if (_find_theme_item(p_theme_owner, p_theme_owner_window, constant, &Theme::get_constant, &Theme::has_constant, p_name, p_type)) { @@ -1026,43 +954,36 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, } bool Control::has_theme_icon_override(const StringName &p_name) const { - const Ref *tex = data.icon_override.getptr(p_name); return tex != nullptr; } bool Control::has_theme_shader_override(const StringName &p_name) const { - const Ref *sdr = data.shader_override.getptr(p_name); return sdr != nullptr; } bool Control::has_theme_stylebox_override(const StringName &p_name) const { - const Ref *style = data.style_override.getptr(p_name); return style != nullptr; } bool Control::has_theme_font_override(const StringName &p_name) const { - const Ref *font = data.font_override.getptr(p_name); return font != nullptr; } bool Control::has_theme_color_override(const StringName &p_name) const { - const Color *color = data.color_override.getptr(p_name); return color != nullptr; } bool Control::has_theme_constant_override(const StringName &p_name) const { - const int *constant = data.constant_override.getptr(p_name); return constant != nullptr; } bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_icon_override(p_name)) return true; @@ -1074,7 +995,6 @@ bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) } bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_icon, p_name, p_type)) { return true; } @@ -1088,7 +1008,6 @@ bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, co } bool Control::has_theme_shader(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_shader_override(p_name)) return true; @@ -1099,7 +1018,6 @@ bool Control::has_theme_shader(const StringName &p_name, const StringName &p_typ return has_shaders(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_shader, p_name, p_type)) { return true; } @@ -1113,7 +1031,6 @@ bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, } bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_stylebox_override(p_name)) return true; @@ -1125,7 +1042,6 @@ bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_t } bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_stylebox, p_name, p_type)) { return true; } @@ -1139,7 +1055,6 @@ bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window } bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_font_override(p_name)) return true; @@ -1150,7 +1065,6 @@ bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) return has_fonts(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_font, p_name, p_type)) { return true; } @@ -1164,7 +1078,6 @@ bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, co } bool Control::has_theme_color(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_color_override(p_name)) return true; @@ -1175,7 +1088,6 @@ bool Control::has_theme_color(const StringName &p_name, const StringName &p_type return has_colors(data.theme_owner, data.theme_owner_window, p_name, type); } bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_color, p_name, p_type)) { return true; } @@ -1189,7 +1101,6 @@ bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, c } bool Control::has_theme_constant(const StringName &p_name, const StringName &p_type) const { - if (p_type == StringName() || p_type == get_class_name()) { if (has_theme_constant_override(p_name)) return true; @@ -1201,7 +1112,6 @@ bool Control::has_theme_constant(const StringName &p_name, const StringName &p_t } bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) { - if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_constant, p_name, p_type)) { return true; } @@ -1229,18 +1139,15 @@ Rect2 Control::get_parent_anchorable_rect() const { } Size2 Control::get_parent_area_size() const { - return get_parent_anchorable_rect().size; } void Control::_size_changed() { - Rect2 parent_rect = get_parent_anchorable_rect(); float margin_pos[4]; for (int i = 0; i < 4; i++) { - float area = parent_rect.size[i & 1]; margin_pos[i] = data.margin[i] + (data.anchor[i] * area); } @@ -1293,7 +1200,6 @@ void Control::_size_changed() { } void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bool p_push_opposite_anchor) { - ERR_FAIL_INDEX((int)p_margin, 4); Rect2 parent_rect = get_parent_anchorable_rect(); @@ -1334,13 +1240,11 @@ void Control::_set_anchor(Margin p_margin, float p_anchor) { } void Control::set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor) { - set_anchor(p_margin, p_anchor, false, p_push_opposite_anchor); set_margin(p_margin, p_pos); } void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { - ERR_FAIL_INDEX((int)p_preset, 16); //Left @@ -1457,7 +1361,6 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { } void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { - ERR_FAIL_INDEX((int)p_preset, 16); ERR_FAIL_INDEX((int)p_resize_mode, 4); @@ -1594,14 +1497,12 @@ void Control::set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPreset } float Control::get_anchor(Margin p_margin) const { - ERR_FAIL_INDEX_V(int(p_margin), 4, 0.0); return data.anchor[p_margin]; } void Control::_change_notify_margins() { - // this avoids sending the whole object data again on a change _change_notify("margin_left"); _change_notify("margin_top"); @@ -1612,7 +1513,6 @@ void Control::_change_notify_margins() { } void Control::set_margin(Margin p_margin, float p_value) { - ERR_FAIL_INDEX((int)p_margin, 4); data.margin[p_margin] = p_value; @@ -1620,37 +1520,31 @@ void Control::set_margin(Margin p_margin, float p_value) { } void Control::set_begin(const Size2 &p_point) { - data.margin[0] = p_point.x; data.margin[1] = p_point.y; _size_changed(); } void Control::set_end(const Size2 &p_point) { - data.margin[2] = p_point.x; data.margin[3] = p_point.y; _size_changed(); } float Control::get_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); return data.margin[p_margin]; } Size2 Control::get_begin() const { - return Size2(data.margin[0], data.margin[1]); } Size2 Control::get_end() const { - return Size2(data.margin[2], data.margin[3]); } Point2 Control::get_global_position() const { - return get_global_transform().get_origin(); } @@ -1670,11 +1564,9 @@ void Control::_set_global_position(const Point2 &p_point) { } void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) { - Transform2D inv; if (data.parent_canvas_item) { - inv = data.parent_canvas_item->get_global_transform().affine_inverse(); } @@ -1682,7 +1574,6 @@ void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) { } void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]) { - Size2 parent_rect_size = get_parent_anchorable_rect().size; ERR_FAIL_COND(parent_rect_size.x == 0.0); ERR_FAIL_COND(parent_rect_size.y == 0.0); @@ -1694,7 +1585,6 @@ void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r } void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) { - Size2 parent_rect_size = get_parent_anchorable_rect().size; r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x); r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); @@ -1724,7 +1614,6 @@ void Control::_set_size(const Size2 &p_size) { } void Control::set_size(const Size2 &p_size, bool p_keep_margins) { - Size2 new_size = p_size; Size2 min = get_combined_minimum_size(); if (new_size.x < min.x) @@ -1745,22 +1634,18 @@ void Control::set_size(const Size2 &p_size, bool p_keep_margins) { } Size2 Control::get_position() const { - return data.pos_cache; } Size2 Control::get_size() const { - return data.size_cache; } Rect2 Control::get_global_rect() const { - return Rect2(get_global_position(), get_size()); } Rect2 Control::get_screen_rect() const { - ERR_FAIL_COND_V(!is_inside_tree(), Rect2()); Rect2 r(get_global_position(), get_size()); @@ -1781,17 +1666,14 @@ Rect2 Control::get_window_rect() const { } Rect2 Control::get_rect() const { - return Rect2(get_position(), get_size()); } Rect2 Control::get_anchorable_rect() const { - return Rect2(Point2(), get_size()); } void Control::add_theme_icon_override(const StringName &p_name, const Ref &p_icon) { - if (data.icon_override.has(p_name)) { data.icon_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1809,7 +1691,6 @@ void Control::add_theme_icon_override(const StringName &p_name, const Ref &p_shader) { - if (data.shader_override.has(p_name)) { data.shader_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1826,7 +1707,6 @@ void Control::add_theme_shader_override(const StringName &p_name, const Ref &p_style) { - if (data.style_override.has(p_name)) { data.style_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } @@ -1844,7 +1724,6 @@ void Control::add_theme_style_override(const StringName &p_name, const Ref