pub struct Workspace { /* private fields */ }Expand description
Editor-style dock host: a serializable node tree over registered items.
Implements ViewerLiveSource so a Viewer opened with
ViewerMode::Workspace renders and routes through it unchanged; the
dock layout round-trips through Workspace::to_json /
Workspace::from_json as application-owned state.
Implementations§
Source§impl Workspace
impl Workspace
Sourcepub fn new(root: WorkspaceNode) -> Self
pub fn new(root: WorkspaceNode) -> Self
Empty workspace over root; register content with Workspace::add_item.
Sourcepub fn set_layout(&mut self, json: &str) -> Result<()>
pub fn set_layout(&mut self, json: &str) -> Result<()>
Replace the dock tree with a parsed layout document (see
Workspace::from_json); registered items are preserved.
Sourcepub fn open_tab(&mut self, item: Box<dyn WorkspaceItem>) -> Result<()>
pub fn open_tab(&mut self, item: Box<dyn WorkspaceItem>) -> Result<()>
Register item and append its id to the root tab set. Returns an
error when the root is a split — multi-pane docks place tabs through
Workspace::root_mut or Workspace::set_layout.
Sourcepub fn root(&self) -> &WorkspaceNode
pub fn root(&self) -> &WorkspaceNode
Borrow the dock tree.
Sourcepub fn root_mut(&mut self) -> &mut WorkspaceNode
pub fn root_mut(&mut self) -> &mut WorkspaceNode
Mutably borrow the dock tree (e.g. to attach or detach panes).
Sourcepub fn add_item(&mut self, item: Box<dyn WorkspaceItem>)
pub fn add_item(&mut self, item: Box<dyn WorkspaceItem>)
Register pane content. Registering a second item under an existing id replaces the previous entry.
Sourcepub fn item(&self, id: &str) -> Option<&dyn WorkspaceItem>
pub fn item(&self, id: &str) -> Option<&dyn WorkspaceItem>
Look up registered content by id.
Sourcepub fn item_mut(&mut self, id: &str) -> Option<&mut (dyn WorkspaceItem + '_)>
pub fn item_mut(&mut self, id: &str) -> Option<&mut (dyn WorkspaceItem + '_)>
Mutably look up registered content by id.
Sourcepub fn item_ids(&self) -> impl Iterator<Item = &str>
pub fn item_ids(&self) -> impl Iterator<Item = &str>
Registered item ids in registration order.
Sourcepub fn to_json(&self) -> Result<String>
pub fn to_json(&self) -> Result<String>
Serialize the dock tree (no item content) to a JSON document.
Sourcepub fn from_json(json: &str) -> Result<Self>
pub fn from_json(json: &str) -> Result<Self>
Parse a document produced by Workspace::to_json. Tab ids are
preserved verbatim; items are registered separately and unresolved ids
render as disabled tabs until content arrives.
Sourcepub fn render(&mut self, ui: &mut Ui<'_>, rect: PixelRect) -> Result<()>
pub fn render(&mut self, ui: &mut Ui<'_>, rect: PixelRect) -> Result<()>
Record one frame: walk the dock tree over rect, driving split_pane
and tab_bar, then render each leaf’s selected item.
Sourcepub fn route_event(&mut self, event: &InputEvent) -> Result<()>
pub fn route_event(&mut self, event: &InputEvent) -> Result<()>
Route a UI-space input event: pointer events go to the leaf under the cursor (and move focus there on press); key and text events go to the focused leaf.
Trait Implementations§
Source§impl ViewerLiveSource for Workspace
impl ViewerLiveSource for Workspace
fn capabilities(&self) -> ViewerLiveCapabilities
Source§fn open(&mut self, _runtime: &Runtime) -> Result<()>
fn open(&mut self, _runtime: &Runtime) -> Result<()>
Runtime.Source§fn update(&mut self, delta_ms: f32) -> Result<()>
fn update(&mut self, delta_ms: f32) -> Result<()>
delta_ms is the frame time in milliseconds.Source§fn render(&mut self, ui: &mut Ui<'_>, width: u32, height: u32) -> Result<()>
fn render(&mut self, ui: &mut Ui<'_>, width: u32, height: u32) -> Result<()>
ui. Called every frame.Source§fn on_event(&mut self, event: &InputEvent) -> Result<()>
fn on_event(&mut self, event: &InputEvent) -> Result<()>
receives_events is true).Source§fn canvas_texture(&self) -> Option<&Texture>
fn canvas_texture(&self) -> Option<&Texture>
render draws only the source’s overlays when this is provided.