From 42d1a969046f9a92a63ef2335ef5486e79d69ac4 Mon Sep 17 00:00:00 2001 From: FireForge <67974470+fire-forge@users.noreply.github.com> Date: Thu, 31 Mar 2022 23:43:46 -0500 Subject: Add rounded corners to the contextual toolbar - Move contextual toolbar stylebox to the editor theme because it's the same in the 2D and 3D editors --- editor/editor_themes.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'editor/editor_themes.cpp') diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 0e6bdec08f..43d7067a0a 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -692,6 +692,21 @@ Ref create_editor_theme(const Ref p_theme) { style_canvas_editor_info->set_expand_margin_size_all(4 * EDSCALE); theme->set_stylebox("CanvasItemInfoOverlay", "EditorStyles", style_canvas_editor_info); + // 2D and 3D contextual toolbar. + // Use a custom stylebox to make contextual menu items stand out from the rest. + // This helps with editor usability as contextual menu items change when selecting nodes, + // even though it may not be immediately obvious at first. + Ref toolbar_stylebox = memnew(StyleBoxFlat); + toolbar_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1)); + toolbar_stylebox->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); + toolbar_stylebox->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); + toolbar_stylebox->set_anti_aliased(false); + // Add an underline to the StyleBox, but prevent its minimum vertical size from changing. + toolbar_stylebox->set_border_color(accent_color); + toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE)); + toolbar_stylebox->set_default_margin(SIDE_BOTTOM, 0); + theme->set_stylebox("ContextualToolbar", "EditorStyles", toolbar_stylebox); + // Script Editor theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); -- cgit v1.2.3