Added selection outline to locked nodes.

(cherry picked from commit 7f5fb73146)
This commit is contained in:
Eric M 2020-04-15 22:03:12 +10:00 committed by Rémi Verschelde
parent e869da9665
commit e2c9cbb79f
1 changed files with 8 additions and 2 deletions

View File

@ -3132,13 +3132,15 @@ void CanvasItemEditor::_draw_selection() {
RID ci = viewport->get_canvas_item(); RID ci = viewport->get_canvas_item();
List<CanvasItem *> selection = _get_edited_canvas_items(false, false); List<CanvasItem *> selection = _get_edited_canvas_items(true, false);
bool single = selection.size() == 1; bool single = selection.size() == 1;
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
bool item_locked = canvas_item->has_meta("_edit_lock_");
// Draw the previous position if we are dragging the node // Draw the previous position if we are dragging the node
if (show_helpers && if (show_helpers &&
(drag_type == DRAG_MOVE || drag_type == DRAG_ROTATE || (drag_type == DRAG_MOVE || drag_type == DRAG_ROTATE ||
@ -3178,6 +3180,10 @@ void CanvasItemEditor::_draw_selection() {
Color c = Color(1, 0.6, 0.4, 0.7); Color c = Color(1, 0.6, 0.4, 0.7);
if (item_locked) {
c = Color(0.7, 0.7, 0.7, 0.7);
}
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE), true); viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE), true);
} }
@ -3190,7 +3196,7 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_set_transform_matrix(viewport->get_transform()); viewport->draw_set_transform_matrix(viewport->get_transform());
} }
if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
// Draw the pivot // Draw the pivot
if (canvas_item->_edit_use_pivot()) { if (canvas_item->_edit_use_pivot()) {