diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2021-07-30 15:18:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-30 15:18:48 +0200 |
| commit | e95e33f25137486d2df0a1c13e17394454c7fdf1 (patch) | |
| tree | a0de75564f7efc84a75e5d4a05bc279ed6cbe4e5 /editor/plugins/node_3d_editor_plugin.cpp | |
| parent | ba274a6fc6111449c4484f48b272b7775a73eff8 (diff) | |
| parent | 81d2d2b41ad286c29f513ff5221938b3760f48ba (diff) | |
| download | redot-engine-e95e33f25137486d2df0a1c13e17394454c7fdf1.tar.gz | |
Merge pull request #35891 from Calinou/editor-viewport-highlight-context-menus
Highlight context menu items at the top of the 2D/3D viewports
Diffstat (limited to 'editor/plugins/node_3d_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 5eb549d58c..b1f4baac13 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -5972,6 +5972,18 @@ 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("accent_color", "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(); @@ -6539,6 +6551,7 @@ 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; @@ -6587,11 +6600,11 @@ Vector<int> Node3DEditor::get_subgizmo_selection() { } void Node3DEditor::add_control_to_menu_panel(Control *p_control) { - hbc_menu->add_child(p_control); + hbc_context_menu->add_child(p_control); } void Node3DEditor::remove_control_from_menu_panel(Control *p_control) { - hbc_menu->remove_child(p_control); + hbc_context_menu->remove_child(p_control); } void Node3DEditor::set_can_preview(Camera3D *p_preview) { @@ -7174,6 +7187,17 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { view_menu->set_shortcut_context(this); hbc_menu->add_child(view_menu); + hbc_menu->add_child(memnew(VSeparator)); + + 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(); + p = view_menu->get_popup(); accept = memnew(AcceptDialog); |
