shift for horizontal scroll

fixed issue with size calculation when zoomed
This commit is contained in:
Branislav Stojkovic
2018-12-15 18:23:56 +01:00
parent ed6792800b
commit 2ee81093a0
8 changed files with 260 additions and 232 deletions
@@ -100,9 +100,11 @@ public interface ISelectionProcessor {
* Returns the minimum rectangle containing all selected components, or null if none exists. * Returns the minimum rectangle containing all selected components, or null if none exists.
* Rectangle is scaled by the current zoom level. * Rectangle is scaled by the current zoom level.
* *
* @param applyZoom
*
* @return * @return
*/ */
Rectangle2D getSelectionBounds(); Rectangle2D getSelectionBounds(boolean applyZoom);
/** /**
* Moves selection for the specified offset. * Moves selection for the specified offset.
@@ -859,7 +859,7 @@ public class Presenter implements IPlugInPort {
} }
@Override @Override
public Rectangle2D getSelectionBounds() { public Rectangle2D getSelectionBounds(boolean applyZoom) {
if (selectedComponents == null || selectedComponents.isEmpty()) if (selectedComponents == null || selectedComponents.isEmpty())
return null; return null;
@@ -871,7 +871,7 @@ public class Presenter implements IPlugInPort {
else else
LOG.info("Area is null"); LOG.info("Area is null");
} }
if (drawingManager.getZoomLevel() != 1) { if (drawingManager.getZoomLevel() != 1 && applyZoom) {
totalArea totalArea
.transform(AffineTransform.getScaleInstance(drawingManager.getZoomLevel(), drawingManager.getZoomLevel())); .transform(AffineTransform.getScaleInstance(drawingManager.getZoomLevel(), drawingManager.getZoomLevel()));
} }
@@ -1881,7 +1881,7 @@ public class Presenter implements IPlugInPort {
if (selectedComponents.isEmpty()) { if (selectedComponents.isEmpty()) {
return null; return null;
} }
Rectangle2D rect = getSelectionBounds(); Rectangle2D rect = getSelectionBounds(false);
double width = rect.getWidth(); double width = rect.getWidth();
double height = rect.getHeight(); double height = rect.getHeight();
Binary file not shown.
@@ -22,7 +22,6 @@ import java.awt.Color;
import java.awt.Composite; import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.OrientationHV; import org.diylc.common.OrientationHV;
Binary file not shown.
@@ -1,23 +1,19 @@
/* /*
*
DIY Layout Creator (DIYLC). * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
Copyright (c) 2009-2018 held jointly by the individual authors. *
* This file is part of DIYLC.
This file is part of DIYLC. *
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
DIYLC is free software: you can redistribute it and/or modify * General Public License as published by the Free Software Foundation, either version 3 of the
it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
the Free Software Foundation, either version 3 of the License, or *
(at your option) any later version. * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
DIYLC is distributed in the hope that it will be useful, * Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
GNU General Public License for more details. * <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc; package org.diylc;
@@ -43,6 +39,7 @@ import org.diylc.images.IconLoader;
import org.diylc.presenter.Presenter; import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.MainFrame; import org.diylc.swing.gui.MainFrame;
import org.diylc.swing.gui.TemplateDialog; import org.diylc.swing.gui.TemplateDialog;
import org.diylc.swingframework.FontChooserComboBox;
/** /**
* Main class that runs DIYLC. * Main class that runs DIYLC.
@@ -117,6 +114,17 @@ public class DIYLCStarter {
LOG.error("Could not set Look&Feel", e); LOG.error("Could not set Look&Feel", e);
} }
// Thread fontThread = new Thread(new Runnable() {
//
// @Override
// public void run() {
// LOG.debug("Starting font pre-loading");
// FontChooserComboBox box = new FontChooserComboBox();
// LOG.debug("Finished font pre-loading");
// }
// });
// fontThread.start();
String val = System.getProperty(SCRIPT_RUN); String val = System.getProperty(SCRIPT_RUN);
if (!"true".equals(val)) { if (!"true".equals(val)) {
int response = int response =
@@ -240,16 +240,20 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
plugInPort.setMetric(isMetric); plugInPort.setMetric(isMetric);
} }
}); });
// disable scrolling
scrollPane.setWheelScrollingEnabled(false);
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 = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false); boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) { if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
// disable scrolling
scrollPane.setWheelScrollingEnabled(false);
Point mousePos = getCanvasPanel().getMousePosition(true); Point mousePos = getCanvasPanel().getMousePosition(true);
@@ -280,9 +284,16 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
horizontal.setValue(horizontal.getValue() + dx); horizontal.setValue(horizontal.getValue() + dx);
JScrollBar vertical = scrollPane.getVerticalScrollBar(); JScrollBar vertical = scrollPane.getVerticalScrollBar();
vertical.setValue(vertical.getValue() + dy); vertical.setValue(vertical.getValue() + dy);
} if (e.isShiftDown()) {
int iScrollAmount = e.getScrollAmount();
int iNewValue = horizontalScrollBar.getValue() + horizontalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
if (iNewValue <= horizontalScrollBar.getMaximum())
horizontalScrollBar.setValue(iNewValue);
} else { } else {
// enable scrolling int iScrollAmount = e.getScrollAmount();
scrollPane.setWheelScrollingEnabled(true); int iNewValue = verticalScrollBar.getValue() + verticalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
if (iNewValue <= verticalScrollBar.getMaximum())
verticalScrollBar.setValue(iNewValue);
} }
} }
}); });
@@ -602,7 +613,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override @Override
public void run() { public void run() {
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SHOW_RULERS_KEY, true)) if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SHOW_RULERS_KEY, true))
scrollPane.setSelectionRectangle(plugInPort.getSelectionBounds()); scrollPane.setSelectionRectangle(plugInPort.getSelectionBounds(true));
} }
}); });
break; break;
+10 -2
View File
@@ -1868,16 +1868,24 @@
<org.diylc.appframework.update.Version> <org.diylc.appframework.update.Version>
<versionNumber> <versionNumber>
<major>3</major> <major>3</major>
<minor>41</minor> <minor>42</minor>
<build>2</build> <build>0</build>
</versionNumber> </versionNumber>
<releaseDate>2018-12-11 00:00:00.000 CET</releaseDate> <releaseDate>2018-12-11 00:00:00.000 CET</releaseDate>
<name></name> <name></name>
<changes> <changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Holding "shift" key switches mouse wheel scrolling from vertical to horizontal</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>"Cut Line" component sometimes disappears</description> <description>"Cut Line" component sometimes disappears</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Measurement tool shows incorrect readings when zoomed in or out</description>
</org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>