diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml
index c7e56dc0..7e07aa57 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/update.xml
+++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml
@@ -3277,7 +3277,11 @@
2020-11-19 00:00:00.000 CET
-
+
+
+ NEW_FEATURE
+ Added a button in the action toolbar to toggle between snap modes (none, grid, component)
+
NEW_FEATURE
Added pinch zooming functionality for compatible devices (tested on Mac and Win laptops)
diff --git a/diylc/diylc-swing/lang/Deutsch.txt b/diylc/diylc-swing/lang/Deutsch.txt
index 12f6c51e..1ef43568 100644
--- a/diylc/diylc-swing/lang/Deutsch.txt
+++ b/diylc/diylc-swing/lang/Deutsch.txt
@@ -61,6 +61,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.|Klicken Sie auf das Glühbirnen-Symbol in der unteren rechten Ecke des Fensters, um weitere Informationen zu erhalten
Click to fetch the most recent public announcement|Klicken Sie hier, um das neuste Update zu erhalten
Click to show recent changes and updates|Klicken Sie hier, um die letzten Änderungen und Aktualisierungen anzuzeigen
+Click to toggle to the next option|Klicken Sie, um zur nächsten Option zu wechseln
Coil|Spule
Coil Border|Spulenrand
Coil Length|Spulenlänge
@@ -367,7 +368,7 @@ Size|Größe
Sizing Mode|Größenmodus
Small-button B7G|Miniatur 7-pol
Smooth|Glätten
-Snap To...|Einrasten zu...
+Snap To|Einrasten zu
Soap Bar|
Solid|Ununterbrochen
South|Süden
diff --git a/diylc/diylc-swing/lang/English.txt b/diylc/diylc-swing/lang/English.txt
index dbd9291d..b2734953 100644
--- a/diylc/diylc-swing/lang/English.txt
+++ b/diylc/diylc-swing/lang/English.txt
@@ -58,6 +58,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.
Click to fetch the most recent public announcement
Click to show recent changes and updates
+Click to toggle to the next option
Coil
Coil Border
Coil Length
@@ -350,7 +351,7 @@ Size
Sizing Mode
Small-button B7G
Smooth
-Snap To...
+Snap To
Soap Bar
Solid
South
diff --git a/diylc/diylc-swing/lang/Español.txt b/diylc/diylc-swing/lang/Español.txt
index fe41150f..c12d26ff 100644
--- a/diylc/diylc-swing/lang/Español.txt
+++ b/diylc/diylc-swing/lang/Español.txt
@@ -58,6 +58,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.|Haga clic en el icono de la bombilla en la esquina inferior derecha de la ventana para obtener más información.
Click to fetch the most recent public announcement|Haga clic para obtener el anuncio público más reciente.
Click to show recent changes and updates|Haga clic para ver cambios y actualizaciones recientes
+Click to toggle to the next option|Haga clic para cambiar a la siguiente opción
Coil|Bobina
Coil Border|Borde de la bobina
Coil Length|Longitud de la bobina
@@ -356,7 +357,7 @@ Size|Tamaño
Sizing Mode|Modo de Dimensionamiento
Small-button B7G|Zócalo de Botón pequeño B7G
Smooth|Suave
-Snap To...|Ajustarse a...
+Snap To|Ajustarse a
Soap Bar|Soap Bar
Solid|Sólido
South|Sur
diff --git a/diylc/diylc-swing/lang/Français.txt b/diylc/diylc-swing/lang/Français.txt
index 5138ab21..db3d4c86 100644
--- a/diylc/diylc-swing/lang/Français.txt
+++ b/diylc/diylc-swing/lang/Français.txt
@@ -58,6 +58,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.|Cliquez sur l'icône de l'ampoule dans le coin inférieur droit de la fenêtre pour plus d'informations.
Click to fetch the most recent public announcement|Cliquez pour récupérer l'annonce publique la plus récente
Click to show recent changes and updates|Cliquez pour afficher les modifications et mises à jour récentes
+Click to toggle to the next option|Cliquez pour passer à l'option suivante
Coil|Bobine
Coil Border|Bordure de la bobine
Coil Length|Longueur de la bobine
@@ -352,7 +353,7 @@ Size|Taille
Sizing Mode|Mode de redimensionnement
Small-button B7G|Petit bouton B7G
Smooth|Lisse
-Snap To...|Aimanter à ...
+Snap To|Aimanter à
Soap Bar|Soap Bar
Solid|Solide
South|Sud
diff --git a/diylc/diylc-swing/lang/Italiano.txt b/diylc/diylc-swing/lang/Italiano.txt
index 3ef5892b..73b513e9 100644
--- a/diylc/diylc-swing/lang/Italiano.txt
+++ b/diylc/diylc-swing/lang/Italiano.txt
@@ -61,6 +61,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.|Clicca sull'icona della lampadina nell'angolo in basso a destra della finestra per ulteriori informazioni.
Click to fetch the most recent public announcement|Clicca per recuperare l'annuncio pubblico più recente
Click to show recent changes and updates|Clicca per mostrare le modifiche e gli aggiornamenti recenti
+Click to toggle to the next option|Clicca per passare all'opzione successiva
Coil|Bobina
Coil Border|Bordo della Bobina
Coil Length|Lunghezza della Bobina
@@ -367,7 +368,7 @@ Size|dimensione
Sizing Mode|Modalità di dimensionamento
Small-button B7G|Pulsante piccolo B7G
Smooth|Smussato
-Snap To...|Aggancia a ...
+Snap To|Aggancia a
Soap Bar|Soap Bar
Solid|solido
South|Sud
diff --git a/diylc/diylc-swing/lang/Nederlands.txt b/diylc/diylc-swing/lang/Nederlands.txt
index a33fa40f..53bfa341 100644
--- a/diylc/diylc-swing/lang/Nederlands.txt
+++ b/diylc/diylc-swing/lang/Nederlands.txt
@@ -60,7 +60,8 @@ Click on the canvas to create a new %s or press %s to cancel|Klik op het werkbla
Click on the canvas to set the %s control point of a new %s or press %s to cancel|Klik op het werkblad om het %s-controlepunt van een nieuwe %s in te stellen of druk op %s om te annuleren
Click the lightbulb icon in the bottom-right corner of the window for more info.|Klik op het gloeilampicoon in de rechteronderhoek van het venster voor meer informatie.
Click to fetch the most recent public announcement|Klik om de meest recente openbare aankondiging op te halen
-Click to show recent changes and updates|Klik om recente wijzigingen en updates weer te geven
+Click to show recent changes and updates|Klik om recente wijzigingen en updates weer te geven
+Click to toggle to the next option|Klik om naar de volgende optie te gaan
Coil|Spoel
Coil Border|Spoelrand
Coil Length|Spoellengte
@@ -367,7 +368,7 @@ Size|Maat
Sizing Mode|Dimensioneringsmethode
Small-button B7G|B7G met Kleine Knop
Smooth|Egaliseren
-Snap To...|Uitlijnen op...
+Snap To|Uitlijnen op
Soap Bar|Soap Bar
Solid|Ononderbroken
South|Zuid
diff --git a/diylc/diylc-swing/lang/Srpski.txt b/diylc/diylc-swing/lang/Srpski.txt
index 6cc7a694..0d27d66c 100644
--- a/diylc/diylc-swing/lang/Srpski.txt
+++ b/diylc/diylc-swing/lang/Srpski.txt
@@ -58,6 +58,7 @@ Click on the canvas to set the %s control point of a new %s or press %s to cance
Click the lightbulb icon in the bottom-right corner of the window for more info.|Klikni na ikonicu sa sijalicom u donjem-desnom uglu prozora za više informacija.
Click to fetch the most recent public announcement|Klikni za preuzimanje najnovijih objava
Click to show recent changes and updates|Klikni za prikaz skorih unapređenja
+Click to toggle to the next option|Klikni za prelaz za narednu opciju
Coil|Kalem
Coil Border|Ivica Kalema
Coil Length|Dužina Kalema
@@ -348,7 +349,7 @@ Size|Veličina
Sizing Mode|Zadavanje Veličine
Small-button B7G
Smooth|Glatko
-Snap To...|Zalepi Uz...
+Snap To|Zalepi Uz
Soap Bar
Solid|Puna Linija
South|Jug
diff --git a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
index e41c1d91..738df72b 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
@@ -1705,7 +1705,7 @@ public class ActionFactory {
}
}
- public static class ToggleAction extends AbstractAction {
+ public static class ToggleAction extends AbstractAction implements IConfigListener {
private static final long serialVersionUID = 1L;
@@ -1720,6 +1720,8 @@ public class ActionFactory {
.readString(configKey, defaultValue).equalsIgnoreCase(title));
if (icon != null)
putValue(AbstractAction.SMALL_ICON, icon);
+ // keep track of config changes and update the state accordingly
+ ConfigurationManager.getInstance().addConfigListener(configKey, this);
}
@Override
@@ -1727,6 +1729,11 @@ public class ActionFactory {
LOG.info(getValue(AbstractAction.NAME) + " toggle triggered");
ConfigurationManager.getInstance().writeValue(configKey, getValue(AbstractAction.NAME));
}
+
+ @Override
+ public void valueChanged(String key, Object value) {
+ putValue(AbstractAction.SELECTED_KEY, getValue(AbstractAction.NAME).toString().equalsIgnoreCase(value.toString()));
+ }
}
public static class ThemeAction extends AbstractAction {
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ActionBarPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ActionBarPlugin.java
index 7ac1d3a2..4adf4cc7 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ActionBarPlugin.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ActionBarPlugin.java
@@ -26,7 +26,9 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
@@ -42,11 +44,10 @@ import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
-import org.diylc.swing.images.IconLoader;
import org.diylc.lang.LangUtil;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
-import org.diylc.swing.plugins.canvas.CanvasPlugin;
+import org.diylc.swing.images.IconLoader;
import org.diylc.swing.plugins.help.HelpMenuPlugin;
/**
@@ -152,6 +153,13 @@ public class ActionBarPlugin implements IPlugIn {
public ConfigToolbar getConfigToolbar() {
if (configToolbar == null) {
configToolbar = new ConfigToolbar();
+
+ List toggleItems = new ArrayList();
+ toggleItems.add(new ToggleItem(IPlugInPort.SNAP_TO_NONE, IPlugInPort.SNAP_TO_NONE, IconLoader.SnapToNone.getIcon()));
+ toggleItems.add(new ToggleItem(IPlugInPort.SNAP_TO_GRID, IPlugInPort.SNAP_TO_GRID, IconLoader.SnapToGrid.getIcon()));
+ toggleItems.add(new ToggleItem(IPlugInPort.SNAP_TO_COMPONENTS, IPlugInPort.SNAP_TO_COMPONENTS, IconLoader.SnapToComponents.getIcon()));
+ configToolbar.addToggleLabel(LangUtil.translate("Snap To"), IPlugInPort.SNAP_TO_KEY, IPlugInPort.SNAP_TO_DEFAULT, toggleItems);
+
configToolbar.add(LangUtil.translate("Continuous Creation"), IPlugInPort.CONTINUOUS_CREATION_KEY, IconLoader.Elements.getIcon(), false);
configToolbar.add(LangUtil.translate("Highlight Connected Areas"), IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, IconLoader.LaserPointer.getIcon(), false);
configToolbar.add(LangUtil.translate("Sticky Points"), IPlugInPort.STICKY_POINTS_KEY, IconLoader.GraphNodes.getIcon(), true);
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ConfigToolbar.java b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ConfigToolbar.java
index 454d2477..fbf39e74 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ConfigToolbar.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ConfigToolbar.java
@@ -25,6 +25,7 @@ import java.awt.Component;
import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@@ -75,6 +76,11 @@ public class ConfigToolbar extends JPanel {
});
}
+ public void addToggleLabel(String text, String configKey, String defaultValue, List items) {
+ ToggleConfigLabel label = new ToggleConfigLabel(text, configKey, defaultValue, items);
+ add(label);
+ }
+
@Override
public void setEnabled(boolean enabled) {
for (Component c : getComponents())
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleConfigLabel.java b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleConfigLabel.java
new file mode 100644
index 00000000..350b720a
--- /dev/null
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleConfigLabel.java
@@ -0,0 +1,85 @@
+/*
+
+ DIY Layout Creator (DIYLC).
+ Copyright (c) 2009-2018 held jointly by the individual authors.
+
+ This file is part of DIYLC.
+
+ DIYLC is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ 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 Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DIYLC. If not, see .
+
+*/
+package org.diylc.swing.gui.actionbar;
+
+import java.awt.Cursor;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+
+import org.diylc.appframework.miscutils.ConfigurationManager;
+import org.diylc.appframework.miscutils.IConfigListener;
+import org.diylc.lang.LangUtil;
+
+public class ToggleConfigLabel extends JLabel implements IConfigListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private List items;
+ private String configItem;
+ private String title;
+
+ private int itemIndex = 0;
+
+ public ToggleConfigLabel(String title, String configKey, String defaultValue, List items) {
+ super();
+ this.title = title;
+ this.configItem = configKey;
+ this.items = items;
+ setHorizontalTextPosition(SwingConstants.LEFT);
+ setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+
+ valueChanged(configKey, ConfigurationManager.getInstance().readString(configKey, defaultValue));
+ ConfigurationManager.getInstance().addConfigListener(configKey, this);
+
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ itemIndex++;
+ if (itemIndex >= items.size())
+ itemIndex = 0;
+ ConfigurationManager.getInstance().writeValue(configKey, items.get(itemIndex).getConfigValue());
+ }
+ });
+ }
+
+ @Override
+ public void valueChanged(String key, Object value) {
+ if (!this.configItem.equalsIgnoreCase(key) || value == null)
+ return;
+
+ this.itemIndex = 0;
+ for (int i = 0; i < items.size(); i++) {
+ ToggleItem item = items.get(i);
+ if (item.getConfigValue().equalsIgnoreCase(value.toString()))
+ {
+ this.itemIndex = i;
+ setIcon(item.getIcon());
+ setToolTipText(title + " " + item.getConfigValue() + ". " + LangUtil.translate("Click to toggle to the next option"));
+ break;
+ }
+ }
+ }
+}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleItem.java b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleItem.java
new file mode 100644
index 00000000..313c1658
--- /dev/null
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/actionbar/ToggleItem.java
@@ -0,0 +1,28 @@
+package org.diylc.swing.gui.actionbar;
+
+import javax.swing.Icon;
+
+public class ToggleItem {
+ private String name;
+ private String configValue;
+ private Icon icon;
+
+ public ToggleItem(String name, String configValue, Icon icon) {
+ super();
+ this.name = name;
+ this.configValue = configValue;
+ this.icon = icon;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getConfigValue() {
+ return configValue;
+ }
+
+ public Icon getIcon() {
+ return icon;
+ }
+}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/images/IconLoader.java b/diylc/diylc-swing/src/org/diylc/swing/images/IconLoader.java
index 8f53fba3..8d320b3e 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/images/IconLoader.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/images/IconLoader.java
@@ -66,7 +66,8 @@ public enum IconLoader {
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png"), Lock("lock.png"),
- Unlock("lock_open.png"), Earth("earth.png"), Loadline("loadline.png"), LoadlineAdd("loadline_add.png");
+ Unlock("lock_open.png"), Earth("earth.png"), Loadline("loadline.png"), LoadlineAdd("loadline_add.png"), SnapToGrid("snap_to_grid.png"),
+ SnapToComponents("snap_to_components.png"), SnapToNone("snap_to_none.png");
protected String name;
diff --git a/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_components.png b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_components.png
new file mode 100644
index 00000000..6d274f3b
Binary files /dev/null and b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_components.png differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_grid.png b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_grid.png
new file mode 100644
index 00000000..93a9df14
Binary files /dev/null and b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_grid.png differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_none.png b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_none.png
new file mode 100644
index 00000000..de6c7a82
Binary files /dev/null and b/diylc/diylc-swing/src/org/diylc/swing/images/snap_to_none.png differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java
index 7b1845ae..988cf771 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java
@@ -36,7 +36,6 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
import java.awt.image.VolatileImage;
-import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java
index 6e20c7e4..a51d6cb2 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java
@@ -56,7 +56,7 @@ public class ConfigPlugin implements IPlugIn {
private static final String CONFIG_MENU = "Config";
private static final String THEME_MENU = "Theme";
private static final String RULER_MENU = "Ruler Inch Subdivision...";
- private static final String SNAP_MENU = "Snap To...";
+ private static final String SNAP_MENU = "Snap To";
private static final String COMPONENT_BROWSER_MENU = "Toolbox";
public static final String COMPONENT_BROWSER = "componentBrowser";
public static final String SEARCHABLE_TREE = "Searchable Tree";