Merge pull request #116685 from YeldhamDev/gridmap_reset_button

Add button to clear rotation in the `GridMap` editor
This commit is contained in:
Thaddeus Crews 2026-03-06 12:40:29 -06:00
commit cac8aad359
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 12 additions and 1 deletions

View file

@ -1263,6 +1263,7 @@ void GridMapEditor::_update_theme() {
rotate_x_button->set_button_icon(get_theme_icon(SNAME("RotateLeft"), EditorStringName(EditorIcons)));
rotate_y_button->set_button_icon(get_theme_icon(SNAME("ToolRotate"), EditorStringName(EditorIcons)));
rotate_z_button->set_button_icon(get_theme_icon(SNAME("RotateRight"), EditorStringName(EditorIcons)));
clear_rotation_button->set_button_icon(get_theme_icon(SNAME("UndoRedo"), EditorStringName(EditorIcons)));
mode_thumbnail->set_button_icon(get_theme_icon(SNAME("FileThumbnail"), EditorStringName(EditorIcons)));
mode_list->set_button_icon(get_theme_icon(SNAME("FileList"), EditorStringName(EditorIcons)));
options->set_button_icon(get_theme_icon(SNAME("Tools"), EditorStringName(EditorIcons)));
@ -1451,7 +1452,7 @@ GridMapEditor::GridMapEditor() {
ED_SHORTCUT("grid_map/edit_y_axis", TTRC("Edit Y Axis"), KeyModifierMask::SHIFT + Key::X, true);
ED_SHORTCUT("grid_map/edit_z_axis", TTRC("Edit Z Axis"), KeyModifierMask::SHIFT + Key::C, true);
ED_SHORTCUT("grid_map/keep_selected", TTRC("Keep Selection"));
ED_SHORTCUT("grid_map/clear_rotation", TTRC("Clear Rotation"));
ED_SHORTCUT("grid_map/clear_rotation", TTRC("Clear Rotation"), KeyModifierMask::ALT | Key::G, true);
options = memnew(MenuButton);
options->set_theme_type_variation(SceneStringName(FlatButton));
@ -1629,6 +1630,15 @@ GridMapEditor::GridMapEditor() {
rotation_buttons->add_child(rotate_z_button);
viewport_shortcut_buttons.push_back(rotate_z_button);
clear_rotation_button = memnew(Button);
clear_rotation_button->set_theme_type_variation(SceneStringName(FlatButton));
clear_rotation_button->set_shortcut(ED_GET_SHORTCUT("grid_map/clear_rotation"));
clear_rotation_button->set_accessibility_name(TTRC("Cursor Reset Rotation"));
clear_rotation_button->connect(SceneStringName(pressed),
callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_CURSOR_CLEAR_ROTATION));
rotation_buttons->add_child(clear_rotation_button);
viewport_shortcut_buttons.push_back(clear_rotation_button);
// Wide empty separation control. (like BoxContainer::add_spacer())
Control *c = memnew(Control);
c->set_mouse_filter(MOUSE_FILTER_PASS);

View file

@ -93,6 +93,7 @@ class GridMapEditor : public EditorDock {
Button *rotate_x_button = nullptr;
Button *rotate_y_button = nullptr;
Button *rotate_z_button = nullptr;
Button *clear_rotation_button = nullptr;
EditorZoomWidget *zoom_widget = nullptr;
Button *mode_thumbnail = nullptr;