Skip to content

Commit

Permalink
Overhaul the theme editor and improve user experience
Browse files Browse the repository at this point in the history
Backport of #49388, #49772.
  • Loading branch information
YuriSizov committed Jun 20, 2021
1 parent eec079e commit 7120be9
Show file tree
Hide file tree
Showing 6 changed files with 1,960 additions and 211 deletions.
28 changes: 27 additions & 1 deletion editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,16 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE);
style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE);

// this is the stylebox used in 3d and 2d viewports (no borders)
// These styleboxes can be used on tabs against the base color background (e.g. nested tabs).
Ref<StyleBoxFlat> style_tab_selected_odd = style_tab_selected->duplicate();
style_tab_selected_odd->set_bg_color(color_disabled_bg);
theme->set_stylebox("tab_selected_odd", "TabContainer", style_tab_selected_odd);

Ref<StyleBoxFlat> style_content_panel_odd = style_content_panel->duplicate();
style_content_panel_odd->set_bg_color(color_disabled_bg);
theme->set_stylebox("panel_odd", "TabContainer", style_content_panel_odd);

// This stylebox is used in 3d and 2d viewports (no borders).
Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
Expand All @@ -913,6 +922,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("panel", "TabContainer", style_content_panel);
theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);

// This stylebox is used by preview tabs in the Theme Editor.
Ref<StyleBoxFlat> style_theme_preview_tab = style_tab_selected_odd->duplicate();
style_theme_preview_tab->set_expand_margin_size(MARGIN_BOTTOM, 3 * EDSCALE);
theme->set_stylebox("ThemeEditorPreviewFG", "EditorStyles", style_theme_preview_tab);
Ref<StyleBoxFlat> style_theme_preview_bg_tab = style_tab_unselected->duplicate();
style_theme_preview_bg_tab->set_expand_margin_size(MARGIN_BOTTOM, 2 * EDSCALE);
theme->set_stylebox("ThemeEditorPreviewBG", "EditorStyles", style_theme_preview_bg_tab);

// Separators
theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true));
Expand Down Expand Up @@ -1247,6 +1264,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_info_3d_viewport->set_border_width_all(0);
theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);

// Theme editor.
theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));
Color theme_preview_picker_bg_color = accent_color;
theme_preview_picker_bg_color.a = 0.2;
Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);
theme_preview_picker_sb->set_border_color(accent_color);
theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);
theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb);

// adaptive script theme constants
// for comments and elements with lower relevance
const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5);
Expand Down
Loading

0 comments on commit 7120be9

Please sign in to comment.