-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Docking anchors #260
Comments
I've thought about this as some sort of docking "placeholder" that would basically be a dockable with no title bar. Then when something is docked to it, the "placeholder" is hidden and replaced with the new dockable. When all of these dockables are closed, the original "placeholder" panel reappears. I think that is probably doable somehow in the API that I haven't prototyped yet. What won't be possible, or something that I want to change, is how the I'm going to try working out a solution. I think this idea might help address some issues I've had with defining where certain dockables should appear by default. |
Oh the placeholder sounds like a good implementation to do this. One thing I would add is that the empty panel will be always hidden and only visible just before it being replaced with a new panel. This raises a question. Is a panel that's set as |
Also when tabbed together, the current docking implementation does not like if the target is undocked
class EditorWindow : Window() {
private val controller: EditorWindowController = EditorWindowController()
private lateinit var consolePanelDock: ConsolePanelDock
private lateinit var treePanelDock: TreePanelDock
private lateinit var placeholderPanelDock: PlaceholderPanelDock
override fun createPanel(): JPanel? {
return null
}
override fun windowInit(stage: WindowStage) {
if (stage != WindowStage.POST)
return
initDocking()
createPlaceholderPanel()
createConsolePanel()
createTreePanel()
createEditorPanel()
}
fun initDocking() {
Docking.initialize(this)
DockingUI.initialize()
val rootDockingPanel = RootDockingPanel(this)
add(rootDockingPanel)
}
fun createPlaceholderPanel() {
placeholderPanelDock = PlaceholderPanelDock()
Docking.dock(placeholderPanelDock.register(), this, DockingRegion.WEST)
}
fun createEditorPanel() {
val e1 = EditorPanelDock("e1")
val e2 = EditorPanelDock("e2")
val e3 = EditorPanelDock("e3")
Docking.dock(e1.register(), placeholderPanelDock, DockingRegion.CENTER)
Docking.dock(e2.register(), e1, DockingRegion.CENTER)
Docking.dock(e3.register(), e2, DockingRegion.CENTER)
placeholderPanelDock.requestClose()
Docking.undock(placeholderPanelDock)
}
fun createConsolePanel() {
consolePanelDock = ConsolePanelDock()
Docking.dock(consolePanelDock.register(), this, DockingRegion.SOUTH)
}
fun createTreePanel() {
treePanelDock = TreePanelDock()
Docking.dock(treePanelDock.register(), this, DockingRegion.EAST)
}
override fun pack() {}
} |
I did found that this works
|
How did you remove it? |
Here's the code I came up so far. Also posted it in the discussion we had class EditorWindowController(): WindowController() {
private val editors: MutableList<EditorPanelDock> = mutableListOf<EditorPanelDock>()
val placeholderPanelDock: PlaceholderPanelDock = PlaceholderPanelDock()
fun addEditor(id: String) {
val editor = EditorPanelDock(id)
editor.setOnCloseHandler {
removeEditor(id)
}
if (editors.isEmpty())
{
Docking.dock(editor.register(), placeholderPanelDock, DockingRegion.EAST)
Docking.undock(placeholderPanelDock)
}
else {
Docking.dock(editor.register(), editors.last(), DockingRegion.CENTER)
}
editors.add(editor)
}
fun removeEditor(id: String) {
val editor = editors.lastOrNull { it.persistentID == id }
if (editor != null)
{
if (editors.size == 1)
createPlaceholderPanel(editors.last())
editors.remove(editor)
Docking.undock(editor)
}
}
fun createPlaceholderPanel(target: java.awt.Window) {
Docking.dock(placeholderPanelDock.register(), target, DockingRegion.WEST)
}
fun createPlaceholderPanel(target: Dockable) {
Docking.dock(placeholderPanelDock.register(), target, DockingRegion.WEST)
}
} The issue comes when re-adding the placeholder and closing the last window again
Screencast.From.2025-01-11.14-37-25.webm |
Also instead of having empty panels, or anchors as I said. Wouldn't be better to let the user create those panels and just have a new api |
I'm honestly not sure, but a dockable will always be visible because ModernDocking uses another JPanel internally to wrap the panel from the application. |
That makes me assume the user needs to know when the placeholder is docked. |
btw, I managed to remove and recreate dockables without triggering the null pointer excteption. The idea is to dock the source to the target that needs to be removed after in the center region.
|
This way could also help prototyping, as in creating a prototype layout of how the final layout would look like then have the ability to dinami
It kept the dockable while removing the title and probably the content, I haven't checked this. Anyway the frame
Oh that's true too. Would be like, you have a dock in one of the regions and you can use that as a reference for other docks, which would probably allow for better placement, not sure to what extend. The way I see this a good thing to have is where you have a non floating/closable panel with a main content, or empty |
I'm not sure why you're calling |
Ah ignore that. It was there since I was testing ways to close the panel. This is the actual method I ended up with |
Here's what I've experimented with so far. The anchor is a The internal panels all remember which anchor they were docked to and pick up this value when docked to other panels that remember their anchor. In the gif you can see that I initially docked public class Anchor extends JPanel implements Dockable {
public Anchor() {
setBorder(BorderFactory.createLineBorder(Color.RED));
add(new JLabel("This is an anchor"));
}
@Override
public String getPersistentID() {
return "anchor";
}
@Override
public String getTabText() {
return "";
}
} Anchor anchor = new Anchor();
Docking.registerDockingAnchor(anchor);
Docking.dock(anchor, one, DockingRegion.EAST); |
Wow. I must agree that this looks amazing at the first glance |
Would would this idea work:
Docking anchors will allow docks to be created dynamically no matter in what order they are creating. As a reference this discussion 247, even if Docking Region is set to WEST, SOUTH, EAST when creating docks in the order SOUTH, EAST, West the panels are arranged one after the other without respecting their docked region.
A dock anchor region will allow to enforce the starting region of a dock regarding of the order they are created
The text was updated successfully, but these errors were encountered: