ScrollPanel Question: Resize VerticalScrollBar, Make Panel Transparent/Invisible

What is says in the topic title.

I’m trying to implement a ScrollPanel that has the following attributes:

  1. Vertical scrolling only. So, I want to remove the horizontal scroll bar to maximize screen real estate.
  2. A narrower vertical scroll bar.
  3. Every part of the ScrollPanel is transparent except the vertical slider bar and the child Elements placed on the panel. The Elements should seem to hang in space.

[java]
float dockBHeight = 30;
float width = screen.getWidth();
float height = screen.getHeight();

ScrollPanel dockP = new ScrollPanel(screen, “dockPanel”, new Vector2f(width0.8f, height0.10f), new Vector2f(width0.20f, height0.85f));
dockP.setIsMovable(false);
dockP.setIsResizable(false);
dockP.getVerticalScrollBar().setDimensions(10, dockP.getHeight());

for (int i = 0; i < 30; i++) {
ButtonAdapter tempB = new ButtonAdapter(screen) {};
tempB.setText(String.valueOf(i));
tempB.setWidth(dockP.getWidth()-dockP.getVerticalScrollBar().getWidth());
tempB.setHeight(dockBHeight);
tempB.setPosition(0, i*dockBHeight);

dockP.addScrollableContent(tempB);			

}

screen.addElement(dockP);
[/java]

The VerticalScrollBar will not shrink to 10 pixels wide, and its height does not extend to the height of the ScrollPanel–the panel ends up being longer than the VerticalScrollBar. To make the panel background invisible, I’ve tried using dockP.setIsVisible(false) and dockP.getScrollableArea().setIsVisible(false), but those hide all child Elements as well–the latter at least keeps the VerticalScrollBar visible though.

Here’s what it currently looks like with 5 buttons (right side of screen, numbered buttons descending vertically). The ScrollPanel under the buttons is still visible, though it seems like the VerticalScrollBar should be 10 pixels wide (see how far the buttons extend toward the screen edge).

And with 30 buttons, we see that the VerticalScrollBar appears wider than 10 pixels and does not extend the whole height of the panel:

Any help is appreciated!

I can answer some of these I think.

To get vertical only scrolling you need …

[java]Element.setUseVerticalWrap(true);[/java]

To get a transparent background for the ScrollPane, use the constructor that takes the image path as the last argument, but supply null (I don’t think it likes using null with setColorMap after construction, so you can’t use that). You’ll also need to pass in a zeroed Vector4f for resize borders …

[java]
new ScrollPanel(screen, “dockPanel”, new Vector2f(width0.8f, height0.10f), new Vector2f(width0.20f, height0.85f), Vector4f.ZERO, null);
[/java]

To set the width of the bar, ScrollPane.setScrollSize() should do the trick.

[java]
myScroll.setScrollSize(10f);
[/java]

Hope this helps :slight_smile:

RR

@rockfire said: I can answer some of these I think.

To get vertical only scrolling you need …

[java]Element.setUseVerticalWrap(true);[/java]

To get a transparent background for the ScrollPane, use the constructor that takes the image path as the last argument, but supply null (I don’t think it likes using null with setColorMap after construction, so you can’t use that). You’ll also need to pass in a zeroed Vector4f for resize borders …

[java]
new ScrollPanel(screen, “dockPanel”, new Vector2f(width0.8f, height0.10f), new Vector2f(width0.20f, height0.85f), Vector4f.ZERO, null);
[/java]

To set the width of the bar, ScrollPane.setScrollSize() should do the trick.

[java]
myScroll.setScrollSize(10f);
[/java]

Hope this helps :slight_smile:

RR

Thanks! That all worked. And I can’t believe I completely missed that setScrollSize() method… The vertical scrollbar is still not extending for the whole length of the ScrollPanel, but that’s pretty minor right now. :slight_smile: