-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
scrollcontainer: Add automatic scrollbar calculation #14623
Conversation
Doesn't fix #12482 entirely, because that issue wants to set other scrollbaroptions as well, like thumb size. |
Aw that's what I thought this did... |
The scroll factor defines the scrolling "resolution". The default In my opinion, having the scroll factor depend on the content size doesn't make sense. The proper way to use a P.S.: Since the scroll factor defines the scrolling resolution, it's also relevant for animations. For my experimental "inertial scrolling on Android" branch, I had to decrease the scroll factor (increase the scrolling resolution) used by the settings menu to make a smooth animation possible: scroll factor diff.txt |
The apparent inner container size is currently defined by
These values should not need to be calculated manually. It is tedious work, prone to break in future formspec updates, and might result in cargocult/boilerplate code. Automatic content size with constant |
I didn't say that, there must be a misunderstanding. The way scroll containers work makes sense, it's just complicated to get right manually.
In general, this is a good idea. I just disagree with a design choice made in this PR.
I agree that manually calculating these values is unnecessarily complicated. However, "the proper way" I described (constant scroll factor,
"Constant
The scrollbar stores its position as an int. With constant
With the default That's why this PR's approach is wrong IMO. "Constant scroll factor, |
Here's an implementation of what I imagine, on top of your PR: grorp@737acd1 (or to see the changes compared to master: grorp/luanti@737acd1~3...737acd1) I also made the settings menu use the new option, works well. This didn't work well with the implementation in this PR. There's still a conceptual problem my implementation inherits from this PR though: Using the bounding box of the children means you cannot have padding at the end of the scroll_container, which the settings menu needs. Possible solution: Allow manually specifying a content length as the last scroll_container parameter, instead of the auto parameter. Specifying a content length enables auto mode. |
As long you don't care about the relative scroll progress - i.e.
When you reach the point where 1 increment scrolls more than - let's say - 1/4th the container size, then it's very likely that a new concept is needed for such formspec. We would also be far beyond of what can be reasonably searched by the scrollbar thumb.
I assume that your "enables auto mode" means automatic |
That's true, but problems already start earlier. Here's the problem case I had in mind when writing #14623 (comment): I was working on an experimental "swipe to scroll + inertial/kinetic scrolling on Android" branch. Scrolling in the settings menu (scroll_container) wasn't smooth and felt jerky, while scrolling e.g. in the serverlist (textlist) was smooth. I found that on my Android device (high display density) in the settings menu, the default scroll factor of 0.1 results in To satisfy this, I had to decrease the scroll factor to 0.0095238095 or lower (I used 0.001) and of course adjust All this makes me think that we might want to, in addition to what we've already been talking about, ...
Obviously this is not necessary for this PR.
🎉 |
039d1f4
to
c48341a
Compare
c48341a
to
c743ed5
Compare
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.
Tested; works. Very useful feature. Just a few minor comments.
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.
LGTM
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.
- 🎉
- How to test instructions in top comment look outdated.
- Please add something in
/test_formspec
. - Afaik, scollbar min,max can also be negative. Should we maybe support content that is above 0?
(<content padding>
could be<content padding neg>,<content padding pos>
, where empty (or,
) means no auto,<num>,
means set max to 0,,<num>
means set min to 0, and<num>,<num>
means both min and max depend on content.)
47b6607
to
441e245
Compare
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.
Afaik, scollbar min,max can also be negative. Should we maybe support content that is above 0?
@SmallJoker Thoughts on this? Yes/No?
441e245
to
e5f513a
Compare
Although slightly hacky, modders can achieve the same thing by setting the scrollbar to a very high value, which will scroll to the bottom. Negative values do make sense for other purposes, such as sliders where negative values are wanted. |
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.
Looks good. Thanks!
Sorry for late re-review.
Should we maybe support content that is above 0?
Although slightly hacky, modders can achieve the same thing by setting the scrollbar to a very high value, which will scroll to the bottom.
Right.
It's probably too niche of a feature to support anyways, and adding it later is still possible.
(Not adding two approvals label, because there were changes @v-rob's approval.)
Doesn't require my approval since the PR is by a core dev, but the changes appear to be fine to me. |
New parameter 'content padding'. When specified, the scrollbar max value is calculated automatically. This aims to reduce manual calculation functions.
e5f513a
to
4af9819
Compare
There's also a bit less padding at the bottom. |
Co-authored-by: grorp <[email protected]>
@grorp I did the calculation. With PR, settings tab "Minetest Game", visible area 600/398×162 = 244 px. Not pixel-perfect but from what I can see it's mathematically correct proportions. |
Co-authored-by: grorp <[email protected]>
When specifying 'scroll factor'='auto', it will be calculated automatically based
on the associated scrollbar maximal value. Previously, calculating the exact value was mostly guesswork and try & error.
EDIT: This could also be implemented in reverse by adjusting the maximum value of the scrollbar, which would however be more annoying to read out from mods.
Part fix for #12482
To do
This PR is Ready for Review.
How to test
/test_formspec
in devtest