Skip to content

Commit

Permalink
Allow all editor modes to select nodes in the viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
ryevdokimov committed Jan 5, 2024
1 parent fbaab3c commit ff03a32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
19 changes: 10 additions & 9 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2014,14 +2014,14 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if ((b->is_alt_pressed() && !b->is_command_or_control_pressed()) || tool == TOOL_MOVE) {
List<CanvasItem *> selection = _get_edited_canvas_items();

drag_selection.clear();
for (int i = 0; i < selection.size(); i++) {
if (_is_node_movable(selection[i], true)) {
drag_selection.push_back(selection[i]);
if (selection.size() > 0) {
drag_selection.clear();
for (int i = 0; i < selection.size(); i++) {
if (_is_node_movable(selection[i], true)) {
drag_selection.push_back(selection[i]);
}
}
}

if (selection.size() > 0) {
drag_type = DRAG_MOVE;

CanvasItem *ci = selection[0];
Expand All @@ -2043,8 +2043,9 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {

drag_from = transform.affine_inverse().xform(b->get_position());
_save_canvas_item_state(drag_selection);

return true;
}
return true;
}
}
}
Expand Down Expand Up @@ -2344,7 +2345,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
return true;
}

if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && tool == TOOL_SELECT && !panner->is_panning()) {
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && !panner->is_panning() && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE)) {
// Single item selection
Point2 click = transform.affine_inverse().xform(b->get_position());

Expand Down Expand Up @@ -2379,7 +2380,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
} else {
bool still_selected = _select_click_on_item(ci, click, b->is_shift_pressed());
// Start dragging
if (still_selected) {
if (still_selected && (tool == TOOL_SELECT || tool == TOOL_MOVE)) {
// Drag the node(s) if requested
drag_start_origin = click;
drag_type = DRAG_QUEUED;
Expand Down
6 changes: 3 additions & 3 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,17 +1839,17 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {

clicked = ObjectID();

if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->is_command_or_control_pressed()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
if (can_select_gizmos && ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->is_command_or_control_pressed()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)) {
begin_transform(TRANSFORM_ROTATE, false);
break;
}

if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
if (can_select_gizmos && spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
begin_transform(TRANSFORM_TRANSLATE, false);
break;
}

if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
if (can_select_gizmos && spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
begin_transform(TRANSFORM_SCALE, false);
break;
}
Expand Down

0 comments on commit ff03a32

Please sign in to comment.