mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added mini toolbar in the top-right corner of the screen with transform
actions exposed for quick access
This commit is contained in:
@@ -68,6 +68,8 @@ public interface ISwingUI extends IView {
|
|||||||
*/
|
*/
|
||||||
void injectMenuAction(Action action, String menuName);
|
void injectMenuAction(Action action, String menuName);
|
||||||
|
|
||||||
|
void injectMenuComponent(JComponent component);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects a custom submenu into application's main menu. If the specified menu does not exist it
|
* Injects a custom submenu into application's main menu. If the specified menu does not exist it
|
||||||
* will be automatically created.
|
* will be automatically created.
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import org.diylc.images.IconLoader;
|
|||||||
import org.diylc.presenter.Presenter;
|
import org.diylc.presenter.Presenter;
|
||||||
import org.diylc.swing.IDynamicSubmenuHandler;
|
import org.diylc.swing.IDynamicSubmenuHandler;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
|
import org.diylc.swing.gui.actionBar.ActionBarPlugin;
|
||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
|
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
|
||||||
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
||||||
@@ -126,6 +127,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
presenter.installPlugin(new LayersMenuPlugin(this));
|
presenter.installPlugin(new LayersMenuPlugin(this));
|
||||||
presenter.installPlugin(new CloudPlugIn(this));
|
presenter.installPlugin(new CloudPlugIn(this));
|
||||||
presenter.installPlugin(new HelpMenuPlugin(this));
|
presenter.installPlugin(new HelpMenuPlugin(this));
|
||||||
|
presenter.installPlugin(new ActionBarPlugin(this));
|
||||||
|
|
||||||
presenter.installPlugin(new StatusBar(this));
|
presenter.installPlugin(new StatusBar(this));
|
||||||
|
|
||||||
@@ -325,6 +327,11 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
menuMap.put(name, submenu);
|
menuMap.put(name, submenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectMenuComponent(JComponent component) {
|
||||||
|
getMainMenuBar().add(component);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectDynamicSubmenu(String name, Icon icon, String parentMenuName, final IDynamicSubmenuHandler handler) {
|
public void injectDynamicSubmenu(String name, Icon icon, String parentMenuName, final IDynamicSubmenuHandler handler) {
|
||||||
LOG.info(String.format("injectDynamicSubmenu(%s, icon, %s)", name, parentMenuName));
|
LOG.info(String.format("injectDynamicSubmenu(%s, icon, %s)", name, parentMenuName));
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.BorderLayout;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import org.diylc.common.EventType;
|
||||||
|
import org.diylc.common.IComponentTransformer;
|
||||||
|
import org.diylc.common.IPlugIn;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.swing.ActionFactory;
|
||||||
|
import org.diylc.swing.ISwingUI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mini toolbar with common actions
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
public class ActionBarPlugin implements IPlugIn {
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
private ISwingUI swingUI;
|
||||||
|
|
||||||
|
private JPanel actionPanel;
|
||||||
|
private MiniToolbar miniToolbar;
|
||||||
|
|
||||||
|
public ActionBarPlugin(ISwingUI swingUI) {
|
||||||
|
this.swingUI = swingUI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getActionPanel() {
|
||||||
|
if (actionPanel == null) {
|
||||||
|
actionPanel = new JPanel();
|
||||||
|
actionPanel.setOpaque(false);
|
||||||
|
actionPanel.setLayout(new BorderLayout());
|
||||||
|
actionPanel.add(getMiniToolbar(), BorderLayout.EAST);
|
||||||
|
actionPanel.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
}
|
||||||
|
return actionPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MiniToolbar getMiniToolbar() {
|
||||||
|
if (miniToolbar == null) {
|
||||||
|
miniToolbar = new MiniToolbar();
|
||||||
|
miniToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, 1));
|
||||||
|
miniToolbar.add(ActionFactory.getInstance().createRotateSelectionAction(plugInPort, -1));
|
||||||
|
miniToolbar.addSpacer();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connect(IPlugInPort plugInPort) {
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
swingUI.injectMenuComponent(getActionPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||||
|
return EnumSet.of(EventType.SELECTION_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processMessage(EventType eventType, Object... params) {
|
||||||
|
if (eventType != EventType.SELECTION_CHANGED)
|
||||||
|
return;
|
||||||
|
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||||
|
getMiniToolbar().setEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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.AbstractAction;
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
public class MiniToolbar extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public MiniToolbar() {
|
||||||
|
setOpaque(false);
|
||||||
|
setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(final Action action) {
|
||||||
|
final JLabel l = new JLabel();
|
||||||
|
l.setIcon((Icon) action.getValue(AbstractAction.SMALL_ICON));
|
||||||
|
l.setToolTipText((String) action.getValue(AbstractAction.NAME));
|
||||||
|
l.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
l.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
action.actionPerformed(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(l);
|
||||||
|
setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
for (Component c : getComponents())
|
||||||
|
c.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpacer() {
|
||||||
|
JSeparator l = new JSeparator();
|
||||||
|
// l.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, Color.black));
|
||||||
|
add(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2634,6 +2634,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added an optional third control point to leaded components and some schematic symbols that can be used to set component label position. This feature is off by default to keep things backwards compatible and is driven by "Movable Label" property</description>
|
<description>Added an optional third control point to leaded components and some schematic symbols that can be used to set component label position. This feature is off by default to keep things backwards compatible and is driven by "Movable Label" property</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Added mini toolbar in the top-right corner of the screen with transform actions exposed for quick 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>Auto-save plugin now works by periodically creating project backups in user\.diylc\autoSave directory and maintains file history, keeping the last X versions of the file. Maximum size for all backups combined is configurable and pre-set to 64MB</description>
|
<description>Auto-save plugin now works by periodically creating project backups in user\.diylc\autoSave directory and maintains file history, keeping the last X versions of the file. Maximum size for all backups combined is configurable and pre-set to 64MB</description>
|
||||||
@@ -2668,7 +2672,7 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Merge switch configurations that yield with the same effective wiring for "Analyze Guitar Wirings" module, for more compact report</description>
|
<description>Merge switch configurations that yield with the same effective wiring for "Analyze Guitar Wirings" module, for a more compact report</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
Reference in New Issue
Block a user