Merge pull request #89132 from jsjtxietian/lock-update
Update lock and group button state when selection changed in CanvasItemEditor
This commit is contained in:
commit
72a31722fd
|
@ -2640,6 +2640,38 @@ void CanvasItemEditor::_update_cursor() {
|
|||
set_default_cursor_shape(c);
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_update_lock_and_group_button() {
|
||||
bool all_locked = true;
|
||||
bool all_group = true;
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
if (selection.is_empty()) {
|
||||
all_locked = false;
|
||||
all_group = false;
|
||||
} else {
|
||||
for (Node *E : selection) {
|
||||
CanvasItem *item = Object::cast_to<CanvasItem>(E);
|
||||
if (item) {
|
||||
if (all_locked && !item->has_meta("_edit_lock_")) {
|
||||
all_locked = false;
|
||||
}
|
||||
if (all_group && !item->has_meta("_edit_group_")) {
|
||||
all_group = false;
|
||||
}
|
||||
}
|
||||
if (!all_locked && !all_group) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock_button->set_visible(!all_locked);
|
||||
lock_button->set_disabled(selection.is_empty());
|
||||
unlock_button->set_visible(all_locked);
|
||||
group_button->set_visible(!all_group);
|
||||
group_button->set_disabled(selection.is_empty());
|
||||
ungroup_button->set_visible(all_group);
|
||||
}
|
||||
|
||||
Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) const {
|
||||
// Compute an eventual rotation of the cursor
|
||||
const CursorShape rotation_array[4] = { CURSOR_HSIZE, CURSOR_BDIAGSIZE, CURSOR_VSIZE, CURSOR_FDIAGSIZE };
|
||||
|
@ -3795,35 +3827,6 @@ void CanvasItemEditor::_draw_viewport() {
|
|||
transform.columns[2] = -view_offset * zoom;
|
||||
EditorNode::get_singleton()->get_scene_root()->set_global_canvas_transform(transform);
|
||||
|
||||
// hide/show buttons depending on the selection
|
||||
bool all_locked = true;
|
||||
bool all_group = true;
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
if (selection.is_empty()) {
|
||||
all_locked = false;
|
||||
all_group = false;
|
||||
} else {
|
||||
for (Node *E : selection) {
|
||||
if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_lock_")) {
|
||||
all_locked = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Node *E : selection) {
|
||||
if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_group_")) {
|
||||
all_group = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock_button->set_visible(!all_locked);
|
||||
lock_button->set_disabled(selection.is_empty());
|
||||
unlock_button->set_visible(all_locked);
|
||||
group_button->set_visible(!all_group);
|
||||
group_button->set_disabled(selection.is_empty());
|
||||
ungroup_button->set_visible(all_group);
|
||||
|
||||
_draw_grid();
|
||||
_draw_ruler_tool();
|
||||
_draw_axis();
|
||||
|
@ -4027,6 +4030,7 @@ void CanvasItemEditor::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void CanvasItemEditor::_selection_changed() {
|
||||
_update_lock_and_group_button();
|
||||
if (!selected_from_canvas) {
|
||||
_reset_drag();
|
||||
}
|
||||
|
|
|
@ -477,6 +477,7 @@ private:
|
|||
|
||||
void _gui_input_viewport(const Ref<InputEvent> &p_event);
|
||||
void _update_cursor();
|
||||
void _update_lock_and_group_button();
|
||||
|
||||
void _selection_changed();
|
||||
void _focus_selection(int p_op);
|
||||
|
|
Loading…
Reference in New Issue