Expose methods to change viewport alignment#1953
Conversation
hecrj
left a comment
There was a problem hiding this comment.
I have simply introduced an absolute_offset_reversed method instead. Will that work?
d29de5e to
a92e38a
Compare
a92e38a to
a9987cb
Compare
|
Eventually, we should probably expose a variant of the |
I believe `Offset::absolute` guarantees the offset never exceeds the maximum scrolling boundaries already.
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>_alignmentmethods. 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_offsettoscroll_to.