mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added send to back/bring to front
This commit is contained in:
+17
@@ -304,6 +304,13 @@ public interface IPlugInPort {
|
|||||||
*/
|
*/
|
||||||
void ungroupSelectedComponents();
|
void ungroupSelectedComponents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locks or unlocks the specified layer. All components within +- 0.5 range
|
||||||
|
* will be affected by the change as well.
|
||||||
|
*
|
||||||
|
* @param layerZOrder
|
||||||
|
* @param locked
|
||||||
|
*/
|
||||||
void setLayerLocked(int layerZOrder, boolean locked);
|
void setLayerLocked(int layerZOrder, boolean locked);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,4 +318,14 @@ public interface IPlugInPort {
|
|||||||
* on the user preference.
|
* on the user preference.
|
||||||
*/
|
*/
|
||||||
Point2D calculateSelectionDimension();
|
Point2D calculateSelectionDimension();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends each of the selected components one step back.
|
||||||
|
*/
|
||||||
|
void sendSelectionToBack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Brings each of the selected components one step to front.
|
||||||
|
*/
|
||||||
|
void bringSelectionToFront();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ public enum IconLoader {
|
|||||||
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
||||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||||
"edit_component.png"), Size("size.png");
|
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 537 B |
Binary file not shown.
|
After Width: | Height: | Size: 535 B |
+49
-1
@@ -31,6 +31,7 @@ import org.diylc.core.IDIYComponent;
|
|||||||
import org.diylc.core.IView;
|
import org.diylc.core.IView;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.swing.plugins.edit.ComponentTransferable;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
import com.diyfever.gui.miscutils.ConfigurationManager;
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
@@ -709,7 +710,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
controlPoints[index] = null;
|
controlPoints[index] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < controlPoints.length - 1; i++) {
|
for (int i = 0; i < controlPoints.length - 1; i++) {
|
||||||
for (int j = i + 1; j < controlPoints.length; j++) {
|
for (int j = i + 1; j < controlPoints.length; j++) {
|
||||||
if (controlPoints[i] != null && controlPoints[j] != null
|
if (controlPoints[i] != null && controlPoints[j] != null
|
||||||
@@ -892,6 +893,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLayerLocked(int layerZOrder, boolean locked) {
|
public void setLayerLocked(int layerZOrder, boolean locked) {
|
||||||
|
LOG.info(String.format("setLayerLocked(%s, %s)", layerZOrder, locked));
|
||||||
if (locked) {
|
if (locked) {
|
||||||
currentProject.getLockedLayers().add(layerZOrder);
|
currentProject.getLockedLayers().add(layerZOrder);
|
||||||
} else {
|
} else {
|
||||||
@@ -903,6 +905,52 @@ public class Presenter implements IPlugInPort {
|
|||||||
.getLockedLayers());
|
.getLockedLayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendSelectionToBack() {
|
||||||
|
LOG.info("sendSelectionToBack()");
|
||||||
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
|
ComponentType componentType = ComponentProcessor.getInstance()
|
||||||
|
.extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
|
int index = currentProject.getComponents().indexOf(component);
|
||||||
|
if (index < 0) {
|
||||||
|
LOG.warn("Component not found in the project: " + component.getName());
|
||||||
|
} else if (index > 0) {
|
||||||
|
IDIYComponent<?> componentBefore = currentProject.getComponents().get(index - 1);
|
||||||
|
ComponentType componentBeforeType = ComponentProcessor.getInstance()
|
||||||
|
.extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) componentBefore.getClass());
|
||||||
|
if (componentType.getZOrder() == componentBeforeType.getZOrder()) {
|
||||||
|
Collections.swap(currentProject.getComponents(), index, index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bringSelectionToFront() {
|
||||||
|
LOG.info("bringSelectionToFront()");
|
||||||
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
|
ComponentType componentType = ComponentProcessor.getInstance()
|
||||||
|
.extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
|
int index = currentProject.getComponents().indexOf(component);
|
||||||
|
if (index < 0) {
|
||||||
|
LOG.warn("Component not found in the project: " + component.getName());
|
||||||
|
} else if (index < currentProject.getComponents().size() - 1) {
|
||||||
|
IDIYComponent<?> componentAfter = currentProject.getComponents().get(index + 1);
|
||||||
|
ComponentType componentAfterType = ComponentProcessor.getInstance()
|
||||||
|
.extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) componentAfter.getClass());
|
||||||
|
if (componentType.getZOrder() == componentAfterType.getZOrder()) {
|
||||||
|
Collections.swap(currentProject.getComponents(), index, index + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the selection with the specified {@link ComponentTransferable}.
|
* Updates the selection with the specified {@link ComponentTransferable}.
|
||||||
* Also, updates control point map with all components that are stuck to the
|
* Also, updates control point map with all components that are stuck to the
|
||||||
|
|||||||
+48
@@ -124,6 +124,14 @@ public class ActionFactory {
|
|||||||
public DeleteSelectionAction createDeleteSelectionAction(IPlugInPort plugInPort) {
|
public DeleteSelectionAction createDeleteSelectionAction(IPlugInPort plugInPort) {
|
||||||
return new DeleteSelectionAction(plugInPort);
|
return new DeleteSelectionAction(plugInPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendToBackAction createSendToBackAction(IPlugInPort plugInPort) {
|
||||||
|
return new SendToBackAction(plugInPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BringToFrontAction createBringToFrontAction(IPlugInPort plugInPort) {
|
||||||
|
return new BringToFrontAction(plugInPort);
|
||||||
|
}
|
||||||
|
|
||||||
// File menu actions.
|
// File menu actions.
|
||||||
|
|
||||||
@@ -733,4 +741,44 @@ public class ActionFactory {
|
|||||||
plugInPort.deleteSelectedComponents();
|
plugInPort.deleteSelectedComponents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SendToBackAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
|
||||||
|
public SendToBackAction(IPlugInPort plugInPort) {
|
||||||
|
super();
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
putValue(AbstractAction.NAME, "Send to Back");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.Back.getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info("Send to Back triggered");
|
||||||
|
plugInPort.sendSelectionToBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BringToFrontAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
|
||||||
|
public BringToFrontAction(IPlugInPort plugInPort) {
|
||||||
|
super();
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
putValue(AbstractAction.NAME, "Bring to Front");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.Front.getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info("Bring to Front triggered");
|
||||||
|
plugInPort.bringSelectionToFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -49,6 +49,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
||||||
private ActionFactory.GroupAction groupAction;
|
private ActionFactory.GroupAction groupAction;
|
||||||
private ActionFactory.UngroupAction ungroupAction;
|
private ActionFactory.UngroupAction ungroupAction;
|
||||||
|
private ActionFactory.SendToBackAction sendToBackAction;
|
||||||
|
private ActionFactory.BringToFrontAction bringToFrontAction;
|
||||||
|
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
@@ -94,6 +96,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
getDeleteSelectionAction().setEnabled(enabled);
|
getDeleteSelectionAction().setEnabled(enabled);
|
||||||
getGroupAction().setEnabled(enabled);
|
getGroupAction().setEnabled(enabled);
|
||||||
getUngroupAction().setEnabled(enabled);
|
getUngroupAction().setEnabled(enabled);
|
||||||
|
getSendToBackAction().setEnabled(enabled);
|
||||||
|
getBringToFrontAction().setEnabled(enabled);
|
||||||
|
|
||||||
getPopupMenu().show(canvasPanel, e.getX(), e.getY());
|
getPopupMenu().show(canvasPanel, e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
@@ -159,6 +163,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
popupMenu.add(getDeleteSelectionAction());
|
popupMenu.add(getDeleteSelectionAction());
|
||||||
popupMenu.add(getGroupAction());
|
popupMenu.add(getGroupAction());
|
||||||
popupMenu.add(getUngroupAction());
|
popupMenu.add(getUngroupAction());
|
||||||
|
popupMenu.add(getSendToBackAction());
|
||||||
|
popupMenu.add(getBringToFrontAction());
|
||||||
}
|
}
|
||||||
return popupMenu;
|
return popupMenu;
|
||||||
}
|
}
|
||||||
@@ -211,6 +217,20 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
}
|
}
|
||||||
return ungroupAction;
|
return ungroupAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionFactory.SendToBackAction getSendToBackAction() {
|
||||||
|
if (sendToBackAction == null) {
|
||||||
|
sendToBackAction = ActionFactory.getInstance().createSendToBackAction(plugInPort);
|
||||||
|
}
|
||||||
|
return sendToBackAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionFactory.BringToFrontAction getBringToFrontAction() {
|
||||||
|
if (bringToFrontAction == null) {
|
||||||
|
bringToFrontAction = ActionFactory.getInstance().createBringToFrontAction(plugInPort);
|
||||||
|
}
|
||||||
|
return bringToFrontAction;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||||
|
|||||||
+20
@@ -34,6 +34,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
||||||
private ActionFactory.GroupAction groupAction;
|
private ActionFactory.GroupAction groupAction;
|
||||||
private ActionFactory.UngroupAction ungroupAction;
|
private ActionFactory.UngroupAction ungroupAction;
|
||||||
|
private ActionFactory.SendToBackAction sendToBackAction;
|
||||||
|
private ActionFactory.BringToFrontAction bringToFrontAction;
|
||||||
|
|
||||||
private UndoHandler<Project> undoHandler;
|
private UndoHandler<Project> undoHandler;
|
||||||
|
|
||||||
@@ -113,6 +115,20 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
}
|
}
|
||||||
return ungroupAction;
|
return ungroupAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionFactory.SendToBackAction getSendToBackAction() {
|
||||||
|
if (sendToBackAction == null) {
|
||||||
|
sendToBackAction = ActionFactory.getInstance().createSendToBackAction(plugInPort);
|
||||||
|
}
|
||||||
|
return sendToBackAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionFactory.BringToFrontAction getBringToFrontAction() {
|
||||||
|
if (bringToFrontAction == null) {
|
||||||
|
bringToFrontAction = ActionFactory.getInstance().createBringToFrontAction(plugInPort);
|
||||||
|
}
|
||||||
|
return bringToFrontAction;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(IPlugInPort plugInPort) {
|
public void connect(IPlugInPort plugInPort) {
|
||||||
@@ -132,6 +148,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
swingUI.injectMenuAction(getDeleteSelectionAction(), EDIT_TITLE);
|
swingUI.injectMenuAction(getDeleteSelectionAction(), EDIT_TITLE);
|
||||||
swingUI.injectMenuAction(getGroupAction(), EDIT_TITLE);
|
swingUI.injectMenuAction(getGroupAction(), EDIT_TITLE);
|
||||||
swingUI.injectMenuAction(getUngroupAction(), EDIT_TITLE);
|
swingUI.injectMenuAction(getUngroupAction(), EDIT_TITLE);
|
||||||
|
swingUI.injectMenuAction(getSendToBackAction(), EDIT_TITLE);
|
||||||
|
swingUI.injectMenuAction(getBringToFrontAction(), EDIT_TITLE);
|
||||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||||
swingUI.injectMenuAction(actionFactory.createEditProjectAction(plugInPort), EDIT_TITLE);
|
swingUI.injectMenuAction(actionFactory.createEditProjectAction(plugInPort), EDIT_TITLE);
|
||||||
|
|
||||||
@@ -169,6 +187,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
getDeleteSelectionAction().setEnabled(enabled);
|
getDeleteSelectionAction().setEnabled(enabled);
|
||||||
getGroupAction().setEnabled(enabled);
|
getGroupAction().setEnabled(enabled);
|
||||||
getUngroupAction().setEnabled(enabled);
|
getUngroupAction().setEnabled(enabled);
|
||||||
|
getSendToBackAction().setEnabled(enabled);
|
||||||
|
getBringToFrontAction().setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClipboardOwner
|
// ClipboardOwner
|
||||||
|
|||||||
Reference in New Issue
Block a user