mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Exposed the most commonly used configuration items in the top-right
toolbar for faster access
This commit is contained in:
@@ -2846,6 +2846,10 @@
|
|||||||
<releaseDate>2020-04-03 00:00:00.000 CET</releaseDate>
|
<releaseDate>2020-04-03 00:00:00.000 CET</releaseDate>
|
||||||
<name></name>
|
<name></name>
|
||||||
<changes>
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Exposed the most commonly used configuration items in the top-right toolbar for faster access</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added "Ruler Inch Subdivision" config option that allows inch rulers to be subdivided either using base of 2 (1/4", 1/8, 1/16) or base of 10 (1/10)</description>
|
<description>Added "Ruler Inch Subdivision" config option that allows inch rulers to be subdivided either using base of 2 (1/4", 1/8, 1/16) or base of 10 (1/10)</description>
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ public enum IconLoader {
|
|||||||
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
|
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
|
||||||
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png"),
|
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png"),
|
||||||
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
|
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");
|
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
|
||||||
|
Elements("elements1.png"), GraphNodes("graph_nodes.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 616 B |
Binary file not shown.
|
After Width: | Height: | Size: 516 B |
@@ -46,6 +46,7 @@ import javax.swing.KeyStroke;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.appframework.miscutils.IConfigListener;
|
||||||
import org.diylc.common.BuildingBlockPackage;
|
import org.diylc.common.BuildingBlockPackage;
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.IComponentTransformer;
|
import org.diylc.common.IComponentTransformer;
|
||||||
@@ -1562,6 +1563,13 @@ public class ActionFactory {
|
|||||||
putValue(AbstractAction.NAME, title);
|
putValue(AbstractAction.NAME, title);
|
||||||
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readBoolean(configKey, defaultValue));
|
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readBoolean(configKey, defaultValue));
|
||||||
|
ConfigurationManager.getInstance().addConfigListener(configKey, new IConfigListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(String key, Object value) {
|
||||||
|
putValue(AbstractAction.SELECTED_KEY, (Boolean)value);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue) {
|
public ConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue) {
|
||||||
|
|||||||
@@ -17,16 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.diylc.swing.gui.actionbar;
|
package org.diylc.swing.gui.actionbar;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
import org.diylc.common.IComponentTransformer;
|
import org.diylc.common.IComponentTransformer;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.swing.ActionFactory;
|
import org.diylc.swing.ActionFactory;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
|
|
||||||
@@ -41,7 +45,8 @@ public class ActionBarPlugin implements IPlugIn {
|
|||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
|
|
||||||
private JPanel actionPanel;
|
private JPanel actionPanel;
|
||||||
private MiniToolbar miniToolbar;
|
private ActionToolbar contextActionToolbar;
|
||||||
|
private ConfigToolbar configToolbar;
|
||||||
|
|
||||||
public ActionBarPlugin(ISwingUI swingUI) {
|
public ActionBarPlugin(ISwingUI swingUI) {
|
||||||
this.swingUI = swingUI;
|
this.swingUI = swingUI;
|
||||||
@@ -51,31 +56,67 @@ public class ActionBarPlugin implements IPlugIn {
|
|||||||
if (actionPanel == null) {
|
if (actionPanel == null) {
|
||||||
actionPanel = new JPanel();
|
actionPanel = new JPanel();
|
||||||
actionPanel.setOpaque(false);
|
actionPanel.setOpaque(false);
|
||||||
actionPanel.setLayout(new BorderLayout());
|
actionPanel.setLayout(new GridBagLayout());
|
||||||
actionPanel.add(getMiniToolbar(), BorderLayout.EAST);
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
|
||||||
|
actionPanel.add(new JPanel(), gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.weightx = 0;
|
||||||
|
actionPanel.add(getConfigToolbar(), gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 2;
|
||||||
|
// add some space to separate the two toolbars
|
||||||
|
actionPanel.add(new JLabel() {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return new Dimension(16, 16);
|
||||||
|
}
|
||||||
|
}, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 3;
|
||||||
|
actionPanel.add(getContextActionToolbar(), gbc);
|
||||||
|
|
||||||
actionPanel.setBorder(BorderFactory.createEmptyBorder());
|
actionPanel.setBorder(BorderFactory.createEmptyBorder());
|
||||||
}
|
}
|
||||||
return actionPanel;
|
return actionPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiniToolbar getMiniToolbar() {
|
public ConfigToolbar getConfigToolbar() {
|
||||||
if (miniToolbar == null) {
|
if (configToolbar == null) {
|
||||||
miniToolbar = new MiniToolbar();
|
configToolbar = new ConfigToolbar();
|
||||||
miniToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, 1));
|
configToolbar.add("Continuous Creation", IPlugInPort.CONTINUOUS_CREATION_KEY, IconLoader.Elements.getIcon(), false);
|
||||||
miniToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, -1));
|
configToolbar.add("Highlight Connected Areas", IPlugInPort.HIGHLIGHT_CONTINUITY_AREA, IconLoader.LaserPointer.getIcon(), false);
|
||||||
miniToolbar.addSpacer();
|
configToolbar.add("Sticky Points", IPlugInPort.STICKY_POINTS_KEY, IconLoader.GraphNodes.getIcon(), true);
|
||||||
miniToolbar.add(ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL));
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL));
|
|
||||||
miniToolbar.addSpacer();
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createNudgeAction(plugInPort));
|
|
||||||
miniToolbar.addSpacer();
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createSendToBackAction(plugInPort));
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createBringToFrontAction(plugInPort));
|
|
||||||
miniToolbar.addSpacer();
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createGroupAction(plugInPort));
|
|
||||||
miniToolbar.add(ActionFactory.getInstance().createUngroupAction(plugInPort));
|
|
||||||
}
|
}
|
||||||
return miniToolbar;
|
return configToolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionToolbar getContextActionToolbar() {
|
||||||
|
if (contextActionToolbar == null) {
|
||||||
|
contextActionToolbar = new ActionToolbar();
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, 1));
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, -1));
|
||||||
|
contextActionToolbar.addSpacer();
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL));
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL));
|
||||||
|
contextActionToolbar.addSpacer();
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createNudgeAction(plugInPort));
|
||||||
|
contextActionToolbar.addSpacer();
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createSendToBackAction(plugInPort));
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createBringToFrontAction(plugInPort));
|
||||||
|
contextActionToolbar.addSpacer();
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createGroupAction(plugInPort));
|
||||||
|
contextActionToolbar.add(ActionFactory.getInstance().createUngroupAction(plugInPort));
|
||||||
|
}
|
||||||
|
return contextActionToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,6 +135,6 @@ public class ActionBarPlugin implements IPlugIn {
|
|||||||
if (eventType != EventType.SELECTION_CHANGED)
|
if (eventType != EventType.SELECTION_CHANGED)
|
||||||
return;
|
return;
|
||||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||||
getMiniToolbar().setEnabled(enabled);
|
getContextActionToolbar().setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -34,11 +34,11 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
public class MiniToolbar extends JPanel {
|
public class ActionToolbar extends JPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public MiniToolbar() {
|
public ActionToolbar() {
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
setBorder(BorderFactory.createEmptyBorder());
|
setBorder(BorderFactory.createEmptyBorder());
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.diylc.swing.gui.actionbar;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.appframework.miscutils.IConfigListener;
|
||||||
|
|
||||||
|
public class ConfigToolbar extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String CHECK = "\u2611";
|
||||||
|
private final String UNCHECK = "\u2610";
|
||||||
|
|
||||||
|
public ConfigToolbar() {
|
||||||
|
setOpaque(false);
|
||||||
|
setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(String title, String configKey, Icon icon, boolean defaultValue) {
|
||||||
|
final JLabel label = new JLabel();
|
||||||
|
boolean checked = ConfigurationManager.getInstance().readBoolean(configKey, defaultValue);
|
||||||
|
label.setText(checked ? CHECK : UNCHECK);
|
||||||
|
label.setIcon(icon);
|
||||||
|
label.setToolTipText(title);
|
||||||
|
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
label.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
boolean checked = ConfigurationManager.getInstance().readBoolean(configKey, defaultValue);
|
||||||
|
checked = !checked;
|
||||||
|
ConfigurationManager.getInstance().writeValue(configKey, checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(label);
|
||||||
|
|
||||||
|
ConfigurationManager.getInstance().addConfigListener(configKey, new IConfigListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(String key, Object value) {
|
||||||
|
boolean checked = (boolean) value;
|
||||||
|
label.setText(checked ? CHECK : UNCHECK);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
for (Component c : getComponents())
|
||||||
|
c.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpacer() {
|
||||||
|
JSeparator l = new JSeparator();
|
||||||
|
add(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user