-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Expose methods to change viewport alignment #1953
Conversation
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 have simply introduced an absolute_offset_reversed
method instead. Will that work?
d29de5e
to
a92e38a
Compare
a92e38a
to
a9987cb
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.
Looks good, @hecrj. Thanks!
Eventually, we should probably expose a variant of the |
I believe `Offset::absolute` guarantees the offset never exceeds the maximum scrolling boundaries already.
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.
Cool! Thanks again 🙇
At what point should we prefer widget operations over managed app state? The same can probably be said for text input widget. As for composing widgets, a parent widget can still do widget operations within on_event right? It's not just the application that can do these. |
When commands are regularly needed to keep a widget in sync with some application state, then that's a sign there are multiple sources of truth. With managed app state you can derive any scrolling state from your application state without necessarily storing offsets at all.
Yes, a text input with a fully managed cursor has a bunch of valid use cases.
Yes, although I'm not sure that'd be very useful. You'd want the unmanaged widget to depend on the managed one, and the managed one won't expose operations ideally. |
Agreed! The need for managed state satisfies both use cases. The text input seems like a good test case for this since it really can go either way. Would you prefer two separate widgets, or one widget that exposes a |
Two separate widgets; one built on top of the other. Logic will be simpler this way, and we can expose specific APIs for each. |
As discussed in #1912, consumers need to be able to calculate new viewport offsets when swapping between alignments.
This exposes two new
with_<direction>_alignment
methods. If user wants to keep the scrollable's viewport anchored in the same position while swapping alignments, they can callviewport.with_alignment(new_alignment)
and return the new viewport'srelative_offset
toscroll_to
.