@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
ScrollBar scrollBar = (ScrollBar)TerraScrollBarSkin.this.getComponent();
Orientation orientation = scrollBar.getOrientation();
// Calculate the new scroll bar value
int pixelValue;
if (orientation == Orientation.HORIZONTAL) {
pixelValue = component.getX() - scrollUpButton.getWidth() + x - dragOffset;
} else {
pixelValue = component.getY() - scrollUpButton.getHeight() + y - dragOffset;
}
int realValue = (int)(pixelValue / getValueScale());
// Bound the value
int end = scrollBar.getEnd();
int extent = scrollBar.getExtent();
realValue = Math.min(Math.max(realValue, 0), end - extent);
// Update the scroll bar
scrollBar.setValue(realValue);
}
return consumed;
}