mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cef1dbcaa9 |
@@ -361,35 +361,40 @@ public class CanvasPlugin implements IPlugIn{
|
|||||||
double extraSpace = plugInPort.getExtraSpace();
|
double extraSpace = plugInPort.getExtraSpace();
|
||||||
scrollPane.setZeroLocation(new Point2D.Double(extraSpace, extraSpace));
|
scrollPane.setZeroLocation(new Point2D.Double(extraSpace, extraSpace));
|
||||||
|
|
||||||
// disable built-in scrolling mechanism, we'll do it manually
|
// Enable built-in wheel scrolling to support horizontal scroll from tilt wheels on Windows/Linux
|
||||||
scrollPane.setWheelScrollingEnabled(false);
|
// The scroll pane's native handling supports horizontal scrolling from tilt wheels
|
||||||
|
scrollPane.setWheelScrollingEnabled(true);
|
||||||
|
|
||||||
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
final JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
|
|
||||||
final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
|
|
||||||
|
|
||||||
boolean wheelZoom =
|
boolean wheelZoom =
|
||||||
configManager.readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
|
configManager.readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
|
||||||
|
|
||||||
|
// Handle zoom - consume to prevent default scrolling
|
||||||
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
|
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
|
||||||
|
e.consume();
|
||||||
CanvasPlugin.this.zoom(e.getWheelRotation());
|
CanvasPlugin.this.zoom(e.getWheelRotation());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Shift+wheel (horizontal scroll), handle manually to maintain existing behavior
|
||||||
if (e.isShiftDown()) {
|
if (e.isShiftDown()) {
|
||||||
|
e.consume(); // Consume to prevent default handling
|
||||||
|
final JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
|
||||||
int iScrollAmount = e.getScrollAmount();
|
int iScrollAmount = e.getScrollAmount();
|
||||||
int iNewValue = horizontalScrollBar.getValue()
|
int iNewValue = horizontalScrollBar.getValue()
|
||||||
+ horizontalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
|
+ horizontalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
|
||||||
if (iNewValue <= horizontalScrollBar.getMaximum())
|
if (iNewValue >= horizontalScrollBar.getMinimum() && iNewValue <= horizontalScrollBar.getMaximum())
|
||||||
horizontalScrollBar.setValue(iNewValue);
|
horizontalScrollBar.setValue(iNewValue);
|
||||||
} else {
|
return;
|
||||||
int iScrollAmount = e.getScrollAmount();
|
|
||||||
int iNewValue = verticalScrollBar.getValue()
|
|
||||||
+ verticalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
|
|
||||||
if (iNewValue <= verticalScrollBar.getMaximum())
|
|
||||||
verticalScrollBar.setValue(iNewValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For regular vertical scrolling and horizontal scrolling from tilt wheels,
|
||||||
|
// let the scroll pane handle it natively. The scroll pane's built-in handling
|
||||||
|
// supports horizontal scroll events from tilt wheels on Windows/Linux.
|
||||||
|
// We don't consume the event, so the scroll pane can process it.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user