Skip to content

Commit d5942cf

Browse files
committed
Merge pull request godotengine#109792 from vaner-org/blendspace-better-cursor
Make BlendSpace selection tool consistent with StateMachine/BlendTree functionality
2 parents 60710df + 79b45ac commit d5942cf

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

editor/animation/animation_blend_space_1d_editor.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
123123
}
124124
}
125125

126-
if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
126+
if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed() && mb->get_button_index() == MouseButton::LEFT) {
127127
blend_space_draw->queue_redraw(); // why not
128128

129129
// try to see if a point can be selected
@@ -176,7 +176,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
176176
}
177177

178178
// *set* the blend
179-
if (mb.is_valid() && !mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
179+
if (mb.is_valid() && !mb->is_pressed() && !dragging_selected_attempt && ((tool_select->is_pressed() && mb->is_shift_pressed()) || tool_blend->is_pressed()) && mb->get_button_index() == MouseButton::LEFT) {
180180
float blend_pos = mb->get_position().x / blend_space_draw->get_size().x;
181181
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
182182
blend_pos += blend_space->get_min_space();
@@ -194,7 +194,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
194194
_update_edited_point_pos();
195195
}
196196

197-
if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
197+
if (mm.is_valid() && !dragging_selected_attempt && ((tool_select->is_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
198198
float blend_pos = mm->get_position().x / blend_space_draw->get_size().x;
199199
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
200200
blend_pos += blend_space->get_min_space();
@@ -649,21 +649,13 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
649649
Ref<ButtonGroup> bg;
650650
bg.instantiate();
651651

652-
tool_blend = memnew(Button);
653-
tool_blend->set_theme_type_variation(SceneStringName(FlatButton));
654-
tool_blend->set_toggle_mode(true);
655-
tool_blend->set_button_group(bg);
656-
top_hb->add_child(tool_blend);
657-
tool_blend->set_pressed(true);
658-
tool_blend->set_tooltip_text(TTR("Set the blending position within the space"));
659-
tool_blend->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace1DEditor::_tool_switch).bind(3));
660-
661652
tool_select = memnew(Button);
662653
tool_select->set_theme_type_variation(SceneStringName(FlatButton));
663654
tool_select->set_toggle_mode(true);
664655
tool_select->set_button_group(bg);
665656
top_hb->add_child(tool_select);
666-
tool_select->set_tooltip_text(TTR("Select and move points, create points with RMB."));
657+
tool_select->set_pressed(true);
658+
tool_select->set_tooltip_text(TTR("Select and move points.\nRMB: Create point at position clicked.\nShift+LMB+Drag: Set the blending position within the space."));
667659
tool_select->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace1DEditor::_tool_switch).bind(0));
668660

669661
tool_create = memnew(Button);
@@ -674,6 +666,14 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
674666
tool_create->set_tooltip_text(TTR("Create points."));
675667
tool_create->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace1DEditor::_tool_switch).bind(1));
676668

669+
tool_blend = memnew(Button);
670+
tool_blend->set_theme_type_variation(SceneStringName(FlatButton));
671+
tool_blend->set_toggle_mode(true);
672+
tool_blend->set_button_group(bg);
673+
top_hb->add_child(tool_blend);
674+
tool_blend->set_tooltip_text(TTR("Set the blending position within the space."));
675+
tool_blend->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace1DEditor::_tool_switch).bind(2));
676+
677677
tool_erase_sep = memnew(VSeparator);
678678
top_hb->add_child(tool_erase_sep);
679679
tool_erase = memnew(Button);

editor/animation/animation_blend_space_2d_editor.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
165165
}
166166
}
167167

168-
if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
168+
if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed() && mb->get_button_index() == MouseButton::LEFT) {
169169
blend_space_draw->queue_redraw(); //update anyway
170170
//try to see if a point can be selected
171171
selected_point = -1;
@@ -269,7 +269,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
269269
blend_space_draw->queue_redraw();
270270
}
271271

272-
if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
272+
if (mb.is_valid() && mb->is_pressed() && !dragging_selected_attempt && ((tool_select->is_pressed() && mb->is_shift_pressed()) || tool_blend->is_pressed()) && mb->get_button_index() == MouseButton::LEFT) {
273273
Vector2 blend_pos = (mb->get_position() / blend_space_draw->get_size());
274274
blend_pos.y = 1.0 - blend_pos.y;
275275
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -300,7 +300,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
300300
blend_space_draw->queue_redraw();
301301
}
302302

303-
if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
303+
if (mm.is_valid() && !dragging_selected_attempt && ((tool_select->is_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
304304
Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size());
305305
blend_pos.y = 1.0 - blend_pos.y;
306306
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -871,21 +871,13 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
871871
Ref<ButtonGroup> bg;
872872
bg.instantiate();
873873

874-
tool_blend = memnew(Button);
875-
tool_blend->set_theme_type_variation(SceneStringName(FlatButton));
876-
tool_blend->set_toggle_mode(true);
877-
tool_blend->set_button_group(bg);
878-
top_hb->add_child(tool_blend);
879-
tool_blend->set_pressed(true);
880-
tool_blend->set_tooltip_text(TTR("Set the blending position within the space"));
881-
tool_blend->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(3));
882-
883874
tool_select = memnew(Button);
884875
tool_select->set_theme_type_variation(SceneStringName(FlatButton));
885876
tool_select->set_toggle_mode(true);
886877
tool_select->set_button_group(bg);
887878
top_hb->add_child(tool_select);
888-
tool_select->set_tooltip_text(TTR("Select and move points, create points with RMB."));
879+
tool_select->set_pressed(true);
880+
tool_select->set_tooltip_text(TTR("Select and move points.\nRMB: Create point at position clicked.\nShift+LMB+Drag: Set the blending position within the space."));
889881
tool_select->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(0));
890882

891883
tool_create = memnew(Button);
@@ -896,13 +888,21 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
896888
tool_create->set_tooltip_text(TTR("Create points."));
897889
tool_create->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(1));
898890

891+
tool_blend = memnew(Button);
892+
tool_blend->set_theme_type_variation(SceneStringName(FlatButton));
893+
tool_blend->set_toggle_mode(true);
894+
tool_blend->set_button_group(bg);
895+
top_hb->add_child(tool_blend);
896+
tool_blend->set_tooltip_text(TTR("Set the blending position within the space."));
897+
tool_blend->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(2));
898+
899899
tool_triangle = memnew(Button);
900900
tool_triangle->set_theme_type_variation(SceneStringName(FlatButton));
901901
tool_triangle->set_toggle_mode(true);
902902
tool_triangle->set_button_group(bg);
903903
top_hb->add_child(tool_triangle);
904904
tool_triangle->set_tooltip_text(TTR("Create triangles by connecting points."));
905-
tool_triangle->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(2));
905+
tool_triangle->connect(SceneStringName(pressed), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_tool_switch).bind(3));
906906

907907
tool_erase_sep = memnew(VSeparator);
908908
top_hb->add_child(tool_erase_sep);

0 commit comments

Comments
 (0)