diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 9ead8888d..b99160489 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3840,8 +3840,6 @@ void CanvasItemEditor::_notification(int p_what) { zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); - _update_context_menu_stylebox(); - presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons")); PopupMenu *p = presets_menu->get_popup(); @@ -3958,18 +3956,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 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(MARGIN_BOTTOM, Math::round(2 * EDSCALE)); - context_menu_stylebox->set_default_margin(MARGIN_BOTTOM, 0); - context_menu_panel->add_theme_style_override("panel", context_menu_stylebox); -} - void CanvasItemEditor::_update_scrollbars() { updating_scroll = true; @@ -5252,11 +5238,11 @@ void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) { void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { ERR_FAIL_COND(!p_control); - context_menu_hbox->add_child(p_control); + main_flow->add_child(p_control); } void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) { - context_menu_hbox->remove_child(p_control); + main_flow->remove_child(p_control); } void CanvasItemEditor::add_control_to_left_panel(Control *p_control) { @@ -5381,7 +5367,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { editor->call_deferred("connect", "stop_pressed", this, "_update_override_camera_button", make_binds(false)); // A fluid container for all toolbars. - HFlowContainer *main_flow = memnew(HFlowContainer); + main_flow = memnew(HFlowContainer); add_child(main_flow); // Main toolbars. @@ -5666,18 +5652,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { main_menu_hbox->add_child(memnew(VSeparator)); - context_menu_panel = memnew(PanelContainer); - context_menu_hbox = memnew(HBoxContainer); - context_menu_panel->add_child(context_menu_hbox); - // 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. - main_flow->add_child(context_menu_panel); - _update_context_menu_stylebox(); - presets_menu = memnew(MenuButton); presets_menu->set_text(TTR("Layout")); - context_menu_hbox->add_child(presets_menu); + main_flow->add_child(presets_menu); presets_menu->hide(); presets_menu->set_switch_on_hover(true); @@ -5690,13 +5667,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { anchors_popup->connect("id_pressed", this, "_popup_callback"); anchor_mode_button = memnew(ToolButton); - context_menu_hbox->add_child(anchor_mode_button); + main_flow->add_child(anchor_mode_button); anchor_mode_button->set_toggle_mode(true); anchor_mode_button->hide(); anchor_mode_button->connect("toggled", this, "_button_toggle_anchor_mode"); animation_hb = memnew(HBoxContainer); - context_menu_hbox->add_child(animation_hb); + main_flow->add_child(animation_hb); animation_hb->add_child(memnew(VSeparator)); animation_hb->hide(); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 9914fa103..1e373248e 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -73,6 +73,7 @@ class VScrollBar; class VSplitContainer; class WindowDialog; struct Color; +class HFlowContainer; class CanvasItemEditorSelectedItem : public Object { GDCLASS(CanvasItemEditorSelectedItem, Object); @@ -261,10 +262,7 @@ private: HScrollBar *h_scroll; VScrollBar *v_scroll; - // Used for secondary menu items which are displayed depending on the currently selected node - // (such as MeshInstance's "Mesh" menu). - PanelContainer *context_menu_panel; - HBoxContainer *context_menu_hbox; + HFlowContainer *main_flow; ToolButton *zoom_minus; ToolButton *zoom_reset; @@ -577,7 +575,6 @@ private: HSplitContainer *right_panel_split; VSplitContainer *bottom_split; - void _update_context_menu_stylebox(); void _popup_warning_temporarily(Control *p_control, const float p_duration); void _popup_warning_depop(Control *p_control); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 0a8213e3c..351313349 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -6256,18 +6256,6 @@ void SpatialEditor::_init_indicators() { _generate_selection_boxes(); } -void SpatialEditor::_update_context_menu_stylebox() { - // This must be called when the theme changes to follow the new accent color. - Ref 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(MARGIN_BOTTOM, Math::round(2 * EDSCALE)); - context_menu_stylebox->set_default_margin(MARGIN_BOTTOM, 0); - context_menu_panel->add_theme_style_override("panel", context_menu_stylebox); -} - void SpatialEditor::_update_gizmos_menu() { gizmos_menu->clear(); @@ -6762,7 +6750,6 @@ void SpatialEditor::_notification(int p_what) { _init_indicators(); } else if (p_what == NOTIFICATION_THEME_CHANGED) { _update_gizmos_menu_theme(); - _update_context_menu_stylebox(); } else if (p_what == NOTIFICATION_EXIT_TREE) { _finish_indicators(); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { @@ -6830,11 +6817,11 @@ Vector SpatialEditor::get_subgizmo_selection() { } void SpatialEditor::add_control_to_menu_panel(Control *p_control) { - context_menu_hbox->add_child(p_control); + main_flow->add_child(p_control); } void SpatialEditor::remove_control_from_menu_panel(Control *p_control) { - context_menu_hbox->remove_child(p_control); + main_flow->remove_child(p_control); } void SpatialEditor::set_can_preview(Camera *p_preview) { @@ -7134,7 +7121,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { camera_override_viewport_id = 0; // A fluid container for all toolbars. - HFlowContainer *main_flow = memnew(HFlowContainer); + main_flow = memnew(HFlowContainer); vbc->add_child(main_flow); // Main toolbars. @@ -7307,15 +7294,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { main_menu_hbox->add_child(memnew(VSeparator)); - context_menu_panel = memnew(PanelContainer); - context_menu_hbox = memnew(HBoxContainer); - context_menu_panel->add_child(context_menu_hbox); - // 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. - main_flow->add_child(context_menu_panel); - _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(); p->set_hide_on_checkable_item_selection(false); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index d6b51b81c..2f248dee0 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -98,6 +98,7 @@ class VSplitContainer; class Viewport; class SpinBox; class ViewportNavigationControl; +class HFlowContainer; class ViewportRotationControl : public Control { GDCLASS(ViewportRotationControl, Control); @@ -696,10 +697,7 @@ private: void _update_camera_override_button(bool p_game_running); void _update_camera_override_viewport(Object *p_viewport); - // Used for secondary menu items which are displayed depending on the currently selected node - // (such as MeshInstance's "Mesh" menu). - PanelContainer *context_menu_panel; - HBoxContainer *context_menu_hbox; + HFlowContainer *main_flow; void _generate_selection_boxes(); UndoRedo *undo_redo; @@ -707,7 +705,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();