Skip to main content

Workspace

Struct Workspace 

Source
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

Source

pub fn new(root: WorkspaceNode) -> Self

Empty workspace over root; register content with Workspace::add_item.

Source

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.

Source

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.

Source

pub fn root(&self) -> &WorkspaceNode

Borrow the dock tree.

Source

pub fn root_mut(&mut self) -> &mut WorkspaceNode

Mutably borrow the dock tree (e.g. to attach or detach panes).

Source

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.

Source

pub fn item(&self, id: &str) -> Option<&dyn WorkspaceItem>

Look up registered content by id.

Source

pub fn item_mut(&mut self, id: &str) -> Option<&mut (dyn WorkspaceItem + '_)>

Mutably look up registered content by id.

Source

pub fn item_ids(&self) -> impl Iterator<Item = &str>

Registered item ids in registration order.

Source

pub fn to_json(&self) -> Result<String>

Serialize the dock tree (no item content) to a JSON document.

Source

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.

Source

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.

Source

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 Default for Workspace

Source§

fn default() -> Self

One empty tabbed root — the common “add views and run” dock.

Source§

impl ViewerLiveSource for Workspace

Source§

fn capabilities(&self) -> ViewerLiveCapabilities

Source§

fn open(&mut self, _runtime: &Runtime) -> Result<()>

Called once when the Viewer obtains an Runtime.
Source§

fn update(&mut self, delta_ms: f32) -> Result<()>

Per-frame update. delta_ms is the frame time in milliseconds.
Source§

fn render(&mut self, ui: &mut Ui<'_>, width: u32, height: u32) -> Result<()>

Render domain-specific UI overlays into ui. Called every frame.
Source§

fn on_event(&mut self, event: &InputEvent) -> Result<()>

Raw platform event (only called when receives_events is true).
Source§

fn close(&mut self) -> Result<()>

Called once when the Viewer is closing.
Source§

fn canvas_texture(&self) -> Option<&Texture>

Optional camera/image surface presented by the Viewer’s shared GPU 2D canvas. The Viewer owns navigation, fit, zoom, pan and channel selection; render draws only the source’s overlays when this is provided.
Source§

fn canvas_controls_rect( &self, _width: u32, _height: u32, _scale: f32, ) -> Option<PixelRect>

Source controls that own pointer gesture starts over the canvas. Motion and release from an existing canvas drag still reach Navigation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.