mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
configurable snap to grid
This commit is contained in:
@@ -1,22 +1,42 @@
|
|||||||
<map>
|
<map>
|
||||||
|
<entry>
|
||||||
|
<string>lastPath</string>
|
||||||
|
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>stickyPoints</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>theme</string>
|
<string>theme</string>
|
||||||
<org.diylc.core.Theme>
|
<org.diylc.core.Theme>
|
||||||
<name>Blueprint</name>
|
<name>Light</name>
|
||||||
<bgColor>
|
<bgColor>
|
||||||
<red>3</red>
|
<red>255</red>
|
||||||
<green>122</green>
|
<green>255</green>
|
||||||
<blue>198</blue>
|
<blue>255</blue>
|
||||||
<alpha>255</alpha>
|
<alpha>255</alpha>
|
||||||
</bgColor>
|
</bgColor>
|
||||||
<gridColor>
|
<gridColor>
|
||||||
<red>29</red>
|
<red>240</red>
|
||||||
<green>140</green>
|
<green>240</green>
|
||||||
<blue>193</blue>
|
<blue>240</blue>
|
||||||
<alpha>255</alpha>
|
<alpha>240</alpha>
|
||||||
</gridColor>
|
</gridColor>
|
||||||
</org.diylc.core.Theme>
|
</org.diylc.core.Theme>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>antiAliasing</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>snapToGrid</string>
|
||||||
|
<boolean>false</boolean>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>hiQualityRender</string>
|
||||||
|
<boolean>false</boolean>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>showTemplatesAtStartup</string>
|
<string>showTemplatesAtStartup</string>
|
||||||
<boolean>false</boolean>
|
<boolean>false</boolean>
|
||||||
|
|||||||
+2
@@ -36,6 +36,8 @@ public interface IPlugInPort {
|
|||||||
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
||||||
public static final String EXPORT_GRID_KEY = "exportGrid";
|
public static final String EXPORT_GRID_KEY = "exportGrid";
|
||||||
public static final String STICKY_POINTS_KEY = "stickyPoints";
|
public static final String STICKY_POINTS_KEY = "stickyPoints";
|
||||||
|
public static final String METRIC_KEY = "metric";
|
||||||
|
public static final String SNAP_TO_GRID_KEY = "snapToGrid";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns size of the canvas that takes project dimensions into account as
|
* Returns size of the canvas that takes project dimensions into account as
|
||||||
|
|||||||
+9
-8
@@ -53,7 +53,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 7);
|
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 7);
|
||||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||||
public static final String METRIC_KEY = "metric";
|
|
||||||
|
|
||||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
||||||
|
|
||||||
@@ -92,8 +91,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
private Point previousDragPoint = null;
|
private Point previousDragPoint = null;
|
||||||
private Project preDragProject = null;
|
private Project preDragProject = null;
|
||||||
|
|
||||||
private boolean snapToGrid = true;
|
|
||||||
|
|
||||||
public Presenter(IView view) {
|
public Presenter(IView view) {
|
||||||
super();
|
super();
|
||||||
this.view = view;
|
this.view = view;
|
||||||
@@ -361,7 +358,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
switch (componentTypeSlot.getCreationMethod()) {
|
switch (componentTypeSlot.getCreationMethod()) {
|
||||||
case SINGLE_CLICK:
|
case SINGLE_CLICK:
|
||||||
try {
|
try {
|
||||||
if (snapToGrid) {
|
if (ConfigurationManager.getInstance().readBoolean(
|
||||||
|
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||||
}
|
}
|
||||||
IDIYComponent<?> component = instantiationManager.instantiateComponent(
|
IDIYComponent<?> component = instantiationManager.instantiateComponent(
|
||||||
@@ -385,7 +383,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
case POINT_BY_POINT:
|
case POINT_BY_POINT:
|
||||||
// First click is just to set the controlPointSlot and
|
// First click is just to set the controlPointSlot and
|
||||||
// componentSlot.
|
// componentSlot.
|
||||||
if (snapToGrid) {
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SNAP_TO_GRID_KEY,
|
||||||
|
true)) {
|
||||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||||
}
|
}
|
||||||
if (instantiationManager.getComponentSlot() == null) {
|
if (instantiationManager.getComponentSlot() == null) {
|
||||||
@@ -460,7 +459,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||||
Point scaledPoint = scalePoint(point);
|
Point scaledPoint = scalePoint(point);
|
||||||
if (instantiationManager.getComponentTypeSlot() != null) {
|
if (instantiationManager.getComponentTypeSlot() != null) {
|
||||||
if (snapToGrid) {
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||||
}
|
}
|
||||||
boolean refresh = false;
|
boolean refresh = false;
|
||||||
@@ -469,7 +468,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
refresh = instantiationManager.updatePointByPoint(scaledPoint);
|
refresh = instantiationManager.updatePointByPoint(scaledPoint);
|
||||||
break;
|
break;
|
||||||
case SINGLE_CLICK:
|
case SINGLE_CLICK:
|
||||||
refresh = instantiationManager.updateSingleClick(scaledPoint, snapToGrid,
|
refresh = instantiationManager.updateSingleClick(scaledPoint, ConfigurationManager
|
||||||
|
.getInstance().readBoolean(IPlugInPort.SNAP_TO_GRID_KEY, true),
|
||||||
currentProject.getGridSpacing());
|
currentProject.getGridSpacing());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -712,7 +712,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
controlPoints[index].translate(dx, dy);
|
controlPoints[index].translate(dx, dy);
|
||||||
if (snapToGrid) {
|
if (ConfigurationManager.getInstance().readBoolean(
|
||||||
|
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||||
CalcUtils.snapPointToGrid(controlPoints[index], currentProject
|
CalcUtils.snapPointToGrid(controlPoints[index], currentProject
|
||||||
.getGridSpacing());
|
.getGridSpacing());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -46,6 +46,8 @@ public class ConfigPlugin implements IPlugIn {
|
|||||||
"Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
"Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
"Export Grid", IPlugInPort.EXPORT_GRID_KEY, false), CONFIG_MENU);
|
"Export Grid", IPlugInPort.EXPORT_GRID_KEY, false), CONFIG_MENU);
|
||||||
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
|
"Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true), CONFIG_MENU);
|
||||||
File themeDir = new File("themes");
|
File themeDir = new File("themes");
|
||||||
if (themeDir.exists()) {
|
if (themeDir.exists()) {
|
||||||
XStream xStream = new XStream(new DomDriver());
|
XStream xStream = new XStream(new DomDriver());
|
||||||
|
|||||||
@@ -244,6 +244,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Sticky points may be turned off</description>
|
<description>Sticky points may be turned off</description>
|
||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Snap to Grid may be turned off</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||||
</url>
|
</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user