|
@@ -780,19 +780,24 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po
|
|
|
return still_selected;
|
|
|
}
|
|
|
|
|
|
-List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retrieve_locked, bool remove_canvas_item_if_parent_in_selection) const {
|
|
|
+List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool p_retrieve_locked, bool p_remove_canvas_item_if_parent_in_selection, bool *r_has_locked_items) const {
|
|
|
List<CanvasItem *> selection;
|
|
|
for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) {
|
|
|
CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
|
|
|
- if (ci && ci->is_visible_in_tree() && ci->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(ci))) {
|
|
|
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
|
|
|
- if (se) {
|
|
|
- selection.push_back(ci);
|
|
|
+ if (ci) {
|
|
|
+ if (ci->is_visible_in_tree() && ci->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (p_retrieve_locked || !_is_node_locked(ci))) {
|
|
|
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
|
|
|
+ if (se) {
|
|
|
+ selection.push_back(ci);
|
|
|
+ }
|
|
|
+ } else if (r_has_locked_items) {
|
|
|
+ // CanvasItem is selected, but can't be interacted with.
|
|
|
+ *r_has_locked_items = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (remove_canvas_item_if_parent_in_selection) {
|
|
|
+ if (p_remove_canvas_item_if_parent_in_selection) {
|
|
|
List<CanvasItem *> filtered_selection;
|
|
|
for (CanvasItem *E : selection) {
|
|
|
if (!selection.find(E->get_parent())) {
|
|
@@ -1454,7 +1459,8 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed()) {
|
|
|
if ((b->is_command_or_control_pressed() && !b->is_alt_pressed() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
|
|
|
- List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
+ bool has_locked_items = false;
|
|
|
+ List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items);
|
|
|
|
|
|
// Remove not movable nodes
|
|
|
for (CanvasItem *E : selection) {
|
|
@@ -1477,6 +1483,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
|
|
}
|
|
|
_save_canvas_item_state(drag_selection);
|
|
|
return true;
|
|
|
+ } else {
|
|
|
+ if (has_locked_items) {
|
|
|
+ EditorToaster::get_singleton()->popup_str(TTR(locked_transform_warning), EditorToaster::SEVERITY_WARNING);
|
|
|
+ }
|
|
|
+ return has_locked_items;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1917,7 +1928,8 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
|
|
|
// Drag resize handles
|
|
|
if (drag_type == DRAG_NONE) {
|
|
|
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && ((b->is_alt_pressed() && b->is_command_or_control_pressed()) || tool == TOOL_SCALE)) {
|
|
|
- List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
+ bool has_locked_items = false;
|
|
|
+ List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items);
|
|
|
if (selection.size() == 1) {
|
|
|
CanvasItem *ci = selection.front()->get();
|
|
|
|
|
@@ -1946,6 +1958,11 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
|
|
|
_save_canvas_item_state(drag_selection);
|
|
|
return true;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (has_locked_items) {
|
|
|
+ EditorToaster::get_singleton()->popup_str(TTR(locked_transform_warning), EditorToaster::SEVERITY_WARNING);
|
|
|
+ }
|
|
|
+ return has_locked_items;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2056,7 +2073,8 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|
|
//Start moving the nodes
|
|
|
if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed()) {
|
|
|
if ((b->is_alt_pressed() && !b->is_command_or_control_pressed()) || tool == TOOL_MOVE) {
|
|
|
- List<CanvasItem *> selection = _get_edited_canvas_items();
|
|
|
+ bool has_locked_items = false;
|
|
|
+ List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items);
|
|
|
|
|
|
if (selection.size() > 0) {
|
|
|
drag_selection.clear();
|
|
@@ -2089,6 +2107,11 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|
|
_save_canvas_item_state(drag_selection);
|
|
|
|
|
|
return true;
|
|
|
+ } else {
|
|
|
+ if (has_locked_items) {
|
|
|
+ EditorToaster::get_singleton()->popup_str(TTR(locked_transform_warning), EditorToaster::SEVERITY_WARNING);
|
|
|
+ }
|
|
|
+ return has_locked_items;
|
|
|
}
|
|
|
}
|
|
|
}
|