summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-10 10:52:44 +0200
committerGitHub <noreply@github.com>2022-06-10 10:52:44 +0200
commitab2fd4a671124c69ac613437819daf7510b6f0eb (patch)
tree00f32f14b9234633c2b0c593e3e3c0ed1225aa47 /editor
parent1f76ee408088090b586d611ff6a337989a159269 (diff)
parent42d1a969046f9a92a63ef2335ef5486e79d69ac4 (diff)
Merge pull request #59776 from fire-forge/more-round
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_themes.cpp15
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp18
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp19
-rw-r--r--editor/plugins/node_3d_editor_plugin.h1
5 files changed, 18 insertions, 37 deletions
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 3c3fe77e28..2131365d59 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -692,6 +692,21 @@ Ref<Theme> create_editor_theme(const Ref<Theme> 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<StyleBoxFlat> 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));
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 40894cdb8b..bfe9e202d6 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3779,7 +3779,7 @@ void CanvasItemEditor::_update_editor_settings() {
key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55));
animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- _update_context_menu_stylebox();
+ context_menu_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles")));
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
pan_speed = int(EditorSettings::get_singleton()->get("editors/panning/2d_editor_pan_speed"));
@@ -3915,18 +3915,6 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
}
}
-void CanvasItemEditor::_update_context_menu_stylebox() {
- // This must be called when the theme changes to follow the new accent color.
- Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat);
- const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
- // Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
- context_menu_stylebox->set_border_color(accent_color);
- context_menu_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
- context_menu_stylebox->set_default_margin(SIDE_BOTTOM, 0);
- context_menu_container->add_theme_style_override("panel", context_menu_stylebox);
-}
-
void CanvasItemEditor::_update_scrollbars() {
updating_scroll = true;
@@ -5213,11 +5201,7 @@ CanvasItemEditor::CanvasItemEditor() {
context_menu_container = memnew(PanelContainer);
hbc_context_menu = memnew(HBoxContainer);
context_menu_container->add_child(hbc_context_menu);
- // 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.
hb->add_child(context_menu_container);
- _update_context_menu_stylebox();
// Animation controls.
animation_hb = memnew(HBoxContainer);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index a4099079f3..c20a054800 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -492,8 +492,6 @@ private:
HSplitContainer *right_panel_split = nullptr;
VSplitContainer *bottom_split = nullptr;
- void _update_context_menu_stylebox();
-
void _set_owner_for_node_and_children(Node *p_node, Node *p_owner);
friend class CanvasItemEditorPlugin;
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index ef31e132b3..9f4842a5a1 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -6362,18 +6362,6 @@ void fragment() {
_generate_selection_boxes();
}
-void Node3DEditor::_update_context_menu_stylebox() {
- // This must be called when the theme changes to follow the new accent color.
- Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat);
- const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
- // Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
- context_menu_stylebox->set_border_color(accent_color);
- context_menu_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
- context_menu_stylebox->set_default_margin(SIDE_BOTTOM, 0);
- context_menu_container->add_theme_style_override("panel", context_menu_stylebox);
-}
-
void Node3DEditor::_update_gizmos_menu() {
gizmos_menu->clear();
@@ -6965,6 +6953,8 @@ void Node3DEditor::_update_theme() {
sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor"))));
environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor"))));
environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor"))));
+
+ context_menu_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles")));
}
void Node3DEditor::_notification(int p_what) {
@@ -7003,7 +6993,6 @@ void Node3DEditor::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
_update_gizmos_menu_theme();
- _update_context_menu_stylebox();
sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window")));
environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window")));
} break;
@@ -7724,11 +7713,7 @@ Node3DEditor::Node3DEditor() {
context_menu_container = memnew(PanelContainer);
hbc_context_menu = memnew(HBoxContainer);
context_menu_container->add_child(hbc_context_menu);
- // 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.
hbc_menu->add_child(context_menu_container);
- _update_context_menu_stylebox();
// Get the view menu popup and have it stay open when a checkable item is selected
p = view_menu->get_popup();
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 894ec9a119..8a602be08b 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -676,7 +676,6 @@ private:
int camera_override_viewport_id;
void _init_indicators();
- void _update_context_menu_stylebox();
void _update_gizmos_menu();
void _update_gizmos_menu_theme();
void _init_grid();