zircon
zircon copied to clipboard
Scrollable controls
I think there's a lot to discuss here...here's the three things I can think of:
- How does it look?
- How does the user keyboard-navigate to it? Tab? Then arrow keys to scroll?
- How is it implemented? Decorator, component? New decorator, or aspect of existing decorator?
Re: appearance, perhaps this?
┌┤Foo├─────┐
│ ▲│
│ ■│
│ ░│
│ ░│
│ ▼│
└──────────┘
We already have a ScrollBar
, it is just not integrated yet. The problem right now is that Component
s can't be resized right now because resizing support would need a lot of other things (layout support and dynamic size
properties for example). What can be done is to have a Scrollable
thing that has a virtual and an actual size (just like with the LogArea
). What I'm thinking is that the best course of action is to provide scrollable components as Fragment
s. There are already some prototypes in place. Take a look here.
There is a naive implementation of a scrolling list in the scrollbar examples: https://github.com/Hexworks/zircon/blob/6c8a084e59cc0acdb2f9b3977ce036a911c97b22/zircon.jvm.examples/src/main/kotlin/org/hexworks/zircon/examples/components/ScrollBarExample.kt#L136
I noticed that -- I've been using it as a starting point and things are going pretty well. I'm making my version accept any T instead of just strings, and reusing labels kinda like Android does because adding/removing labels was causing the UI to chug a bit.
This sounds great. There is one problem with the ScrollBar
though and I don't know a good solution for this. If you drag the scroll button itself, move it hen move the mouse out of the scroll bar, then it no longer receives mouse events (since the mouse is no longer over it). I think there might be a solution for this somehow using event bubbling, but I'm not 100% sure.
Seems like on clicking the scrollbar, you could add a mousedrag handler to the screen/view/root that uses capture/bubble to track movement, then on mouseup release the handler and itself (the mouseup handler).
Can we split this off into a separate issue?
Yep, do you want to do it?
I'll probably pick it up (#374) once a few of my other PRs get merged.
I'm looking at the other PRs right now.