From eb573da2b582c3ad0cb0585cd30b1005cd1cf1eb Mon Sep 17 00:00:00 2001 From: FireForge <67974470+fire-forge@users.noreply.github.com> Date: Thu, 26 May 2022 21:12:09 -0500 Subject: [PATCH] Use "odd" style for TabContainers on base BG color - Use the "odd" style for TabContainers that are on a background with the same color as the default TabContainer background color to add contrast --- editor/action_map_editor.cpp | 1 + editor/editor_about.cpp | 1 + editor/editor_settings_dialog.cpp | 1 + editor/editor_themes.cpp | 8 +++++--- editor/import/dynamic_font_import_settings.cpp | 1 + editor/import/scene_import_settings.cpp | 1 + editor/plugins/theme_editor_plugin.cpp | 10 +++------- editor/project_export.cpp | 1 + editor/project_settings_editor.cpp | 1 + modules/openxr/editor/openxr_action_map_editor.cpp | 1 + 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 6333b402da7..698390a61eb 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -644,6 +644,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { tab_container = memnew(TabContainer); tab_container->set_use_hidden_tabs_for_min_size(true); tab_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + tab_container->set_theme_type_variation("TabContainerOdd"); tab_container->connect("tab_selected", callable_mp(this, &InputEventConfigurationDialog::_tab_selected)); main_vbox->add_child(tab_container); diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 88ad2633c0f..6fafb2d91a8 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -163,6 +163,7 @@ EditorAbout::EditorAbout() { tc->set_tab_alignment(TabBar::ALIGNMENT_CENTER); tc->set_custom_minimum_size(Size2(400, 200) * EDSCALE); tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); + tc->set_theme_type_variation("TabContainerOdd"); vbc->add_child(tc); // Authors diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 712a5b150f8..02bff2761d6 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -683,6 +683,7 @@ EditorSettingsDialog::EditorSettingsDialog() { undo_redo = memnew(UndoRedo); tabs = memnew(TabContainer); + tabs->set_theme_type_variation("TabContainerOdd"); tabs->connect("tab_changed", callable_mp(this, &EditorSettingsDialog::_tabs_tab_changed)); add_child(tabs); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 550a73ed72b..9efe7f81a0c 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1152,14 +1152,16 @@ Ref create_editor_theme(const Ref p_theme) { style_content_panel->set_border_color(dark_color_2); theme->set_stylebox("panel", "TabContainer", style_content_panel); - // These styleboxes can be used on tabs against the base color background (e.g. nested tabs). + // TabContainerOdd can be used on tabs against the base color background (e.g. nested tabs). + theme->set_type_variation("TabContainerOdd", "TabContainer"); + Ref style_tab_selected_odd = style_tab_selected->duplicate(); style_tab_selected_odd->set_bg_color(disabled_bg_color); - theme->set_stylebox("tab_selected_odd", "TabContainer", style_tab_selected_odd); + theme->set_stylebox("tab_selected", "TabContainerOdd", style_tab_selected_odd); Ref style_content_panel_odd = style_content_panel->duplicate(); style_content_panel_odd->set_bg_color(disabled_bg_color); - theme->set_stylebox("panel_odd", "TabContainer", style_content_panel_odd); + theme->set_stylebox("panel", "TabContainerOdd", style_content_panel_odd); // This stylebox is used in 3d and 2d viewports (no borders). Ref style_content_panel_vp = style_content_panel->duplicate(); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index e546f01205c..97892e47d4d 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -1418,6 +1418,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() { main_pages->set_tab_alignment(TabBar::ALIGNMENT_CENTER); main_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL); main_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL); + main_pages->set_theme_type_variation("TabContainerOdd"); root_vb->add_child(main_pages); label_warn = memnew(Label); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 83dff30dfa0..d9ff4f79de5 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -1229,6 +1229,7 @@ SceneImportSettings::SceneImportSettings() { data_mode = memnew(TabContainer); tree_split->add_child(data_mode); data_mode->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); + data_mode->set_theme_type_variation("TabContainerOdd"); property_split = memnew(HSplitContainer); tree_split->add_child(property_split); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 751751aaaa8..c814f9bb973 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -1871,9 +1871,6 @@ void ThemeItemEditorDialog::_notification(int p_what) { edit_items_remove_all->set_icon(get_theme_icon(SNAME("ThemeRemoveAllItems"), SNAME("EditorIcons"))); import_another_theme_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - - tc->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); - tc->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); } break; } } @@ -1896,6 +1893,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito tc = memnew(TabContainer); add_child(tc); + tc->set_theme_type_variation("TabContainerOdd"); // Edit Items tab. HSplitContainer *edit_dialog_hs = memnew(HSplitContainer); @@ -3305,9 +3303,6 @@ void ThemeTypeEditor::_notification(int p_what) { data_type_tabs->set_tab_icon(5, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); data_type_tabs->set_tab_icon(6, get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - data_type_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); - data_type_tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); - type_variation_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; } @@ -3407,6 +3402,7 @@ ThemeTypeEditor::ThemeTypeEditor() { main_vb->add_child(data_type_tabs); data_type_tabs->set_v_size_flags(SIZE_EXPAND_FILL); data_type_tabs->set_use_hidden_tabs_for_min_size(true); + data_type_tabs->set_theme_type_variation("TabContainerOdd"); color_items_list = _create_item_list(Theme::DATA_TYPE_COLOR); constant_items_list = _create_item_list(Theme::DATA_TYPE_CONSTANT); @@ -3589,7 +3585,7 @@ void ThemeEditor::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"))); preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"))); - preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); + preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainerOdd"))); add_preview_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 503eb5000ba..70627d5e827 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1064,6 +1064,7 @@ ProjectExportDialog::ProjectExportDialog() { sections = memnew(TabContainer); sections->set_use_hidden_tabs_for_min_size(true); + sections->set_theme_type_variation("TabContainerOdd"); settings_vb->add_child(sections); sections->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 14a0427e18b..5238c8f50c2 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -560,6 +560,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container = memnew(TabContainer); tab_container->set_use_hidden_tabs_for_min_size(true); + tab_container->set_theme_type_variation("TabContainerOdd"); add_child(tab_container); VBoxContainer *general_editor = memnew(VBoxContainer); diff --git a/modules/openxr/editor/openxr_action_map_editor.cpp b/modules/openxr/editor/openxr_action_map_editor.cpp index 6e9a2e1b615..87b7f502248 100644 --- a/modules/openxr/editor/openxr_action_map_editor.cpp +++ b/modules/openxr/editor/openxr_action_map_editor.cpp @@ -344,6 +344,7 @@ OpenXRActionMapEditor::OpenXRActionMapEditor() { tabs = memnew(TabContainer); tabs->set_h_size_flags(SIZE_EXPAND_FILL); tabs->set_v_size_flags(SIZE_EXPAND_FILL); + tabs->set_theme_type_variation("TabContainerOdd"); tabs->connect("tab_changed", callable_mp(this, &OpenXRActionMapEditor::_on_tabs_tab_changed)); tabs->connect("tab_button_pressed", callable_mp(this, &OpenXRActionMapEditor::_on_tab_button_pressed)); add_child(tabs);