Hexworks / zircon

Zircon is an extensible and user-friendly, multiplatform tile engine.
https://hexworks.org/projects/zircon/
Apache License 2.0
752 stars 137 forks source link

Scrollable controls #25

Open adam-arold opened 7 years ago

nanodeath commented 3 years ago

I think there's a lot to discuss here...here's the three things I can think of:

nanodeath commented 3 years ago

Re: appearance, perhaps this?

                ┌┤Foo├─────┐
                │         ▲│
                │         ■│
                │         ░│
                │         ░│
                │         ▼│
                └──────────┘
adam-arold commented 3 years ago

We already have a ScrollBar, it is just not integrated yet. The problem right now is that Components 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 Fragments. There are already some prototypes in place. Take a look here.

Seveen commented 3 years ago

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

nanodeath commented 3 years ago

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.

adam-arold commented 3 years ago

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.

nanodeath commented 3 years ago

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?

adam-arold commented 3 years ago

Yep, do you want to do it?

nanodeath commented 3 years ago

I'll probably pick it up (#374) once a few of my other PRs get merged.

adam-arold commented 3 years ago

I'm looking at the other PRs right now.