Skip to content

Commit 5db83fe

Browse files
(v2) Requires press Shift to zoom images outside editors.
1 parent f352548 commit 5db83fe

File tree

9 files changed

+78
-18
lines changed

9 files changed

+78
-18
lines changed

source/v2/phasereditor/phasereditor.animation.ui.editor/src/phasereditor/animation/ui/editor/AnimationsEditor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ public void mouseDown(MouseEvent e) {
247247
e.gc.drawText(_animCanvas.getModel().getKey(), 0, 0, true);
248248
}
249249
});
250+
_animCanvas.setZoomWhenShiftPressed(false);
251+
252+
_timelineCanvas.setZoomWhenShiftPressed(false);
250253

251254
disableToolbar();
252255

source/v2/phasereditor/phasereditor.animation.ui/src/phasereditor/animation/ui/AnimationListCanvas.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public Point viewToModel(int x, int y) {
126126
public Point modelToView(int x, int y) {
127127
return new Point(x, y + _origin.y);
128128
}
129-
129+
130130
@Override
131131
public Image get_DND_Image(int index) {
132132
IAssetFrameModel asset = findAssetFor(index);
@@ -172,7 +172,7 @@ public void paintControl(PaintEvent e) {
172172
}
173173

174174
var gc = e.gc;
175-
175+
176176
prepareGC(gc);
177177

178178
var tx = new Transform(getDisplay());
@@ -254,7 +254,7 @@ public void paintControl(PaintEvent e) {
254254

255255
y += _rowHeight;
256256
}
257-
257+
258258
tx.dispose();
259259
}
260260

@@ -299,10 +299,9 @@ public void refresh() {
299299
} else {
300300
_animations = new ArrayList<>(_model.getAnimations());
301301
}
302-
303-
302+
304303
updateScroll();
305-
304+
306305
redraw();
307306
}
308307

