Far-Beyond-Pulsar / Far-Beyond-Pulsar/WGPUI-Component
Add dock popout window customization hook for host app chrome
- Dominant language
- Rust
- Stars
- 7
- Forks
- 2
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## Problem
When a tab is dragged out of a `DockArea` (or "Move to New Window" is used), `ui::dock` creates a built-in popout window internally.
Today this path is hardcoded in `DockArea::create_popout_window` / `TabPanel::create_window_with_panel_returning_handle` and always renders a minimal detached dock shell. Host applications cannot customize that new window's type, wrapper, or chrome.
For Pulsar-Native, this means dragged-out editor tabs lose the editor window shell (custom titlebar, real editor status bar incl. multiuser badge, etc.) and appear as basic windows.
## Why this needs to be in WGPUI-Component
The detachment logic and window creation happen inside `ui::dock` itself, not in app code. There is no callback/hook to intercept "panel detached -> about to open new window" and provide custom options/wrapping.
So app-side code can style windows opened through its own window manager, but cannot influence this internal dock popout path.
## Proposed API shape
Add a global/configurable popout factory hook used by `DockArea`/`TabPanel` whenever a detached window is created.
### Option A: global function registry (preferred)
```rust
pub struct DockPopoutContext {
pub panel: Arc,
pub source_channel: DockChannel,
pub source: Option,
pub screen_pos: Point,
}
pub type DockPopoutFactory = Arc<
dyn Fn(DockPopoutContext, &mut App) -> Option + Send + Sync
>;
pub fn register_dock_popout_factory(factory: DockPopoutFactory);
```
Behavior:
- If factory is registered and returns `Some(handle)`, dock uses that window and skips default popout creation.
- If no factory, or factory returns `None`, current behavior remains as fallback.
### Option B: per-DockArea config
Allow `DockArea::new(...)` / `new_with_channel(...)` to accept an optional popout config with equivalent callback semantics.
## Required data passed to hook
The hook must receive enough data to preserve existing behavior:
- `panel: Arc` (content to place)
- source metadata (`PanelSource`, tab index) for restore-on-close semantics
- drag/screen position for initial window placement
- dock channel
## Engine-side usage (Pulsar-Native)
With this hook, Pulsar-Native would:
1. Register popout factory during app init.
2. In the callback, route to `window_manager` with an editor window profile for editor-like panels.
3. Wrap detached content in app-specific editor shell (titlebar + real status bar + multiuser status indicator).
4. Fall back to default detached dock shell for non-editor panels.
This keeps dock behavior generic while allowing app-specific window identity/chrome.
## Backward compatibility
- Default behavior unchanged if no hook is set.
- Existing apps keep current popout windows with no migration required.
## Acceptance criteria
- Host app can fully customize detached-tab window construction.
- Drag-out and "Move to New Window" paths both go through the same hook.
- Default fallback remains current `ui::dock` popout behavior.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.