-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent editing properties managed by parent container #30623
Prevent editing properties managed by parent container #30623
Conversation
editor/editor_inspector.cpp
Outdated
@@ -600,6 +600,40 @@ bool EditorProperty::is_selected() const { | |||
return selected; | |||
} | |||
|
|||
void EditorProperty::disable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function looks a little bit dirty. Most buttons (and hopefully spinboxes) have a disabled property, it might make sense to use that instead of using a mouse filter and changing focus mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the inspector uses EditorSpinSlider
s which don't have a way to be disabled (I tried setting them as read-only but could still edit them if I got focus through tabbing). I'll use the same approach used in SpinBox
and add set_editable
and is_editable
to EditorSpinSlider
(if it's considered a good approach).
Here's the code used when trying to use the read-only approach:
void EditorProperty::disable() {
// Make it visually apparent that the property is disabled
Color color = get_modulate();
color.a = color.a * 0.5;
set_modulate(color);
// Make it non editable
set_mouse_filter(MOUSE_FILTER_IGNORE);
set_focus_mode(FOCUS_NONE);
int child_count = get_child_count();
for (int i = 0; i < child_count; i++) {
Node *child = get_child(i);
Container *container = Object::cast_to<Container>(child);
if (container) {
container->set_mouse_filter(MOUSE_FILTER_IGNORE);
container->set_focus_mode(FOCUS_NONE);
int container_child_count = container->get_child_count();
for (int j = 0; j < container_child_count; j++) {
Node *container_child = container->get_child(j);
EditorSpinSlider *spin_slider = Object::cast_to<EditorSpinSlider>(container_child);
if (spin_slider) {
spin_slider->set_read_only(true);
}
}
} else {
EditorSpinSlider *spin_slider = Object::cast_to<EditorSpinSlider>(child);
if (spin_slider) {
spin_slider->set_read_only(true);
}
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add set_editable and is_editable to EditorSpinSlider
Yes, that's likely the best solution IMHO.
I completely agree with the proposed feature, only the implementation needs a rework. :) |
Thanks! I'm really looking forward to this feature! |
Perhaps we can expand this and flip it around so that the expand flags are disabled unless the node is in a container? |
Any news on this one? |
Hey, sorry for not giving any updates. I'm available to apply any needed modifications to make this pull request mergeable. |
Note that |
@groud When I was testing the case in #38356, the scale was reset on visibility toggle. So, a child of Edit: p_child->set_position(r.position);
p_child->set_size(r.size);
p_child->set_rotation(0);
p_child->set_scale(Vector2(1, 1)); So, yeah, it should be disabled (along with rotation, it seems). |
Interesting. I think this was not done before, maybe this was modified. I am not sure what should be done there, maybe the scale should be reset for all containers, but I am not sure it is the case. |
Scale was certainly reset (by the Container) in the past. |
Ah yes you are right, so indeed |
|
@Awkor This needs to be rebased on the latest master branch when you have the chance. |
@aaronfranke Done. |
You have formatting issues, namely empty lines at the start of some functions. |
Sorry to disrupt the productive conversation, but I just wanted to say that I was about to request this and I agree 100% that it’ll make beginner’s lives easier. It took months for Godot’s Controls to “click”with me, and I think the lack of this feature is partially responsible for the steep learning curve. Thanks for making it happen! |
I think we can use this as a solution and address concerns voiced by @KoBeWi with a future PR. If a new method was to be added to the This would complicate things, however, and the problem that this PR fixes is very much annoying to a lot of new users. We can clean up the backend later, I think, if we address the UX now. Also, @groud, can you please check if your concerns were addressed and update your review? |
Well, there are a things do not seem correct to me with the current implementation. Few points:
In the current state, the PR does the job well but is quite hacky. We still have some time before 4.0, so I'd rather have this made in a cleaner way. |
See also godotengine/godot-proposals#2841 |
There is #51722 which adds a proper |
If it gets merged, I'll rebase and use that. |
Done. |
It seems to be needing to include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK looks good to me. Let's merge this!
Thanks!
The issue is not fixed in 3.5, because the fix depends on #51722, which was merged only on master. |
Addresses #28718 by making the properties that are managed by parent container not editable inside the inspector.
Currently the properties that get disabled are:
This is achieved by disabling mouse interactions and preventing focus on the aforementioned inspector properties.
This is how it looks when properties get disabled:
Bugsquad edit: Fixes #28718 and fixes godotengine/godot-proposals#2202.