summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-07-14 16:31:43 +0200
committerGitHub <noreply@github.com>2022-07-14 16:31:43 +0200
commit8bfb634eac8d04ac5f37554d8e062c939920a775 (patch)
treeaf672d6c3c4b45fb44ccd3630813285d81f06172
parent748609feacb7af3081cd9dbcd101ad30ed31d7b2 (diff)
parent87fb95f1ffa77a3d2bd9edae4dbb2037cc22f072 (diff)
Merge pull request #62997 from KoBeWi/drag_void
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp43
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
2 files changed, 25 insertions, 20 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 6dfa11642c..9723fece5e 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1201,7 +1201,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
}
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1369,14 +1369,14 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
drag_selection[0]->get_name(),
drag_selection[0]->_edit_get_pivot().x,
drag_selection[0]->_edit_get_pivot().y));
- drag_type = DRAG_NONE;
+ _reset_drag();
return true;
}
// Cancel a drag
if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1452,14 +1452,14 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
_insert_animation_keys(false, true, false, true);
}
- drag_type = DRAG_NONE;
+ _reset_drag();
return true;
}
// Cancel a drag
if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1614,14 +1614,14 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
_commit_canvas_item_state(
drag_selection,
vformat(TTR("Move CanvasItem \"%s\" Anchor"), drag_selection[0]->get_name()));
- drag_type = DRAG_NONE;
+ _reset_drag();
return true;
}
// Cancel a drag
if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1820,7 +1820,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1830,7 +1830,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
_restore_canvas_item_state(drag_selection);
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1959,7 +1959,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
_insert_animation_keys(false, false, true, true);
}
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -1967,7 +1967,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
// Cancel a drag
if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -2092,7 +2092,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -2102,7 +2102,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
_restore_canvas_item_state(drag_selection, true);
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -2209,7 +2209,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
drag_selection[0]->_edit_get_position().y),
true);
}
- drag_type = DRAG_NONE;
+ _reset_drag();
}
viewport->update();
return true;
@@ -2360,7 +2360,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
if (drag_type == DRAG_QUEUED) {
if (b.is_valid() && !b->is_pressed()) {
- drag_type = DRAG_NONE;
+ _reset_drag();
return true;
}
if (m.is_valid()) {
@@ -2411,14 +2411,14 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
}
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) {
// Cancel box selection
- drag_type = DRAG_NONE;
+ _reset_drag();
viewport->update();
return true;
}
@@ -3981,7 +3981,7 @@ void CanvasItemEditor::_notification(int p_what) {
void CanvasItemEditor::_selection_changed() {
if (!selected_from_canvas) {
- drag_type = DRAG_NONE;
+ _reset_drag();
}
selected_from_canvas = false;
}
@@ -3989,7 +3989,7 @@ void CanvasItemEditor::_selection_changed() {
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
Array selection = editor_selection->get_selected_nodes();
if (selection.size() != 1 || Object::cast_to<Node>(selection[0]) != p_canvas_item) {
- drag_type = DRAG_NONE;
+ _reset_drag();
// Clear the selection
editor_selection->clear(); //_clear_canvas_items();
@@ -4701,6 +4701,11 @@ void CanvasItemEditor::_focus_selection(int p_op) {
}
}
+void CanvasItemEditor::_reset_drag() {
+ drag_type = DRAG_NONE;
+ drag_selection.clear();
+}
+
void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_override_camera_button", "game_running"), &CanvasItemEditor::_update_override_camera_button);
ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 5f50882dba..83685baf7a 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -455,8 +455,8 @@ private:
void _update_cursor();
void _selection_changed();
-
void _focus_selection(int p_op);
+ void _reset_drag();
SnapTarget snap_target[2];
Transform2D snap_transform;