-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double title bars with grouped floating frames
A new `DialogFloatingContainer` implementation (`SingleTitleBarDialogFloatingContainer`) is provided which always leaves itself undecorated, but which will decorate the root pane with dialog decorations when needed. The border is also always set to a resize border rather than sometimes having it and sometimes not. A new `DockingManager` implementation (`MapToolDockingManager`) is needed just to instantiate `SingleTitleBarDialogFloatingContainer`.
- Loading branch information
1 parent
c20e5da
commit 339d417
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/net/rptools/maptool/client/ui/docking/MapToolDockingManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* This software Copyright by the RPTools.net development team, and | ||
* licensed under the Affero GPL Version 3 or, at your option, any later | ||
* version. | ||
* | ||
* MapTool Source Code 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. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License * along with this source Code. If not, please visit | ||
* <http://www.gnu.org/licenses/> and specifically the Affero license | ||
* text at <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
package net.rptools.maptool.client.ui.docking; | ||
|
||
import com.jidesoft.docking.DefaultDockingManager; | ||
import com.jidesoft.docking.DialogFloatingContainer; | ||
import java.awt.Container; | ||
import java.awt.Dialog; | ||
import java.awt.Frame; | ||
import java.awt.Window; | ||
import javax.swing.RootPaneContainer; | ||
|
||
/** | ||
* Custom docking manager that creates custom floating containers. | ||
* | ||
* <p>This is how to use {@link SingleTitleBarDialogFloatingContainer} instead of the default | ||
* implementation. | ||
*/ | ||
public class MapToolDockingManager extends DefaultDockingManager { | ||
public MapToolDockingManager(RootPaneContainer rootPaneContainer, Container container) { | ||
super(rootPaneContainer, container); | ||
} | ||
|
||
@Override | ||
protected DialogFloatingContainer createDialogFloatingContainer( | ||
InternalEventManager internalEventManager, Window window) { | ||
if (window instanceof Dialog dialog) { | ||
return new SingleTitleBarDialogFloatingContainer(this, internalEventManager, dialog); | ||
} | ||
|
||
if (window instanceof Frame frame) { | ||
return new SingleTitleBarDialogFloatingContainer(this, internalEventManager, frame); | ||
} | ||
|
||
throw new UnsupportedOperationException( | ||
"JIDE Docking Framework doesn't support floating frames if rootPaneContainer is " | ||
+ (window == null ? "null" : window.getClass().getName())); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...ain/java/net/rptools/maptool/client/ui/docking/SingleTitleBarDialogFloatingContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This software Copyright by the RPTools.net development team, and | ||
* licensed under the Affero GPL Version 3 or, at your option, any later | ||
* version. | ||
* | ||
* MapTool Source Code 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. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License * along with this source Code. If not, please visit | ||
* <http://www.gnu.org/licenses/> and specifically the Affero license | ||
* text at <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
package net.rptools.maptool.client.ui.docking; | ||
|
||
import com.jidesoft.docking.DialogFloatingContainer; | ||
import com.jidesoft.docking.DockingManager; | ||
import com.jidesoft.docking.DockingUtils; | ||
import com.jidesoft.plaf.UIDefaultsLookup; | ||
import java.awt.Dialog; | ||
import java.awt.Frame; | ||
import java.awt.HeadlessException; | ||
import javax.swing.JRootPane; | ||
|
||
/** | ||
* Container implementation that only decorates the root pane and not the dialog itself. | ||
* | ||
* <p>The default implementation ({@link com.jidesoft.docking.DialogFloatingContainer}) always | ||
* decorates both the dialog and the root pane when decorations are requested, resulting in | ||
* redundant title bars for docked floating frames. | ||
*/ | ||
public class SingleTitleBarDialogFloatingContainer extends DialogFloatingContainer { | ||
public SingleTitleBarDialogFloatingContainer( | ||
DockingManager dockingManager, FloatingContainerManager floatingContainerManager, Frame frame) | ||
throws HeadlessException { | ||
super(dockingManager, floatingContainerManager, frame); | ||
} | ||
|
||
public SingleTitleBarDialogFloatingContainer( | ||
DockingManager dockingManager, | ||
FloatingContainerManager floatingContainerManager, | ||
Dialog dialog) | ||
throws HeadlessException { | ||
super(dockingManager, floatingContainerManager, dialog); | ||
} | ||
|
||
@Override | ||
public void updateUndecorated() { | ||
this.setVisible(false); // So we can change the decorations. | ||
|
||
this.setUndecorated(true); | ||
|
||
final var dockingManager = this.getDockingManager(); | ||
final var contentPane = this.getContentPane(); | ||
if (DockingUtils.shouldUseDecoratedFloatingContainer(dockingManager, contentPane)) { | ||
this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); | ||
} else { | ||
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE); | ||
} | ||
this.setBorder(UIDefaultsLookup.getBorder("Resizable.resizeBorder")); | ||
|
||
this.updateBorders(); | ||
|
||
if (!this.getDockingManager().getMainContainer().isShowing()) { | ||
return; | ||
} | ||
|
||
this.setVisible(true); | ||
} | ||
} |