@@ -327,15 +326,15 @@ public void mouseScrolled(MouseEvent e) {
327326

328327
void updateScroll() {
329328
ScrollBar vBar = getVerticalBar();
330-
329+
331330
if (_animations.isEmpty()) {
332331
vBar.setMaximum(0);
333332
vBar.setSelection(0);
334333
vBar.setThumb(0);
335334
_origin.y = 0;
336335
return;
337336
}
338-
337+
339338
var b = getBounds();
340339
b.height = _rowHeight * _animations.size();
341340
Rectangle rect = b;

source/v2/phasereditor/phasereditor.animation.ui/src/phasereditor/animation/ui/AnimationTimelineCanvas.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class AnimationTimelineCanvas<T extends AnimationModel> extends BaseImage
7979
private Set<AnimationFrameModel> _selectedFrames = new LinkedHashSet<>();
8080
private AnimationFrameModel _lastSelectedFrame;
8181
private AnimationCanvas _animCanvas;
82+
private boolean _zoomWhenShiftPressed;
8283

8384
public AnimationTimelineCanvas(Composite parent, int style) {
8485
super(parent, style | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE);
@@ -104,8 +105,18 @@ public AnimationTimelineCanvas(Composite parent, int style) {
104105
init_DND_Support();
105106

106107
initMouseSupport();
108+
109+
_zoomWhenShiftPressed = true;
107110

108111
}
112+
113+
public boolean isZoomWhenShiftPressed() {
114+
return _zoomWhenShiftPressed;
115+
}
116+
117+
public void setZoomWhenShiftPressed(boolean zoomWhenShiftPressed) {
118+
_zoomWhenShiftPressed = zoomWhenShiftPressed;
119+
}
109120

110121
private void initMouseSupport() {
111122
addMouseListener(this);
@@ -553,6 +564,12 @@ AnimationFrameModel getFrameAtX(int x) {
553564

554565
@Override
555566
public void mouseScrolled(MouseEvent e) {
567+
if (isZoomWhenShiftPressed()) {
568+
if ((e.stateMask & SWT.SHIFT) == 0) {
569+
return;
570+
}
571+
}
572+
556573
if (e.count < 0) {
557574
_widthFactor -= 0.2;
558575
} else {

source/v2/phasereditor/phasereditor.assetpack.ui/src/phasereditor/assetpack/ui/preview/AtlasAssetPreviewComp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public AtlasAssetPreviewComp(Composite parent, int style) {
7171
setLayout(new StackLayout());
7272

7373
_atlasCanvas = new AtlasCanvas(this, SWT.NONE, true);
74+
_atlasCanvas.setZoomWhenShiftPressed(false);
7475
_filteredGrid = new FilteredFrameGrid(this, SWT.NONE, true);
7576
AssetPackUI.installAssetTooltips(_filteredGrid);
7677

source/v2/phasereditor/phasereditor.atlas.ui.editor/src/phasereditor/atlas/ui/editor/TexturePackerEditor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ void updateUIFromModel() {
818818

819819
private AtlasCanvas createAtlasCanvas(Composite parent) {
820820
AtlasCanvas canvas = new AtlasCanvas(parent, SWT.NONE, false);
821+
canvas.setZoomWhenShiftPressed(false);
821822
// we handle the cache
822823
canvas.setDisableCanche(true);
823824

source/v2/phasereditor/phasereditor.scene.ui/src/phasereditor/scene/ui/editor/SceneCanvas.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public SceneCanvas(Composite parent, int style) {
102102
addMouseMoveListener(this);
103103

104104
init_DND();
105+
106+
setZoomWhenShiftPressed(false);
105107
}
106108

107109
private void init_DND() {

source/v2/phasereditor/phasereditor.ui/src/phasereditor/ui/FrameGridCanvas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ private void resetFramesData() {
518518

519519
@Override
520520
public void mouseScrolled(MouseEvent e) {
521-
if (_listLayout && (e.stateMask & SWT.SHIFT) == 0) {
521+
if ((e.stateMask & SWT.SHIFT) == 0) {
522522
return;
523523
}
524524

source/v2/phasereditor/phasereditor.ui/src/phasereditor/ui/ImageCanvas.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class ImageCanvas extends BaseImageCanvas implements PaintListener, IZoom
5353
private boolean _fitWindow;
5454
private IFile _imageFile;
5555
protected Rectangle _imageRenderArea;
56+
private boolean _zoomWhenShiftPressed;
5657

5758
public static class ZoomCalculator {
5859
public float imgWidth;
@@ -137,6 +138,12 @@ public void mouseUp(MouseEvent e) {
137138

138139
@Override
139140
public void mouseScrolled(MouseEvent e) {
141+
if (isZoomWhenShiftPressed()) {
142+
if ((e.stateMask & SWT.SHIFT) == 0) {
143+
return;
144+
}
145+
}
146+
140147
float zoom = (e.count < 0 ? 0.9f : 1.1f);
141148

142149
float oldScale = getScale();
@@ -207,6 +214,16 @@ public void keyPressed(KeyEvent e) {
207214
//
208215
}
209216
});
217+
218+
_zoomWhenShiftPressed = true;
219+
}
220+
221+
public boolean isZoomWhenShiftPressed() {
222+
return _zoomWhenShiftPressed;
223+
}
224+
225+
public void setZoomWhenShiftPressed(boolean zoomWhenShiftPressed) {
226+
_zoomWhenShiftPressed = zoomWhenShiftPressed;
210227
}
211228

212229
protected void fitWindow() {
@@ -264,12 +281,12 @@ public void setNoImageMessage(String noImageMessage) {
264281
public void setImageFile(IFile file) {
265282
setImageFile(file, loadImage(file));
266283
}
267-
284+
268285
public void setImageFile(IFile file, Image image) {
269286
_imageFile = file;
270287
setImage(image);
271288
}
272-
289+
273290
public final IFile getImageFile() {
274291
return _imageFile;
275292
}
@@ -294,7 +311,7 @@ public void loadImage(String filepath) {
294311
public Image getImage() {
295312
return _image;
296313
}
297-
314+
298315
public FrameData getFrameData() {
299316
return _frameData;
300317
}
@@ -328,7 +345,7 @@ public void setImageViewport(Rectangle viewport) {
328345
public Rectangle getImageViewport() {
329346
return _viewport;
330347
}
331-
348+
332349
public Rectangle getImageRenderArea() {
333350
return _imageRenderArea;
334351
}
@@ -341,7 +358,7 @@ public final void paintControl(PaintEvent e) {
341358
}
342359

343360
prepareGC(e.gc);
344-
361+
345362
customPaintControl(e);
346363
}
347364

@@ -369,16 +386,18 @@ protected void customPaintControl(PaintEvent e) {
369386
size = _frameData.srcSize;
370387
}
371388

372-
_imageRenderArea = new Rectangle((int) (_panOffsetX + origDst.x * _scale), (int) (_panOffsetY + origDst.y * _scale),
373-
(int) (origDst.width * _scale), (int) (origDst.height * _scale));
389+
_imageRenderArea = new Rectangle((int) (_panOffsetX + origDst.x * _scale),
390+
(int) (_panOffsetY + origDst.y * _scale), (int) (origDst.width * _scale),
391+
(int) (origDst.height * _scale));
374392

375393
bgDst = new Rectangle(_panOffsetX, _panOffsetY, (int) (size.x * _scale), (int) (size.y * _scale));
376394
}
377395

378396
drawImageBackground(gc, bgDst);
379397

380-
drawImage(gc, src.x, src.y, src.width, src.height, _imageRenderArea.width, _imageRenderArea.height, _imageRenderArea.x, _imageRenderArea.y);
381-
398+
drawImage(gc, src.x, src.y, src.width, src.height, _imageRenderArea.width, _imageRenderArea.height,
399+
_imageRenderArea.x, _imageRenderArea.y);
400+
382401
gc.setAntialias(SWT.ON);
383402

384403
drawMore(gc, src.width, src.height, bgDst.width, bgDst.height, bgDst.x, bgDst.y);

source/v2/phasereditor/phasereditor.ui/src/phasereditor/ui/ZoomCanvas.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public abstract class ZoomCanvas extends BaseImageCanvas implements PaintListene
4343
private int _offsetY;
4444
private float _scale = 1;
4545
private boolean _fitWindow;
46+
private boolean _zoomWhenShiftPressed;
4647

4748
public static class ZoomCalculator {
4849
public float imgWidth;
@@ -151,6 +152,13 @@ public void mouseUp(MouseEvent e) {
151152

152153
@Override
153154
public void mouseScrolled(MouseEvent e) {
155+
156+
if (isZoomWhenShiftPressed()) {
157+
if ((e.stateMask & SWT.SHIFT) == 0) {
158+
return;
159+
}
160+
}
161+
154162
float zoom = (e.count < 0 ? 0.9f : 1.1f);
155163

156164
float oldScale = getScale();
@@ -221,8 +229,18 @@ public void keyPressed(KeyEvent e) {
221229
//
222230
}
223231
});
232+
233+
_zoomWhenShiftPressed = true;
224234

225235
}
236+
237+
public boolean isZoomWhenShiftPressed() {
238+
return _zoomWhenShiftPressed;
239+
}
240+
241+
public void setZoomWhenShiftPressed(boolean zoomWhenShiftPressed) {
242+
_zoomWhenShiftPressed = zoomWhenShiftPressed;
243+
}
226244

227245
@Override
228246
public final void paintControl(PaintEvent e) {

0 commit comments

Comments
 (0)