mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
switchable wheel zoom
This commit is contained in:
@@ -53,6 +53,10 @@
|
||||
<string>autoEdit</string>
|
||||
<boolean>false</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>wheelZoom</string>
|
||||
<boolean>false</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>autoCreatePads</string>
|
||||
<boolean>false</boolean>
|
||||
|
||||
Binary file not shown.
+1
@@ -42,6 +42,7 @@ public interface IPlugInPort {
|
||||
public static final String CONTINUOUS_CREATION_KEY = "continuousCreation";
|
||||
public static final String AUTO_EDIT_KEY = "autoEdit";
|
||||
public static final String ABNORMAL_EXIT_KEY = "abnormalExit";
|
||||
public static final String WHEEL_ZOOM_KEY = "wheelZoom";
|
||||
|
||||
/**
|
||||
* Returns size of the canvas that takes project dimensions into account as
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 7);
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 8);
|
||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||
|
||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
||||
|
||||
+37
-27
@@ -29,6 +29,7 @@ import org.diylc.swing.plugins.edit.ComponentTransferable;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
|
||||
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||
import com.diyfever.gui.miscutils.IConfigListener;
|
||||
import com.diyfever.gui.ruler.IRulerListener;
|
||||
import com.diyfever.gui.ruler.RulerScrollPane;
|
||||
|
||||
@@ -36,8 +37,6 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(CanvasPlugin.class);
|
||||
|
||||
private static final String WHEEL_ZOOM = "wheelZoom";
|
||||
|
||||
private RulerScrollPane scrollPane;
|
||||
private CanvasPanel canvasPanel;
|
||||
private JPopupMenu popupMenu;
|
||||
@@ -112,11 +111,20 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private RulerScrollPane getScrollPane() {
|
||||
if (scrollPane == null) {
|
||||
scrollPane = new RulerScrollPane(getCanvasPanel(), new ProjectDrawingProvider(
|
||||
plugInPort, true, false), new Size(1d, SizeUnit.cm).convertToPixels(), new Size(1d,
|
||||
SizeUnit.in).convertToPixels());
|
||||
plugInPort, true, false), new Size(1d, SizeUnit.cm).convertToPixels(),
|
||||
new Size(1d, SizeUnit.in).convertToPixels());
|
||||
boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY,
|
||||
true);
|
||||
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(WHEEL_ZOOM, false);
|
||||
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.WHEEL_ZOOM_KEY, false);
|
||||
ConfigurationManager.getInstance().addConfigListener(IPlugInPort.WHEEL_ZOOM_KEY,
|
||||
new IConfigListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
scrollPane.setWheelScrollingEnabled((Boolean) value);
|
||||
}
|
||||
});
|
||||
scrollPane.setMetric(metric);
|
||||
scrollPane.setWheelScrollingEnabled(!wheelZoom);
|
||||
scrollPane.addUnitListener(new IRulerListener() {
|
||||
@@ -126,30 +134,32 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
plugInPort.setMetric(isMetric);
|
||||
}
|
||||
});
|
||||
if (wheelZoom) {
|
||||
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
||||
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
double d = plugInPort.getZoomLevel();
|
||||
Double[] availableZoomLevels = plugInPort.getAvailableZoomLevels();
|
||||
if (e.getWheelRotation() > 0) {
|
||||
int i = availableZoomLevels.length - 1;
|
||||
while (i > 0 && availableZoomLevels[i] >= d) {
|
||||
i--;
|
||||
}
|
||||
plugInPort.setZoomLevel(availableZoomLevels[i]);
|
||||
} else {
|
||||
int i = 0;
|
||||
while (i < availableZoomLevels.length - 1
|
||||
&& availableZoomLevels[i] <= d) {
|
||||
i++;
|
||||
}
|
||||
plugInPort.setZoomLevel(availableZoomLevels[i]);
|
||||
}
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.WHEEL_ZOOM_KEY, false);
|
||||
if (!wheelZoom) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
double d = plugInPort.getZoomLevel();
|
||||
Double[] availableZoomLevels = plugInPort.getAvailableZoomLevels();
|
||||
if (e.getWheelRotation() > 0) {
|
||||
int i = availableZoomLevels.length - 1;
|
||||
while (i > 0 && availableZoomLevels[i] >= d) {
|
||||
i--;
|
||||
}
|
||||
plugInPort.setZoomLevel(availableZoomLevels[i]);
|
||||
} else {
|
||||
int i = 0;
|
||||
while (i < availableZoomLevels.length - 1 && availableZoomLevels[i] <= d) {
|
||||
i++;
|
||||
}
|
||||
plugInPort.setZoomLevel(availableZoomLevels[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
+2
@@ -54,6 +54,8 @@ public class ConfigPlugin implements IPlugIn {
|
||||
"Auto-Edit Mode", IPlugInPort.AUTO_EDIT_KEY, false), CONFIG_MENU);
|
||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||
"Continuous Creation", IPlugInPort.CONTINUOUS_CREATION_KEY, false), CONFIG_MENU);
|
||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||
"Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY, false), CONFIG_MENU);
|
||||
File themeDir = new File("themes");
|
||||
if (themeDir.exists()) {
|
||||
XStream xStream = new XStream(new DomDriver());
|
||||
|
||||
@@ -135,8 +135,7 @@
|
||||
<description>Added axial electrolytic capacitor</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||
</url>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
<com.diyfever.gui.update.Version>
|
||||
<versionNumber>
|
||||
@@ -200,8 +199,7 @@
|
||||
<description>Configurable rendering quality to improve speed</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||
</url>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
<com.diyfever.gui.update.Version>
|
||||
<versionNumber>
|
||||
@@ -209,7 +207,7 @@
|
||||
<minor>0</minor>
|
||||
<build>7</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2011-02-07 20:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2011-02-27 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<com.diyfever.gui.update.Change>
|
||||
@@ -273,8 +271,31 @@
|
||||
<description>Continuous component creation</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||
</url>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
<com.diyfever.gui.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>0</minor>
|
||||
<build>8</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2011-02-27 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description></description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description></description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Switchable wheel zoom</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
Reference in New Issue
Block a user