mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Improve scroll precision
This commit is contained in:
@@ -37,13 +37,21 @@
|
||||
<update_contact>nbenitezl_AT_gmail.com</update_contact>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="4.21.3" date="2022-02-22">
|
||||
<description>
|
||||
<ul>
|
||||
<li>[Bug Fix] Fixed the issue with the app going back to .diylc user directory for configuration storage. Only diylc directory is used going forward, please copy config.xml from .diylc to diylc if you are missing any configuration</li>
|
||||
</ul>
|
||||
</description>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.21.3</url>
|
||||
</release>
|
||||
<release version="4.21.2" date="2022-02-21">
|
||||
<description>
|
||||
<ul>
|
||||
<li>[Bug Fix] Fixed broken Linux app package</li>
|
||||
</ul>
|
||||
</description>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.21.1</url>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.21.2</url>
|
||||
</release>
|
||||
<release version="4.21.1" date="2022-02-19">
|
||||
<description>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -469,7 +469,10 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
|
||||
public void zoom(int direction) {
|
||||
Point mousePos = canvasPanel.getMousePosition(true);
|
||||
Point mousePosBefore = canvasPanel.getMousePosition(true);
|
||||
Point locationBefore = canvasPanel.getLocation();
|
||||
int relativeX = (int) (mousePosBefore.getX() + locationBefore.getX());
|
||||
int relativeY = (int) (mousePosBefore.getY() + locationBefore.getY());
|
||||
|
||||
// change zoom level
|
||||
double oldZoom = plugInPort.getZoomLevel();
|
||||
@@ -495,24 +498,25 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
JScrollBar horizontal = scrollPane.getHorizontalScrollBar();
|
||||
JScrollBar vertical = scrollPane.getVerticalScrollBar();
|
||||
|
||||
if (mousePos == null)
|
||||
mousePos = new Point((int)visibleRect.getCenterX(), (int)visibleRect.getCenterY());
|
||||
|
||||
if (selectionBounds == null) {
|
||||
// center to cursor
|
||||
Point desiredPos = new Point((int) (1d * mousePos.x / oldZoom * newZoom),
|
||||
(int) (1d * mousePos.y / oldZoom * newZoom));
|
||||
int dx = desiredPos.x - mousePos.x;
|
||||
int dy = desiredPos.y - mousePos.y;
|
||||
horizontal.setValue(horizontal.getValue() + dx);
|
||||
vertical.setValue(vertical.getValue() + dy);
|
||||
} else {
|
||||
// center to selection
|
||||
horizontal.setValue((int) (selectionBounds.getX() + selectionBounds.getWidth() / 2
|
||||
- visibleRect.getWidth() / 2));
|
||||
vertical.setValue((int) (selectionBounds.getY() + selectionBounds.getHeight() / 2
|
||||
- visibleRect.getHeight() / 2));
|
||||
if (mousePosBefore == null) {
|
||||
mousePosBefore = new Point((int)visibleRect.getCenterX(), (int)visibleRect.getCenterY());
|
||||
}
|
||||
|
||||
if (selectionBounds == null) {
|
||||
// center to cursor
|
||||
Point desiredPos = new Point((int) (1d * mousePosBefore.getX() / oldZoom * newZoom),
|
||||
(int) (1d * mousePosBefore.getY() / oldZoom * newZoom));
|
||||
int newHorizontalPos = (int) (desiredPos.getX() - relativeX);
|
||||
int newVerticalPos = (int) (desiredPos.getY() - relativeY);
|
||||
horizontal.setValue(newHorizontalPos < 0 ? 0 : newHorizontalPos);
|
||||
vertical.setValue(newVerticalPos < 0 ? 0 : newVerticalPos);
|
||||
} else {
|
||||
// center to selection
|
||||
horizontal
|
||||
.setValue((int) (selectionBounds.getX() + selectionBounds.getWidth() / 2 - visibleRect.getWidth() / 2));
|
||||
vertical.setValue(
|
||||
(int) (selectionBounds.getY() + selectionBounds.getHeight() / 2 - visibleRect.getHeight() / 2));
|
||||
}
|
||||
}
|
||||
|
||||
private void showPopupAt(int x, int y) {
|
||||
|
||||
Reference in New Issue
Block a user