Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Clean and simplify 2D toolbar

Jayden Sipe31a0412de687
diff --git a/editor/gui/editor_toolbar_group.cpp b/editor/gui/editor_toolbar_group.cpp
new file mode 100644
index 00000000000..86051555c22
--- /dev/null
+++ b/editor/gui/editor_toolbar_group.cpp
@@ -0,0 +1,50 @@
+/**************************************************************************/
+/* editor_toolbar_group.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "editor/gui/editor_toolbar_group.h"
+
+#include "editor/themes/editor_scale.h"
+#include "scene/gui/box_container.h"
+
+EditorToolbarGroup::EditorToolbarGroup() {
+ set_theme_type_variation("PanelContainerButtonGroup");
+ set_custom_maximum_size(Size2(-1, 32 * EDSCALE));
+
+ hbox = memnew(HBoxContainer);
+ hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
+ add_child(hbox);
+}
+
+HBoxContainer *EditorToolbarGroup::create(Control *p_parent) {
+ EditorToolbarGroup *group = memnew(EditorToolbarGroup);
+ p_parent->add_child(group);
+
+ return group->get_hbox();
+}
diff --git a/editor/gui/editor_toolbar_group.h b/editor/gui/editor_toolbar_group.h
new file mode 100644
index 00000000000..ee1ae8cc570
--- /dev/null
+++ b/editor/gui/editor_toolbar_group.h
@@ -0,0 +1,48 @@
+/**************************************************************************/
+/* editor_toolbar_group.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#pragma once
+
+#include "scene/gui/panel_container.h"
+
+class HBoxContainer;
+
+class EditorToolbarGroup : public PanelContainer {
+ GDCLASS(EditorToolbarGroup, PanelContainer);
+
+ HBoxContainer *hbox = nullptr;
+
+public:
+ EditorToolbarGroup();
+
+ static HBoxContainer *create(Control *p_parent);
+
+ HBoxContainer *get_hbox() const { return hbox; }
+};
diff --git a/editor/run/game_view_plugin.cpp b/editor/run/game_view_plugin.cpp
index 79938b15067..6dc3a8c085e 100644
--- a/editor/run/game_view_plugin.cpp
+++ b/editor/run/game_view_plugin.cpp
@@ -42,6 +42,7 @@
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_bottom_panel.h"
+#include "editor/gui/editor_toolbar_group.h"
#include "editor/gui/window_wrapper.h"
#include "editor/run/editor_run_bar.h"
#include "editor/run/embedded_process.h"
@@ -1482,9 +1483,6 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, EmbeddedProcessBase *p_embe
MarginContainer *toolbar_margin = memnew(MarginContainer);
toolbar_margin->set_theme_type_variation("MainToolBarMargin");
- toolbar_margin->add_theme_constant_override("margin_top", 1 * EDSCALE);
- toolbar_margin->add_theme_constant_override("margin_bottom", 1 * EDSCALE);
- toolbar_margin->set_custom_maximum_size(Size2(-1, 36 * EDSCALE));
add_child(toolbar_margin);
// FIXME: Turn this back into a FlowContainer once GH-115523 is fixed.
@@ -1528,12 +1526,7 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, EmbeddedProcessBase *p_embe
process_hb->add_child(memnew(VSeparator));
- PanelContainer *input_panel = memnew(PanelContainer);
- input_panel->set_theme_type_variation("PanelContainerButtonGroup");
- main_menu_fc->add_child(input_panel);
-
- HBoxContainer *input_hb = memnew(HBoxContainer);
- input_panel->add_child(input_hb);
+ HBoxContainer *input_hb = EditorToolbarGroup::create(main_menu_fc);
node_type_button[RuntimeNodeSelect::NODE_TYPE_NONE] = memnew(Button);
input_hb->add_child(node_type_button[RuntimeNodeSelect::NODE_TYPE_NONE]);
@@ -1562,12 +1555,7 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, EmbeddedProcessBase *p_embe
main_menu_fc->add_child(memnew(VSeparator));
- PanelContainer *selection_panel = memnew(PanelContainer);
- selection_panel->set_theme_type_variation("PanelContainerButtonGroup");
- main_menu_fc->add_child(selection_panel);
-
- HBoxContainer *selection_hb = memnew(HBoxContainer);
- selection_panel->add_child(selection_hb);
+ HBoxContainer *selection_hb = EditorToolbarGroup::create(main_menu_fc);
select_mode_button[RuntimeNodeSelect::SELECT_MODE_SINGLE] = memnew(Button);
selection_hb->add_child(select_mode_button[RuntimeNodeSelect::SELECT_MODE_SINGLE]);
@@ -1613,12 +1601,7 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, EmbeddedProcessBase *p_embe
main_menu_fc->add_child(memnew(VSeparator));
- PanelContainer *camera_panel = memnew(PanelContainer);
- camera_panel->set_theme_type_variation("PanelContainerButtonGroup");
- main_menu_fc->add_child(camera_panel);
-
- HBoxContainer *camera_hb = memnew(HBoxContainer);
- camera_panel->add_child(camera_hb);
+ HBoxContainer *camera_hb = EditorToolbarGroup::create(main_menu_fc);
camera_override_button = memnew(Button);
camera_hb->add_child(camera_override_button);
@@ -1659,15 +1642,9 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, EmbeddedProcessBase *p_embe
embedding_hb->set_alignment(ALIGNMENT_END);
main_menu_fc->add_child(embedding_hb);
- PanelContainer *embed_panel = memnew(PanelContainer);
- embed_panel->set_theme_type_variation("PanelContainerButtonGroup");
-
game_size_label = memnew(Label());
- game_hb = memnew(HBoxContainer);
-
embedding_hb->add_child(game_size_label);
- embedding_hb->add_child(embed_panel);
- embed_panel->add_child(game_hb);
+ game_hb = EditorToolbarGroup::create(embedding_hb);
game_size_label->hide();
// Setting the minimum size prevents the game workspace from resizing indefinitely
// due to the label size oscillating by a few pixels when the game is in stretch mode
diff --git a/editor/scene/canvas_item_editor_plugin.cpp b/editor/scene/canvas_item_editor_plugin.cpp
index 2432fe0e0f4..8f49272565e 100644
--- a/editor/scene/canvas_item_editor_plugin.cpp
+++ b/editor/scene/canvas_item_editor_plugin.cpp
@@ -48,6 +48,7 @@
#include "editor/gui/create_dialog.h"
#include "editor/gui/editor_quick_open_dialog.h"
#include "editor/gui/editor_toaster.h"
+#include "editor/gui/editor_toolbar_group.h"
#include "editor/gui/editor_zoom_widget.h"
#include "editor/inspector/editor_context_menu_plugin.h"
#include "editor/plugins/editor_plugin_list.h"
@@ -4453,7 +4454,7 @@ void CanvasItemEditor::_update_editor_settings() {
local_space_button->set_button_icon(get_editor_theme_icon(SNAME("Object")));
smart_snap_button->set_button_icon(get_editor_theme_icon(SNAME("Snap")));
grid_snap_button->set_button_icon(get_editor_theme_icon(SNAME("SnapGrid")));
- snap_config_menu->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
+ snap_config_menu->set_button_icon(get_editor_theme_icon(SNAME("GuiDropdown")));
skeleton_menu->set_button_icon(get_editor_theme_icon(SNAME("Bone")));
pan_button->set_button_icon(get_editor_theme_icon(SNAME("ToolPan")));
ruler_button->set_button_icon(get_editor_theme_icon(SNAME("Ruler")));
@@ -5755,9 +5756,7 @@ CanvasItemEditor::CanvasItemEditor() {
// Main toolbars.
// Split into separate `HBoxContainer` so they can wrap onto multiple lines as the window width decreases (the parent is a `FlowContainer`).
// These are not grouped by any particular criteria. Only some of the end children are grouped separately, based on their separators.
- HBoxContainer *tool_button_hbox = memnew(HBoxContainer);
- tool_button_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
- main_flow->add_child(tool_button_hbox);
+ HBoxContainer *input_hbox = EditorToolbarGroup::create(main_flow);
bottom_split = memnew(VSplitContainer);
add_child(bottom_split);
@@ -5872,7 +5871,7 @@ CanvasItemEditor::CanvasItemEditor() {
select_button = memnew(Button);
select_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
select_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(select_button);
+ input_hbox->add_child(select_button);
select_button->set_toggle_mode(true);
select_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_SELECT));
select_button->set_pressed(true);
@@ -5882,18 +5881,20 @@ CanvasItemEditor::CanvasItemEditor() {
scene_paint_button = memnew(Button);
scene_paint_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(scene_paint_button);
+ input_hbox->add_child(scene_paint_button);
scene_paint_button->set_toggle_mode(true);
scene_paint_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_SCENE_PAINT));
scene_paint_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scene_paint_mode", TTRC("Scene Paint Mode"), Key::B, true));
scene_paint_button->set_shortcut_context(this);
scene_paint_button->set_accessibility_name(TTRC("Scene Paint Mode"));
- tool_button_hbox->add_child(memnew(VSeparator));
+ VSeparator *vsep = memnew(VSeparator);
+ vsep->set_theme_type_variation("VSeparatorButtonGroup");
+ input_hbox->add_child(vsep);
move_button = memnew(Button);
move_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(move_button);
+ input_hbox->add_child(move_button);
move_button->set_toggle_mode(true);
move_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_MOVE));
move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTRC("Move Mode"), Key::W, true));
@@ -5902,7 +5903,7 @@ CanvasItemEditor::CanvasItemEditor() {
rotate_button = memnew(Button);
rotate_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(rotate_button);
+ input_hbox->add_child(rotate_button);
rotate_button->set_toggle_mode(true);
rotate_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_ROTATE));
rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTRC("Rotate Mode"), Key::E, true));
@@ -5911,18 +5912,20 @@ CanvasItemEditor::CanvasItemEditor() {
scale_button = memnew(Button);
scale_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(scale_button);
+ input_hbox->add_child(scale_button);
scale_button->set_toggle_mode(true);
scale_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_SCALE));
scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTRC("Scale Mode"), Key::R, true));
scale_button->set_shortcut_context(this);
scale_button->set_accessibility_name(TTRC("Scale Mode"));
- tool_button_hbox->add_child(memnew(VSeparator));
+ vsep = memnew(VSeparator);
+ vsep->set_theme_type_variation("VSeparatorButtonGroup");
+ input_hbox->add_child(vsep);
list_select_button = memnew(Button);
list_select_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(list_select_button);
+ input_hbox->add_child(list_select_button);
list_select_button->set_toggle_mode(true);
list_select_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_LIST_SELECT));
list_select_button->set_accessibility_name(TTRC("List Selectable Nodes"));
@@ -5930,14 +5933,14 @@ CanvasItemEditor::CanvasItemEditor() {
pivot_button = memnew(Button);
pivot_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
pivot_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(pivot_button);
+ input_hbox->add_child(pivot_button);
pivot_button->set_toggle_mode(true);
pivot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_EDIT_PIVOT));
pivot_button->set_accessibility_name(TTRC("Change Pivot"));
pan_button = memnew(Button);
pan_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(pan_button);
+ input_hbox->add_child(pan_button);
pan_button->set_toggle_mode(true);
pan_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_PAN));
pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTRC("Pan Mode"), Key::G));
@@ -5946,14 +5949,61 @@ CanvasItemEditor::CanvasItemEditor() {
ruler_button = memnew(Button);
ruler_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(ruler_button);
+ input_hbox->add_child(ruler_button);
ruler_button->set_toggle_mode(true);
ruler_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_RULER));
ruler_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/ruler_mode", TTRC("Ruler Mode"), Key::M));
ruler_button->set_shortcut_context(this);
ruler_button->set_accessibility_name(TTRC("Ruler Mode"));
- tool_button_hbox->add_child(memnew(VSeparator));
+ main_flow->add_child(memnew(VSeparator));
+
+ HBoxContainer *selection_control_hbox = memnew(HBoxContainer);
+ selection_control_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
+ main_flow->add_child(selection_control_hbox);
+
+ lock_button = memnew(Button);
+ lock_button->set_theme_type_variation(SceneStringName(FlatButton));
+ lock_button->set_accessibility_name(TTRC("Lock"));
+ selection_control_hbox->add_child(lock_button);
+
+ lock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(LOCK_SELECTED));
+ lock_button->set_tooltip_text(TTRC("Lock selected node, preventing selection and movement."));
+ // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
+ lock_button->set_shortcut(ED_GET_SHORTCUT("editor/lock_selected_nodes"));
+
+ unlock_button = memnew(Button);
+ unlock_button->set_accessibility_name(TTRC("Unlock"));
+ unlock_button->set_theme_type_variation(SceneStringName(FlatButton));
+ selection_control_hbox->add_child(unlock_button);
+ unlock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNLOCK_SELECTED));
+ unlock_button->set_tooltip_text(TTRC("Unlock selected node, allowing selection and movement."));
+ // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
+ unlock_button->set_shortcut(ED_GET_SHORTCUT("editor/unlock_selected_nodes"));
+
+ group_button = memnew(Button);
+ group_button->set_accessibility_name(TTRC("Group"));
+ group_button->set_theme_type_variation(SceneStringName(FlatButton));
+ selection_control_hbox->add_child(group_button);
+ group_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(GROUP_SELECTED));
+ group_button->set_tooltip_text(TTRC("Groups the selected node with its children. This causes the parent to be selected when any child node is clicked in 2D and 3D view."));
+ // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
+ group_button->set_shortcut(ED_GET_SHORTCUT("editor/group_selected_nodes"));
+
+ ungroup_button = memnew(Button);
+ ungroup_button->set_accessibility_name(TTRC("Ungroup"));
+ ungroup_button->set_theme_type_variation(SceneStringName(FlatButton));
+ selection_control_hbox->add_child(ungroup_button);
+ ungroup_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNGROUP_SELECTED));
+ ungroup_button->set_tooltip_text(TTRC("Ungroups the selected node from its children. Child nodes will be individual items in 2D and 3D view."));
+ // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
+ ungroup_button->set_shortcut(ED_GET_SHORTCUT("editor/ungroup_selected_nodes"));
+
+ main_flow->add_child(memnew(VSeparator));
+
+ HBoxContainer *tool_button_hbox = memnew(HBoxContainer);
+ tool_button_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
+ main_flow->add_child(tool_button_hbox);
local_space_button = memnew(Button);
local_space_button->set_theme_type_variation(SceneStringName(FlatButton));
@@ -5965,9 +6015,13 @@ CanvasItemEditor::CanvasItemEditor() {
local_space_button->set_shortcut_context(this);
local_space_button->set_accessibility_name(TTRC("Use Local Space"));
+ main_flow->add_child(memnew(VSeparator));
+
+ HBoxContainer *snap_hbox = EditorToolbarGroup::create(main_flow);
+
smart_snap_button = memnew(Button);
smart_snap_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(smart_snap_button);
+ snap_hbox->add_child(smart_snap_button);
smart_snap_button->set_toggle_mode(true);
smart_snap_button->connect(SceneStringName(toggled), callable_mp(this, &CanvasItemEditor::_button_toggle_smart_snap));
smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTRC("Use Smart Snap"), KeyModifierMask::SHIFT | Key::S));
@@ -5975,7 +6029,7 @@ CanvasItemEditor::CanvasItemEditor() {
grid_snap_button = memnew(Button);
grid_snap_button->set_theme_type_variation(SceneStringName(FlatButton));
- tool_button_hbox->add_child(grid_snap_button);
+ snap_hbox->add_child(grid_snap_button);
grid_snap_button->set_toggle_mode(true);
grid_snap_button->connect(SceneStringName(toggled), callable_mp(this, &CanvasItemEditor::_button_toggle_grid_snap));
grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTRC("Use Grid Snap"), KeyModifierMask::SHIFT | Key::G));
@@ -5985,7 +6039,7 @@ CanvasItemEditor::CanvasItemEditor() {
snap_config_menu->set_flat(false);
snap_config_menu->set_theme_type_variation("FlatMenuButton");
snap_config_menu->set_shortcut_context(this);
- tool_button_hbox->add_child(snap_config_menu);
+ snap_hbox->add_child(snap_config_menu);
snap_config_menu->set_h_size_flags(SIZE_SHRINK_END);
snap_config_menu->set_tooltip_text(TTRC("Snapping Options"));
snap_config_menu->set_switch_on_hover(true);
@@ -6012,50 +6066,7 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/configure_snap", TTRC("Configure Snap...")), SNAP_CONFIGURE);
- tool_button_hbox->add_child(memnew(VSeparator));
-
- HBoxContainer *selection_control_hbox = memnew(HBoxContainer);
- selection_control_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
- main_flow->add_child(selection_control_hbox);
-
- lock_button = memnew(Button);
- lock_button->set_theme_type_variation(SceneStringName(FlatButton));
- lock_button->set_accessibility_name(TTRC("Lock"));
- selection_control_hbox->add_child(lock_button);
-
- lock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(LOCK_SELECTED));
- lock_button->set_tooltip_text(TTRC("Lock selected node, preventing selection and movement."));
- // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
- lock_button->set_shortcut(ED_GET_SHORTCUT("editor/lock_selected_nodes"));
-
- unlock_button = memnew(Button);
- unlock_button->set_accessibility_name(TTRC("Unlock"));
- unlock_button->set_theme_type_variation(SceneStringName(FlatButton));
- selection_control_hbox->add_child(unlock_button);
- unlock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNLOCK_SELECTED));
- unlock_button->set_tooltip_text(TTRC("Unlock selected node, allowing selection and movement."));
- // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
- unlock_button->set_shortcut(ED_GET_SHORTCUT("editor/unlock_selected_nodes"));
-
- group_button = memnew(Button);
- group_button->set_accessibility_name(TTRC("Group"));
- group_button->set_theme_type_variation(SceneStringName(FlatButton));
- selection_control_hbox->add_child(group_button);
- group_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(GROUP_SELECTED));
- group_button->set_tooltip_text(TTRC("Groups the selected node with its children. This causes the parent to be selected when any child node is clicked in 2D and 3D view."));
- // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
- group_button->set_shortcut(ED_GET_SHORTCUT("editor/group_selected_nodes"));
-
- ungroup_button = memnew(Button);
- ungroup_button->set_accessibility_name(TTRC("Ungroup"));
- ungroup_button->set_theme_type_variation(SceneStringName(FlatButton));
- selection_control_hbox->add_child(ungroup_button);
- ungroup_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNGROUP_SELECTED));
- ungroup_button->set_tooltip_text(TTRC("Ungroups the selected node from its children. Child nodes will be individual items in 2D and 3D view."));
- // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
- ungroup_button->set_shortcut(ED_GET_SHORTCUT("editor/ungroup_selected_nodes"));
-
- selection_control_hbox->add_child(memnew(VSeparator));
+ main_flow->add_child(memnew(VSeparator));
HBoxContainer *skeleton_menu_hbox = memnew(HBoxContainer);
skeleton_menu_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
@@ -6076,7 +6087,7 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTRC("Make Bone2D Node(s) from Node(s)"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::B), SKELETON_MAKE_BONES);
p->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_popup_callback));
- skeleton_menu_hbox->add_child(memnew(VSeparator));
+ main_flow->add_child(memnew(VSeparator));
HBoxContainer *view_menu_hbox = memnew(HBoxContainer);
view_menu_hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
@@ -6149,7 +6160,7 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_submenu_node_item(TTRC("Preview Translation"), memnew(EditorTranslationPreviewMenu));
- view_menu_hbox->add_child(memnew(VSeparator));
+ main_flow->add_child(memnew(VSeparator));
// Contextual toolbars.
context_toolbar_panel = memnew(PanelContainer);
diff --git a/editor/themes/theme_classic.cpp b/editor/themes/theme_classic.cpp
index 7a1af9ce1c2..5a005080b30 100644
--- a/editor/themes/theme_classic.cpp
+++ b/editor/themes/theme_classic.cpp
@@ -2096,6 +2096,16 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &p_theme, Edito
p_theme->set_stylebox(SceneStringName(panel), "PanelContainerButtonGroup", style_button_group);
}
+ // VSeparatorButtonGroup.
+ {
+ p_theme->set_type_variation("VSeparatorButtonGroup", "VSeparator");
+
+ Ref<StyleBoxLine> style_v_separator = p_theme->get_stylebox(SNAME("separator"), SNAME("VSeparator"))->duplicate();
+ style_v_separator->set_color(p_config.base_color);
+
+ p_theme->set_stylebox("separator", "VSeparatorButtonGroup", style_v_separator);
+ }
+
// TreeLineEdit.
{
Ref<StyleBoxFlat> tree_line_edit_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("LineEdit"))->duplicate();
diff --git a/editor/themes/theme_modern.cpp b/editor/themes/theme_modern.cpp
index 03e710fa795..65510a194d6 100644
--- a/editor/themes/theme_modern.cpp
+++ b/editor/themes/theme_modern.cpp
@@ -1710,8 +1710,8 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
p_theme->set_type_variation("MainToolBarMargin", "MarginContainer");
p_theme->set_constant("margin_left", "MainToolBarMargin", EDSCALE_RND(4));
p_theme->set_constant("margin_right", "MainToolBarMargin", EDSCALE_RND(4));
- p_theme->set_constant("margin_top", "MainToolBarMargin", EDSCALE_RND(p_config.base_margin * 0.5));
- p_theme->set_constant("margin_bottom", "MainToolBarMargin", EDSCALE_RND(p_config.base_margin * 0.5));
+ p_theme->set_constant("margin_top", "MainToolBarMargin", EDSCALE);
+ p_theme->set_constant("margin_bottom", "MainToolBarMargin", EDSCALE);
// 2D and 3D contextual toolbar.
// Use a custom stylebox to make contextual menu items stand out from the rest.
@@ -2212,6 +2212,16 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
p_theme->set_stylebox(SceneStringName(panel), "PanelContainerButtonGroup", style_button_group);
}
+ // VSeparatorButtonGroup.
+ {
+ p_theme->set_type_variation("VSeparatorButtonGroup", "VSeparator");
+
+ Ref<StyleBoxLine> style_v_separator = p_theme->get_stylebox(SNAME("separator"), SNAME("VSeparator"))->duplicate();
+ style_v_separator->set_color(p_config.base_color);
+
+ p_theme->set_stylebox("separator", "VSeparatorButtonGroup", style_v_separator);
+ }
+
// TreeLineEdit.
{
Ref<StyleBoxFlat> tree_line_edit_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("LineEdit"))->duplicate();