diff options
Diffstat (limited to 'scene/gui/tab_container.cpp')
-rw-r--r-- | scene/gui/tab_container.cpp | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 3a128cf8e6..501e50e7f7 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -36,7 +36,6 @@ #include "scene/gui/texture_rect.h" int TabContainer::_get_top_margin() const { - if (!tabs_visible) return 0; @@ -53,7 +52,6 @@ int TabContainer::_get_top_margin() const { Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { - Control *c = tabs[i]; if (!c->has_meta("_tab_icon")) continue; @@ -68,11 +66,9 @@ int TabContainer::_get_top_margin() const { } void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Point2 pos(mb->get_position().x, mb->get_position().y); Size2 size = get_size(); @@ -144,13 +140,11 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - Point2 pos(mm->get_position().x, mm->get_position().y); Size2 size = get_size(); // Mouse must be on tabs in the tab header area. if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin()) { - if (menu_hovered || highlight_arrow > -1) { menu_hovered = false; highlight_arrow = -1; @@ -161,7 +155,6 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { Ref<Texture2D> menu = get_theme_icon("menu"); if (popup) { - if (pos.x >= size.width - menu->get_width()) { if (!menu_hovered) { menu_hovered = true; @@ -194,13 +187,11 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { Ref<Texture2D> increment = get_theme_icon("increment"); Ref<Texture2D> decrement = get_theme_icon("decrement"); if (pos.x >= size.width - increment->get_width() - popup_ofs) { - if (highlight_arrow != 1) { highlight_arrow = 1; update(); } } else if (pos.x >= size.width - increment->get_width() - decrement->get_width() - popup_ofs) { - if (highlight_arrow != 0) { highlight_arrow = 0; update(); @@ -213,16 +204,12 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { } void TabContainer::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_TRANSLATION_CHANGED: { - minimum_size_changed(); update(); } break; case NOTIFICATION_RESIZED: { - Vector<Control *> tabs = _get_tabs(); int side_margin = get_theme_constant("side_margin"); Ref<Texture2D> menu = get_theme_icon("menu"); @@ -257,7 +244,6 @@ void TabContainer::_notification(int p_what) { } } break; case NOTIFICATION_DRAW: { - RID canvas = get_canvas_item(); Size2 size = get_size(); @@ -412,7 +398,6 @@ void TabContainer::_notification(int p_what) { // Draw the navigation buttons. if (buttons_visible_cache) { - x -= increment->get_width(); if (last_tab_cache < tabs.size() - 1) { draw_texture(highlight_arrow == 1 ? increment_hl : increment, Point2(x, (header_height - increment->get_height()) / 2)); @@ -429,7 +414,6 @@ void TabContainer::_notification(int p_what) { } } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); call_deferred("_on_theme_changed"); // Wait until all changed theme. } break; @@ -451,7 +435,6 @@ void TabContainer::_on_mouse_exited() { } int TabContainer::_get_tab_width(int p_index) const { - ERR_FAIL_INDEX_V(p_index, get_tab_count(), 0); Control *control = Object::cast_to<Control>(_get_tabs()[p_index]); if (!control || control->is_set_as_toplevel() || get_tab_hidden(p_index)) @@ -488,10 +471,8 @@ int TabContainer::_get_tab_width(int p_index) const { } Vector<Control *> TabContainer::_get_tabs() const { - Vector<Control *> controls; for (int i = 0; i < get_child_count(); i++) { - Control *control = Object::cast_to<Control>(get_child(i)); if (!control || control->is_toplevel_control()) continue; @@ -502,12 +483,10 @@ Vector<Control *> TabContainer::_get_tabs() const { } void TabContainer::_child_renamed_callback() { - update(); } void TabContainer::add_child_notify(Node *p_child) { - Container::add_child_notify(p_child); Control *c = Object::cast_to<Control>(p_child); @@ -543,12 +522,10 @@ void TabContainer::add_child_notify(Node *p_child) { } int TabContainer::get_tab_count() const { - return _get_tabs().size(); } void TabContainer::set_current_tab(int p_current) { - ERR_FAIL_INDEX(p_current, get_tab_count()); int pending_previous = current; @@ -557,7 +534,6 @@ void TabContainer::set_current_tab(int p_current) { Ref<StyleBox> sb = get_theme_stylebox("panel"); Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { - Control *c = tabs[i]; if (i == current) { c->show(); @@ -587,17 +563,14 @@ void TabContainer::set_current_tab(int p_current) { } int TabContainer::get_current_tab() const { - return current; } int TabContainer::get_previous_tab() const { - return previous; } Control *TabContainer::get_tab_control(int p_idx) const { - Vector<Control *> tabs = _get_tabs(); if (p_idx >= 0 && p_idx < tabs.size()) return tabs[p_idx]; @@ -606,7 +579,6 @@ Control *TabContainer::get_tab_control(int p_idx) const { } Control *TabContainer::get_current_tab_control() const { - Vector<Control *> tabs = _get_tabs(); if (current >= 0 && current < tabs.size()) return tabs[current]; @@ -615,7 +587,6 @@ Control *TabContainer::get_current_tab_control() const { } void TabContainer::remove_child_notify(Node *p_child) { - Container::remove_child_notify(p_child); call_deferred("_update_current_tab"); @@ -626,7 +597,6 @@ void TabContainer::remove_child_notify(Node *p_child) { } void TabContainer::_update_current_tab() { - int tc = get_tab_count(); if (current >= tc) current = tc - 1; @@ -637,7 +607,6 @@ void TabContainer::_update_current_tab() { } Variant TabContainer::get_drag_data(const Point2 &p_point) { - if (!drag_to_rearrange_enabled) return Variant(); @@ -666,7 +635,6 @@ Variant TabContainer::get_drag_data(const Point2 &p_point) { } bool TabContainer::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (!drag_to_rearrange_enabled) return false; @@ -675,7 +643,6 @@ bool TabContainer::can_drop_data(const Point2 &p_point, const Variant &p_data) c return false; if (String(d["type"]) == "tabc_element") { - NodePath from_path = d["from_path"]; NodePath to_path = get_path(); if (from_path == to_path) { @@ -693,7 +660,6 @@ bool TabContainer::can_drop_data(const Point2 &p_point, const Variant &p_data) c } void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) { - if (!drag_to_rearrange_enabled) return; @@ -704,7 +670,6 @@ void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) { return; if (String(d["type"]) == "tabc_element") { - int tab_from_id = d["tabc_element"]; NodePath from_path = d["from_path"]; NodePath to_path = get_path(); @@ -733,7 +698,6 @@ void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) { } int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const { - if (get_tab_count() == 0) return -1; @@ -772,7 +736,6 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const { } void TabContainer::set_tab_align(TabAlign p_align) { - ERR_FAIL_INDEX(p_align, 3); align = p_align; update(); @@ -781,12 +744,10 @@ void TabContainer::set_tab_align(TabAlign p_align) { } TabContainer::TabAlign TabContainer::get_tab_align() const { - return align; } void TabContainer::set_tabs_visible(bool p_visible) { - if (p_visible == tabs_visible) return; @@ -794,7 +755,6 @@ void TabContainer::set_tabs_visible(bool p_visible) { Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { - Control *c = tabs[i]; if (p_visible) c->set_margin(MARGIN_TOP, _get_top_margin()); @@ -807,17 +767,14 @@ void TabContainer::set_tabs_visible(bool p_visible) { } bool TabContainer::are_tabs_visible() const { - return tabs_visible; } Control *TabContainer::_get_tab(int p_idx) const { - return get_tab_control(p_idx); } void TabContainer::set_tab_title(int p_tab, const String &p_title) { - Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_name", p_title); @@ -825,7 +782,6 @@ void TabContainer::set_tab_title(int p_tab, const String &p_title) { } String TabContainer::get_tab_title(int p_tab) const { - Control *child = _get_tab(p_tab); ERR_FAIL_COND_V(!child, ""); if (child->has_meta("_tab_name")) @@ -835,14 +791,12 @@ String TabContainer::get_tab_title(int p_tab) const { } void TabContainer::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { - Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_icon", p_icon); update(); } Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const { - Control *child = _get_tab(p_tab); ERR_FAIL_COND_V(!child, Ref<Texture2D>()); if (child->has_meta("_tab_icon")) @@ -852,7 +806,6 @@ Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const { } void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) { - Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_disabled", p_disabled); @@ -860,7 +813,6 @@ void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) { } bool TabContainer::get_tab_disabled(int p_tab) const { - Control *child = _get_tab(p_tab); ERR_FAIL_COND_V(!child, false); if (child->has_meta("_tab_disabled")) @@ -870,7 +822,6 @@ bool TabContainer::get_tab_disabled(int p_tab) const { } void TabContainer::set_tab_hidden(int p_tab, bool p_hidden) { - Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_hidden", p_hidden); @@ -890,7 +841,6 @@ void TabContainer::set_tab_hidden(int p_tab, bool p_hidden) { } bool TabContainer::get_tab_hidden(int p_tab) const { - Control *child = _get_tab(p_tab); ERR_FAIL_COND_V(!child, false); if (child->has_meta("_tab_hidden")) @@ -900,10 +850,8 @@ bool TabContainer::get_tab_hidden(int p_tab) const { } void TabContainer::get_translatable_strings(List<String> *p_strings) const { - Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { - Control *c = tabs[i]; if (!c->has_meta("_tab_name")) @@ -917,12 +865,10 @@ void TabContainer::get_translatable_strings(List<String> *p_strings) const { } Size2 TabContainer::get_minimum_size() const { - Size2 ms; Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { - Control *c = tabs[i]; if (!c->is_visible_in_tree() && !use_hidden_tabs_for_min_size) @@ -983,7 +929,6 @@ bool TabContainer::get_use_hidden_tabs_for_min_size() const { } void TabContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input); ClassDB::bind_method(D_METHOD("get_tab_count"), &TabContainer::get_tab_count); ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabContainer::set_current_tab); @@ -1030,7 +975,6 @@ void TabContainer::_bind_methods() { } TabContainer::TabContainer() { - first_tab_cache = 0; last_tab_cache = 0; buttons_visible_cache = false; |