-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Scroll Container exposes Damping, Sensitivity, Follow Focus Buffer #58318
base: master
Are you sure you want to change the base?
Scroll Container exposes Damping, Sensitivity, Follow Focus Buffer #58318
Conversation
2a74487
to
5ad54b4
Compare
f6de597
to
717bb9c
Compare
717bb9c
to
56240ef
Compare
54d0279
to
66f3318
Compare
Okay. I added PROPERTY_HINT_RANGE to this branch and the 3.x version for the new properties. |
4a6ccb9
to
87a1a02
Compare
de4743b
to
6886a11
Compare
doc/classes/ScrollContainer.xml
Outdated
If [code]true[/code], the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible. Use in combination with [member follow_focus_buffer] to specify how far past the control to scroll. | ||
</member> | ||
<member name="follow_focus_buffer" type="Vector2" setter="set_follow_focus_buffer" getter="get_follow_focus_buffer" default="Vector2(0, 0)"> | ||
When [member follow_focus] is [code]true[/code], specifies how far past the focused control to scroll, so that the focused control is not barely visibile. |
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.
When [member follow_focus] is [code]true[/code], specifies how far past the focused control to scroll, so that the focused control is not barely visibile. | |
When [member follow_focus] is [code]true[/code], specifies how far past the focused control to scroll, so that the focused control is not barely visible. |
Aside from the typo, "is not barely visible" sounds a bit awkward to me. Does it mean "is not visible at all", or "is fully visible"?
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.
Original behaviour is to just barely scroll the scroll container enough to have the focused element in view, this allows you to set a buffer to scroll past the focused container. Not sure what a better wording is.
Maybe even just "When [member follow_focus] is [code]true[/code], specifies how far past the focused control to scroll."
scene/gui/scroll_container.cpp
Outdated
return sensitivity; | ||
} | ||
|
||
void ScrollContainer::set_scroll_sensitivity(float _sensitivity) { |
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.
Parameters should start with p_
.
scene/gui/scroll_container.cpp
Outdated
if (_sensitivity < 0.0) { | ||
WARN_PRINT("scroll_wheel_sensitivity cannot be negative"); | ||
_sensitivity = 0.0; | ||
} |
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 can be an error condition instead:
if (_sensitivity < 0.0) { | |
WARN_PRINT("scroll_wheel_sensitivity cannot be negative"); | |
_sensitivity = 0.0; | |
} | |
ERR_FAIL_COND(p_sensitivity < 0.0); |
scene/gui/scroll_container.cpp
Outdated
sensitivity = _sensitivity; | ||
} | ||
|
||
void ScrollContainer::set_follow_focus_buffer(Vector2 buffer) { |
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.
void ScrollContainer::set_follow_focus_buffer(Vector2 buffer) { | |
void ScrollContainer::set_follow_focus_buffer(Vector2 p_buffer) { |
scene/gui/scroll_container.cpp
Outdated
return damping; | ||
} | ||
|
||
void ScrollContainer::set_scroll_damping(float d) { |
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.
void ScrollContainer::set_scroll_damping(float d) { | |
void ScrollContainer::set_scroll_damping(float p_damping) { |
scene/gui/scroll_container.cpp
Outdated
if (_sensitivity < 0.0) { | ||
WARN_PRINT("pan_gesture_sensitivity cannot be negative"); | ||
_sensitivity = 0.0; | ||
} |
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.
Same here.
// original sensitivity was 0.125 | ||
float scaled_sensitivity = sensitivity * 0.125; |
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.
Maybe sensitivity
should default to 0.125
instead of being a scaling factor for a hardcoded 0.125
?
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.
I think scaling it this way works well as having the default appear to the user as '1.0' makes the factor easy to understand in your head. But if you want me to remove the 0.125 scaling factor and change the default to 0.125 instead of 1.0 then I will do that.
We've discussed this in a PR meeting, and it would be nice to gather more feedback from users. The linked proposal is only about one thing out of everything exposed here, and it doesn't have any discussion. We can post this PR on Twitter to spark a bit of discussion there. Maybe there are other sources that you can link too? |
Can you summarise the core of the discussion? What specifically are you interested in feedback on? Previously, 'damping' and 'sensitivity' were hard coded values chosen years ago. And the sensitivity on the pan gesture on web platforms was set extremely high and was untunable. This seems like a pure positive to expose these values to the user. There are no fundamental changes here, just more control offered to the user. |
1ce9797
to
73d2776
Compare
73d2776
to
32d1a99
Compare
Just the general. Do other users need this, and if they do, is this the solution that works for them. |
See also the discussion in #47931, which also aims to improve the touchscreen scrolling experience. I think #47931 is a more robust solution to improve smooth scrolling, but it'll break compatibility so it can only be considered for 4.0. However, it doesn't expose scroll sensitivity and follow focus buffer, so I think both PRs are relevant. As for user need, I'd say issues like #21137 show that there's a lot of demand for improving how scrolling behaves on touchscreens in Godot. The current implementation is clearly subpar compared to system applications or even Chromium. |
#21137 is 4 years old and hyperbolic. Scrolling works on touchscreens on Android. That user maybe doesnt have emulate mouse from touch enabled? I think this issue should be closed. As for #47931 I'd agree that the inertial scrolling function could probably be different as it doesnt feel quite right as is, but it's important to note just how similar this PR is to this one from a user's perspective. Increasing the 'scroll damping' PR is basically 80% of what using the 'quadratic damping' function will achieve. I think this other PR may have more code changes than is needed, making it difficult to review. We could add 'quadratic damping' to scroll_container.cpp without such a large changeset. A smaller change set would lower the risk of regression and be easier to review. This large changeset is probably why this PR hasnt been merged in over a year. Maybe it's better code, maybe not? This PR also separates 'pan gesture sensivity' from "scroll sensitivity" which allows tuning of laptop trackpads, for instance. |
I'm currently working on a mobile app with a lot of scrollable lists and fully support this PR. The current default scroll speed for Scroll Containers is way too fast on mobile devices. Please expose those properties to the user. Thanks. |
Needs rebase. Also what's the purpose of the new project settings? They don't seem used. |
Adds scroll wheel sensitivity, pan gesture sensitivity and damping settings to scroll container so that users can tune these values.
The values that are currently hard coded into godot are the default values of these new settings.
Follow Focus buffer is a vector2 that describes extra space that the 'follow focus' setting will use to track the focused control. This makes it so that when the scroll container follows the focus, it tries to scroll a bit past the focused control so it's not 'barely' visibile.
3.x version: #58319
Bugsquad edit: This partially addresses godotengine/godot-proposals#3975 (only for ScrollContainer, not other nodes).