Fix scrolling and keep lists clear of the scrollbar
Scroll kept its position as an int, so wheel and trackpad deltas were truncated: small ones were lost in one direction and a wheel notch moved one unit. It now keeps a fractional position, scrolls 24 units a notch, sizes and places its thumb consistently, and the thumb can be dragged or the track clicked. PanelScreen's scrollWidth and scrollContentWidth keep every scrolling list clear of the bar. Sliders read a float step from its text, so 0.1 no longer shows 17 decimals, and show at most three; number boxes show at most three too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -3,6 +3,7 @@ package org.saturnclient.ui;
|
||||
import org.saturnclient.ui.components.Sidebar;
|
||||
import org.saturnclient.ui.elements.ImageTexture;
|
||||
import org.saturnclient.ui.elements.Panel;
|
||||
import org.saturnclient.ui.elements.Scroll;
|
||||
import org.saturnclient.ui.resources.Textures;
|
||||
|
||||
/**
|
||||
@@ -18,6 +19,9 @@ public abstract class PanelScreen extends SaturnScreen {
|
||||
|
||||
protected static final int PADDING = 20;
|
||||
|
||||
/** How far a scroll reaches past its content area, into the padding, for its bar */
|
||||
private static final int SCROLL_OVERHANG = 14;
|
||||
|
||||
private final int sidebarItem;
|
||||
|
||||
protected int panelX, panelY, panelWidth, panelHeight;
|
||||
@@ -61,4 +65,18 @@ public abstract class PanelScreen extends SaturnScreen {
|
||||
* Draws the panel's content.
|
||||
*/
|
||||
protected abstract void panel();
|
||||
|
||||
/**
|
||||
* The width of a scroll filling {@code width} of the content area.
|
||||
*/
|
||||
protected static int scrollWidth(int width) {
|
||||
return width + SCROLL_OVERHANG;
|
||||
}
|
||||
|
||||
/**
|
||||
* The width left for a scroll's children, clear of its scrollbar.
|
||||
*/
|
||||
protected static int scrollContentWidth(int width) {
|
||||
return scrollWidth(width) - Scroll.SCROLLBAR_SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user