diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/MovableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/MovableComponentFrame.java index c68bc1f1..4fec66f1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/MovableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/MovableComponentFrame.java @@ -12,6 +12,7 @@ public abstract class MovableComponentFrame extends ComponentFrame { protected Container mainContainer; private FrameConstraints prevConstraints; + protected UndecoratedFrameState moveState = UndecoratedFrameState.DEFAULT; protected boolean locationWasChanged = false; protected boolean sizeWasChanged = false; protected boolean inMoveMode = false; @@ -32,6 +33,7 @@ protected void onLock(){ public void setState(UndecoratedFrameState state){ switch (state){ case MOVING:{ + this.moveState = UndecoratedFrameState.MOVING; inMoveMode = true; this.prevConstraints = new FrameConstraints( this.processSEResize, @@ -57,6 +59,7 @@ public void setState(UndecoratedFrameState state){ break; } case DEFAULT: { + this.moveState = UndecoratedFrameState.DEFAULT; this.setContentPane(mainContainer); this.processSEResize = prevConstraints.processSEResize; this.processEResize = prevConstraints.processEResize; @@ -110,6 +113,11 @@ public void mouseExited(MouseEvent e) { } return panel; } + + public UndecoratedFrameState getMoveState() { + return moveState; + } + protected class FrameConstraints { private boolean processSEResize; private boolean processEResize; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/impl/TaskBarFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/impl/TaskBarFrame.java index 70dc7543..78c4767d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/impl/TaskBarFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/impl/TaskBarFrame.java @@ -98,20 +98,28 @@ private JPanel getTaskBarPanel(){ true ); - JButton itemGrid = componentsFactory.getIconButton("app/item-grid-disable.png",24,AppThemeColor.FRAME_ALPHA, TooltipConstants.VISIBLE_MODE); - componentsFactory.setUpToggleCallbacks(itemGrid, - () -> { - itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-enable.png", 24)); - TaskBarFrame.this.repaint(); - FramesManager.INSTANCE.enableMovementDirect("ItemsGridFrame"); - }, - () -> { - itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-disable.png", 24)); - TaskBarFrame.this.repaint(); - FramesManager.INSTANCE.disableMovement("ItemsGridFrame"); - }, - true - ); + JButton itemGrid = componentsFactory.getIconButton("app/item-grid-enable.png",24,AppThemeColor.FRAME_ALPHA, TooltipConstants.VISIBLE_MODE); + itemGrid.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + FramesManager.INSTANCE.enableOrDisableMovementDirect("ItemsGridFrame"); + } + } + }); +// componentsFactory.setUpToggleCallbacks(itemGrid, +// () -> { +// itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-enable.png", 24)); +// TaskBarFrame.this.repaint(); +// FramesManager.INSTANCE.enableMovementDirect("ItemsGridFrame"); +// }, +// () -> { +// itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-disable.png", 24)); +// TaskBarFrame.this.repaint(); +// FramesManager.INSTANCE.disableMovement("ItemsGridFrame"); +// }, +// true +// ); JButton toHideOut = componentsFactory.getIconButton("app/hideout.png",24,AppThemeColor.FRAME_ALPHA,TooltipConstants.HIDEOUT); toHideOut.addActionListener(action -> { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/location/SetUpLocationCommander.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/location/SetUpLocationCommander.java index e4a27071..ca9b574f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/location/SetUpLocationCommander.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/location/SetUpLocationCommander.java @@ -35,6 +35,16 @@ public void setUp(String frameClass, boolean showingSetUpFrame){ enableMovement(frame,showingSetUpFrame); activeFrames.add(frame); } + public void enableOrDisableMovement(String frameClass, boolean showingSetUpFrame) { + MovableComponentFrame frame = movableFrames.get(frameClass); + if(frame.getMoveState().equals(UndecoratedFrameState.DEFAULT)){ + enableMovement(frame,showingSetUpFrame); + activeFrames.add(frame); + }else { + disableMovement(frame); + activeFrames.remove(frame); + } + } public void disableAll() { activeFrames.forEach(this::disableMovement); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 58472e0a..2586a3ae 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -147,6 +147,9 @@ public void enableMovementExclude(String... frames){ public void enableMovementDirect(String frameClass){ locationCommander.setUp(frameClass,false); } + public void enableOrDisableMovementDirect(String frameClass){ + locationCommander.enableOrDisableMovement(frameClass,false); + } public void disableMovement(){ locationCommander.disableAll(); } diff --git a/app/pom.xml b/app/pom.xml index 489c3a81..ed3e5b9e 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -25,7 +25,7 @@ com.home.mercury app-shared - 1.0.0.1 + 1.0.0.4 diff --git a/pom.xml b/pom.xml index 8d700042..789fad85 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ app app-ui app-core - app-shared + app-local-updater pom