mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.24k stars 243 forks source link

create a ScrollPanel component #490

Open ginkoblongata opened 4 years ago

ginkoblongata commented 4 years ago

Having a general container which manages the horizontal and vertical ScrollBars for the supplied single contained Component will be generally useful.

I have started into this and have what I think is about 85% complete prototype in a non API breaking backwards compatible manner.

Using this approach, it's ScrollBar components will also be interactable.

mabe02 commented 4 years ago

I have purposefully not attempted this because it seems like it would be very difficult to get right when you don't know what the underlying components are. But if you got something that seems to be working, I would definitely want to check it out and include it!

ginkoblongata commented 4 years ago

In order to get it to be workable with existing code, I've added an interface ScrollableBox. I need to do some melding into things like TextBox and AbstractListBox for those to be able to be used in their existing manner and also be capable of being in a ScrollPanel.

I am hoping that the issue for the mouse events (https://github.com/mabe02/lanterna/pull/488) could be merged to 3.1 prior to proceeding onto this.

ginkoblongata commented 4 years ago

Pull request created: https://github.com/mabe02/lanterna/pull/492

It is not complete, just created in case of remarks.

ginkoblongata commented 4 years ago

Looks like will need to make some part in the events pipeline which tracks DRAG.

Something along the lines of:

UiSystem {
  mouseDown(event) {
    this.component = event.comp;
  }

  mouseDrag(event) {
    this.component.handleInput(event);
  }

  mouseUp(event) {
    this.component = null;
  }
}

The reason is that currently when dragging on the ScrollBar, only mouse drag events which are inside the rectangle are delivered to the ScrollBar InteractableComponent.

The above component would make it so that the mouse DRAGS are delivered to which component last was the target of the mouse DOWNS.

This would need to be configurable (on/off method) in order to maintain backwards compatablity by leaving this component off the pipeline.

Ended up adding this to AbstractBasePane, did not make it configurable.

mabe02 commented 4 years ago

Ok, I got a couple of comments on the PR.

anlar commented 2 years ago

Hello, I've run into the similar task with Lanterna. My application consists of fullscreen window and main panel in it, containing long list of small panels. And I need main panel to be scrollable.

As I understand from discussion there are no generic scroll panel at the moment but it is possible to implement it manually for specific case. Is there are any examples of such code exists?

tflucke commented 2 years ago

I would also like to express interest in having a feature like this.