mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Use FlowContainer to handle toolbar overflow more gracefully
This commit is contained in:
parent
e830d9d7cc
commit
842c3a644f
4 changed files with 85 additions and 77 deletions
|
@ -49,6 +49,7 @@
|
|||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/3d/room_manager.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/gui/flow_container.h"
|
||||
#include "scene/gui/viewport_container.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
|
@ -5810,7 +5811,7 @@ void SpatialEditor::_update_context_menu_stylebox() {
|
|||
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_container->add_style_override("panel", context_menu_stylebox);
|
||||
context_menu_panel->add_style_override("panel", context_menu_stylebox);
|
||||
}
|
||||
|
||||
void SpatialEditor::_update_gizmos_menu() {
|
||||
|
@ -6330,11 +6331,11 @@ void SpatialEditor::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void SpatialEditor::add_control_to_menu_panel(Control *p_control) {
|
||||
hbc_context_menu->add_child(p_control);
|
||||
context_menu_hbox->add_child(p_control);
|
||||
}
|
||||
|
||||
void SpatialEditor::remove_control_from_menu_panel(Control *p_control) {
|
||||
hbc_context_menu->remove_child(p_control);
|
||||
context_menu_hbox->remove_child(p_control);
|
||||
}
|
||||
|
||||
void SpatialEditor::set_can_preview(Camera *p_preview) {
|
||||
|
@ -6576,15 +6577,20 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
|
||||
camera_override_viewport_id = 0;
|
||||
|
||||
hbc_menu = memnew(HBoxContainer);
|
||||
vbc->add_child(hbc_menu);
|
||||
// A fluid container for all toolbars.
|
||||
HFlowContainer *main_flow = memnew(HFlowContainer);
|
||||
vbc->add_child(main_flow);
|
||||
|
||||
// Main toolbars.
|
||||
HBoxContainer *main_menu_hbox = memnew(HBoxContainer);
|
||||
main_flow->add_child(main_menu_hbox);
|
||||
|
||||
Vector<Variant> button_binds;
|
||||
button_binds.resize(1);
|
||||
String sct;
|
||||
|
||||
tool_button[TOOL_MODE_SELECT] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_MODE_SELECT]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_MODE_SELECT]);
|
||||
tool_button[TOOL_MODE_SELECT]->set_toggle_mode(true);
|
||||
tool_button[TOOL_MODE_SELECT]->set_flat(true);
|
||||
tool_button[TOOL_MODE_SELECT]->set_pressed(true);
|
||||
|
@ -6592,10 +6598,10 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_button[TOOL_MODE_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q));
|
||||
tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked."));
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
tool_button[TOOL_MODE_MOVE] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_MODE_MOVE]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_MODE_MOVE]);
|
||||
tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true);
|
||||
tool_button[TOOL_MODE_MOVE]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_MOVE;
|
||||
|
@ -6603,7 +6609,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W));
|
||||
|
||||
tool_button[TOOL_MODE_ROTATE] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_MODE_ROTATE]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_MODE_ROTATE]);
|
||||
tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true);
|
||||
tool_button[TOOL_MODE_ROTATE]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_ROTATE;
|
||||
|
@ -6611,17 +6617,17 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E));
|
||||
|
||||
tool_button[TOOL_MODE_SCALE] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_MODE_SCALE]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_MODE_SCALE]);
|
||||
tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true);
|
||||
tool_button[TOOL_MODE_SCALE]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_SCALE;
|
||||
tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R));
|
||||
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
tool_button[TOOL_MODE_LIST_SELECT] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_MODE_LIST_SELECT]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_MODE_LIST_SELECT]);
|
||||
tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true);
|
||||
tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_LIST_SELECT;
|
||||
|
@ -6629,37 +6635,37 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
|
||||
|
||||
tool_button[TOOL_LOCK_SELECTED] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_LOCK_SELECTED]);
|
||||
button_binds.write[0] = MENU_LOCK_SELECTED;
|
||||
tool_button[TOOL_LOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved)."));
|
||||
tool_button[TOOL_LOCK_SELECTED]->set_shortcut(ED_SHORTCUT("editor/lock_selected_nodes", TTR("Lock Selected Node(s)"), KEY_MASK_CMD | KEY_L));
|
||||
|
||||
tool_button[TOOL_UNLOCK_SELECTED] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_UNLOCK_SELECTED]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_UNLOCK_SELECTED]);
|
||||
button_binds.write[0] = MENU_UNLOCK_SELECTED;
|
||||
tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved)."));
|
||||
tool_button[TOOL_UNLOCK_SELECTED]->set_shortcut(ED_SHORTCUT("editor/unlock_selected_nodes", TTR("Unlock Selected Node(s)"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_L));
|
||||
|
||||
tool_button[TOOL_GROUP_SELECTED] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_GROUP_SELECTED]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_GROUP_SELECTED]);
|
||||
button_binds.write[0] = MENU_GROUP_SELECTED;
|
||||
tool_button[TOOL_GROUP_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_GROUP_SELECTED]->set_tooltip(TTR("Makes sure the object's children are not selectable."));
|
||||
tool_button[TOOL_GROUP_SELECTED]->set_shortcut(ED_SHORTCUT("editor/group_selected_nodes", TTR("Group Selected Node(s)"), KEY_MASK_CMD | KEY_G));
|
||||
|
||||
tool_button[TOOL_UNGROUP_SELECTED] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_UNGROUP_SELECTED]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_UNGROUP_SELECTED]);
|
||||
button_binds.write[0] = MENU_UNGROUP_SELECTED;
|
||||
tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
|
||||
tool_button[TOOL_UNGROUP_SELECTED]->set_tooltip(TTR("Restores the object's children's ability to be selected."));
|
||||
tool_button[TOOL_UNGROUP_SELECTED]->set_shortcut(ED_SHORTCUT("editor/ungroup_selected_nodes", TTR("Ungroup Selected Node(s)"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_G));
|
||||
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
tool_option_button[TOOL_OPT_LOCAL_COORDS] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_option_button[TOOL_OPT_LOCAL_COORDS]);
|
||||
main_menu_hbox->add_child(tool_option_button[TOOL_OPT_LOCAL_COORDS]);
|
||||
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true);
|
||||
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_LOCAL_COORDS;
|
||||
|
@ -6667,17 +6673,17 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T));
|
||||
|
||||
tool_option_button[TOOL_OPT_USE_SNAP] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_option_button[TOOL_OPT_USE_SNAP]);
|
||||
main_menu_hbox->add_child(tool_option_button[TOOL_OPT_USE_SNAP]);
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true);
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_USE_SNAP;
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", this, "_menu_item_toggled", button_binds);
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y));
|
||||
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]);
|
||||
main_menu_hbox->add_child(tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]);
|
||||
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_toggle_mode(true);
|
||||
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_flat(true);
|
||||
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_disabled(true);
|
||||
|
@ -6686,7 +6692,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
_update_camera_override_button(false);
|
||||
|
||||
tool_button[TOOL_CONVERT_ROOMS] = memnew(ToolButton);
|
||||
hbc_menu->add_child(tool_button[TOOL_CONVERT_ROOMS]);
|
||||
main_menu_hbox->add_child(tool_button[TOOL_CONVERT_ROOMS]);
|
||||
tool_button[TOOL_CONVERT_ROOMS]->set_toggle_mode(false);
|
||||
tool_button[TOOL_CONVERT_ROOMS]->set_flat(true);
|
||||
button_binds.write[0] = MENU_TOOL_CONVERT_ROOMS;
|
||||
|
@ -6694,7 +6700,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
tool_button[TOOL_CONVERT_ROOMS]->set_shortcut(ED_SHORTCUT("spatial_editor/convert_rooms", TTR("Convert Rooms"), KEY_MASK_ALT | KEY_C));
|
||||
tool_button[TOOL_CONVERT_ROOMS]->set_tooltip(TTR("Converts rooms for portal culling."));
|
||||
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
// Drag and drop support;
|
||||
preview_node = memnew(Spatial);
|
||||
|
@ -6727,7 +6733,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
transform_menu = memnew(MenuButton);
|
||||
transform_menu->set_text(TTR("Transform"));
|
||||
transform_menu->set_switch_on_hover(true);
|
||||
hbc_menu->add_child(transform_menu);
|
||||
main_menu_hbox->add_child(transform_menu);
|
||||
|
||||
p = transform_menu->get_popup();
|
||||
p->add_shortcut(ED_SHORTCUT("spatial_editor/snap_to_floor", TTR("Snap Object to Floor"), KEY_PAGEDOWN), MENU_SNAP_TO_FLOOR);
|
||||
|
@ -6742,17 +6748,17 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
// TRANSLATORS: Noun, name of the 2D/3D View menus.
|
||||
view_menu->set_text(TTR("View"));
|
||||
view_menu->set_switch_on_hover(true);
|
||||
hbc_menu->add_child(view_menu);
|
||||
main_menu_hbox->add_child(view_menu);
|
||||
|
||||
hbc_menu->add_child(memnew(VSeparator));
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
context_menu_container = memnew(PanelContainer);
|
||||
hbc_context_menu = memnew(HBoxContainer);
|
||||
context_menu_container->add_child(hbc_context_menu);
|
||||
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.
|
||||
hbc_menu->add_child(context_menu_container);
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue