diff options
author | azagaya <azagaya.games@gmail.com> | 2019-01-26 15:41:36 -0300 |
---|---|---|
committer | azagaya <azagaya.games@gmail.com> | 2019-08-30 08:33:32 -0300 |
commit | fa6f86b886bf199ea0788743a49503e449afb5f7 (patch) | |
tree | 990f6d77f924335274dc80086f8368e17718d42d | |
parent | b203f80dfce16135d6baced2c118eff5e44a7dcf (diff) |
Make tab containers in editor, project settings, and export dialog, to use hidden tabs for min size computation.
-rw-r--r-- | editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | editor/project_export.cpp | 1 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 7 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 14 | ||||
-rw-r--r-- | scene/gui/tab_container.h | 3 |
5 files changed, 25 insertions, 4 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0ff0bca7ee..677e3ad523 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -889,7 +889,8 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> ret_changed = true; } } break; - default: {} + default: { + } } } @@ -5102,6 +5103,7 @@ EditorNode::EditorNode() { dock_slot[i]->set_drag_to_rearrange_enabled(true); dock_slot[i]->set_tabs_rearrange_group(1); dock_slot[i]->connect("tab_changed", this, "_dock_tab_changed"); + dock_slot[i]->set_use_hidden_tabs_for_min_size(true); } dock_drag_timer = memnew(Timer); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index ec64d76b18..54b7270f19 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1115,6 +1115,7 @@ ProjectExportDialog::ProjectExportDialog() { sections = memnew(TabContainer); sections->set_tab_align(TabContainer::ALIGN_LEFT); + sections->set_use_hidden_tabs_for_min_size(true); settings_vb->add_child(sections); sections->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index cc33550ac9..24e2a08657 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -294,7 +294,8 @@ void ProjectSettingsEditor::_device_input_add() { ie = jb; } break; - default: {} + default: { + } } if (idx < 0 || idx >= events.size()) { @@ -519,7 +520,8 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } } break; - default: {} + default: { + } } } @@ -1679,6 +1681,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container = memnew(TabContainer); tab_container->set_tab_align(TabContainer::ALIGN_LEFT); + tab_container->set_use_hidden_tabs_for_min_size(true); add_child(tab_container); VBoxContainer *props_base = memnew(VBoxContainer); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 212efa4976..e35967861c 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -791,7 +791,7 @@ Size2 TabContainer::get_minimum_size() const { Control *c = tabs[i]; - if (!c->is_visible_in_tree()) + if (!c->is_visible_in_tree() && !use_hidden_tabs_for_min_size) continue; Size2 cms = c->get_combined_minimum_size(); @@ -838,6 +838,13 @@ int TabContainer::get_tabs_rearrange_group() const { return tabs_rearrange_group; } +void TabContainer::set_use_hidden_tabs_for_min_size(bool p_use_hidden_tabs) { + use_hidden_tabs_for_min_size = p_use_hidden_tabs; +} + +bool TabContainer::get_use_hidden_tabs_for_min_size() const { + return use_hidden_tabs_for_min_size; +} void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input); @@ -864,6 +871,9 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tabs_rearrange_group", "group_id"), &TabContainer::set_tabs_rearrange_group); ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &TabContainer::get_tabs_rearrange_group); + ClassDB::bind_method(D_METHOD("set_use_hidden_tabs_for_min_size", "enabled"), &TabContainer::set_use_hidden_tabs_for_min_size); + ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size); + ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback); ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed); ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab); @@ -876,6 +886,7 @@ void TabContainer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_visible"), "set_tabs_visible", "are_tabs_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_to_rearrange_enabled"), "set_drag_to_rearrange_enabled", "get_drag_to_rearrange_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hidden_tabs_for_min_size"), "set_use_hidden_tabs_for_min_size", "get_use_hidden_tabs_for_min_size"); BIND_ENUM_CONSTANT(ALIGN_LEFT); BIND_ENUM_CONSTANT(ALIGN_CENTER); @@ -896,4 +907,5 @@ TabContainer::TabContainer() { popup = NULL; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; + use_hidden_tabs_for_min_size = false; } diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index c110f041d0..dbf2bb9231 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -59,6 +59,7 @@ private: int _get_top_margin() const; Popup *popup; bool drag_to_rearrange_enabled; + bool use_hidden_tabs_for_min_size; int tabs_rearrange_group; Vector<Control *> _get_tabs() const; @@ -115,6 +116,8 @@ public: bool get_drag_to_rearrange_enabled() const; void set_tabs_rearrange_group(int p_group_id); int get_tabs_rearrange_group() const; + void set_use_hidden_tabs_for_min_size(bool p_use_hidden_tabs); + bool get_use_hidden_tabs_for_min_size() const; TabContainer(); }; |