Merge pull request #88997 from jsjtxietian/parallax

Disable lock and group buttons when selected item is not CanvasItem
This commit is contained in:
Rémi Verschelde 2024-03-24 01:14:35 +01:00
commit 33cca7c65c
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 30 additions and 11 deletions

View file

@ -2643,6 +2643,7 @@ void CanvasItemEditor::_update_cursor() {
void CanvasItemEditor::_update_lock_and_group_button() {
bool all_locked = true;
bool all_group = true;
bool has_canvas_item = false;
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.is_empty()) {
all_locked = false;
@ -2657,6 +2658,7 @@ void CanvasItemEditor::_update_lock_and_group_button() {
if (all_group && !item->has_meta("_edit_group_")) {
all_group = false;
}
has_canvas_item = true;
}
if (!all_locked && !all_group) {
break;
@ -2664,12 +2666,17 @@ void CanvasItemEditor::_update_lock_and_group_button() {
}
}
all_locked = all_locked && has_canvas_item;
all_group = all_group && has_canvas_item;
lock_button->set_visible(!all_locked);
lock_button->set_disabled(selection.is_empty());
lock_button->set_disabled(!has_canvas_item);
unlock_button->set_visible(all_locked);
unlock_button->set_disabled(!has_canvas_item);
group_button->set_visible(!all_group);
group_button->set_disabled(selection.is_empty());
group_button->set_disabled(!has_canvas_item);
ungroup_button->set_visible(all_group);
ungroup_button->set_disabled(!has_canvas_item);
}
Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) const {
@ -4011,6 +4018,9 @@ void CanvasItemEditor::_notification(int p_what) {
AnimationPlayerEditor::get_singleton()->connect("animation_selected", callable_mp(this, &CanvasItemEditor::_keying_changed).unbind(1));
_keying_changed();
_update_editor_settings();
connect("item_lock_status_changed", callable_mp(this, &CanvasItemEditor::_update_lock_and_group_button));
connect("item_group_status_changed", callable_mp(this, &CanvasItemEditor::_update_lock_and_group_button));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {

View file

@ -7376,6 +7376,7 @@ void Node3DEditor::_selection_changed() {
void Node3DEditor::_refresh_menu_icons() {
bool all_locked = true;
bool all_grouped = true;
bool has_node3d_item = false;
List<Node *> &selection = editor_selection->get_selected_node_list();
@ -7384,26 +7385,34 @@ void Node3DEditor::_refresh_menu_icons() {
all_grouped = false;
} else {
for (Node *E : selection) {
if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_lock_")) {
all_locked = false;
break;
Node3D *node = Object::cast_to<Node3D>(E);
if (node) {
if (all_locked && !node->has_meta("_edit_lock_")) {
all_locked = false;
}
if (all_grouped && !node->has_meta("_edit_group_")) {
all_grouped = false;
}
has_node3d_item = true;
}
}
for (Node *E : selection) {
if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_group_")) {
all_grouped = false;
if (!all_locked && !all_grouped) {
break;
}
}
}
all_locked = all_locked && has_node3d_item;
all_grouped = all_grouped && has_node3d_item;
tool_button[TOOL_LOCK_SELECTED]->set_visible(!all_locked);
tool_button[TOOL_LOCK_SELECTED]->set_disabled(selection.is_empty());
tool_button[TOOL_LOCK_SELECTED]->set_disabled(!has_node3d_item);
tool_button[TOOL_UNLOCK_SELECTED]->set_visible(all_locked);
tool_button[TOOL_UNLOCK_SELECTED]->set_disabled(!has_node3d_item);
tool_button[TOOL_GROUP_SELECTED]->set_visible(!all_grouped);
tool_button[TOOL_GROUP_SELECTED]->set_disabled(selection.is_empty());
tool_button[TOOL_GROUP_SELECTED]->set_disabled(!has_node3d_item);
tool_button[TOOL_UNGROUP_SELECTED]->set_visible(all_grouped);
tool_button[TOOL_UNGROUP_SELECTED]->set_disabled(!has_node3d_item);
}
template <typename T>