Skip to main content

FacetDeck

Struct FacetDeck 

Source
pub struct FacetDeck { /* private fields */ }
Expand description

A tabbed set of Facets — the reusable multi-component shell. Draws a tab bar + the active facet, and composes every facet’s state_json under its title, so the whole-app introspection contract is free. korp/nornir can build their window from a FacetDeck instead of hand-rolling tabs + the state dump.

Implementations§

Source§

impl FacetDeck

Source

pub fn new(facets: Vec<Box<dyn Facet>>) -> Self

Source

pub fn push(&mut self, facet: Box<dyn Facet>)

Append a facet (the incremental form of new). Lets a host build a deck pane-by-pane as it discovers what to show (e.g. one pane per warehouse table it finds).

Source

pub fn active(&self) -> usize

Source

pub fn active_title(&self) -> Option<&str>

The title of the currently-active facet (the deck’s state_json["active"]), or None if the deck is empty.

Source

pub fn titles(&self) -> Vec<&str>

The titles of every tabbed facet, in tab order — the discoverable surface a host (or a robot-UI control channel) enumerates to know which tabs exist.

Source

pub fn set_active_by_title(&mut self, title: &str) -> bool

Make the facet titled title the active tab — the programmatic (headless, robot-addressable) equivalent of clicking its tab header. Returns true if a facet with that title exists (and is now active), false otherwise. This is the named boundary a control channel switches tabs through (the deck analogue of the viz’s Tab::from_name), so a driver needn’t replay a pointer click.

Source

pub fn facet_mut<T: Any>(&mut self, title: &str) -> Option<&mut T>

Typed mutable access to the facet with title, downcast to TNone if no such facet, or it doesn’t opt into Facet::as_any_mut, or the type mismatches. Lets a host drive a concrete component’s own API (e.g. a robot-UI control forwarding a node selection to a SystemChart).

Source

pub fn replace_facet(&mut self, title: &str, facet: Box<dyn Facet>) -> bool

Replace the facet whose title matches with facet (the box’s own title is what the deck enumerates afterwards). Returns true if a facet was replaced. Used by hosts that reload a tab’s data in place — e.g. the OSM region picker rebuilds the OSM 2D / OSM 3D views from a freshly clipped region and swaps them in, keeping the same tab slots (and the active selection).

Source

pub fn with_fx(self, fx: DeckFx) -> Self

Enable deck effects up front (builder form of fx_mut).

Source

pub fn fx(&self) -> &DeckFx

The current deck-effects config (read-only).

Source

pub fn fx_mut(&mut self) -> &mut DeckFx

Mutate the deck-effects config (toggle glow, pin a palette, …).

Source

pub fn set_palette(&mut self, i: usize)

Override the deck theme with palette index i (wraps); enables the override. Convenience over fx_mut().set_palette(i).

Source

pub fn cycle_palette(&mut self) -> usize

Advance to the next palette in Theme::ALL (wrapping); returns the new index. Convenience over fx_mut().cycle_palette().

Source

pub fn send_raven(&mut self, target: Rect)

Summon the raven to perch on target — any rect a facet/host hands us (a table row, a node, a header). Replaces any raven already in flight. The body is tinted from the deck’s current palette (or the host theme). Logs an activity trail entry. Drive/paint happens automatically inside ui.

Source

pub fn has_raven(&self) -> bool

True while a raven is present (flying or perched).

Source

pub fn raven_perched(&self) -> bool

True once the summoned raven has landed (false if none).

Source

pub fn clear_raven(&mut self)

Dismiss any raven.

Source

pub fn palette_picker(&mut self, ui: &mut Ui) -> Option<usize>

Draw a one-line palette picker — a switcher over Theme::ALL the host can place anywhere (toolbar, menu). Selecting a palette pins the fx override; ui() then applies it each frame. Returns the chosen index if it changed this frame.

The override stays off until the user actually clicks a palette: merely drawing the picker must not pin index 0, otherwise a host that drives its own theme (e.g. the rich crate::look::Theme) would be silently clobbered every frame by the legacy set_theme in ui — size still changing (spacing) but colour frozen on Theme::ALL[0]. So we only pin when the selection genuinely changed this frame.

Source

pub fn active_caps(&self) -> FacetCaps

The capabilities of the currently-active facet (or NONE if empty).

Source

pub fn len(&self) -> usize

Number of facets in the deck.

Source

pub fn is_empty(&self) -> bool

True when the deck holds no facets.

Source

pub fn wall_ui(&mut self, ui: &mut Ui, cols: usize)

Wall layout — render every facet at once in a wrapping grid of cols columns, instead of the tabbed one-at-a-time ui. This is the “multiple components visible simultaneously” mode a dashboard host wants (e.g. several Graph3D panes side-by-side). Each cell is a titled group; the fx palette override (if set) still applies, and every rendered facet is logged to the runtrace ledger keyed deck.wall:<title> (mirrors the tab path’s deck.render:<title>), so state_json’s trace.ran proves each pane drew.

Source

pub fn ui(&mut self, ui: &mut Ui)

Draw the tab bar + capability toolbar + the active facet, and route capability-gated shortcuts (Ctrl-+/-/0 for scale; Ctrl-C/X/V for clipboard).

Source

pub fn active_kind(&self) -> &'static str

The active facet’s Facet::kind ("" if empty / opted out).

Source

pub fn copy_component_envelope(&self) -> Option<String>

Copy component — encode the active facet’s Facet::portable_state into the tagged clipboard envelope and place it on the OS clipboard. Returns the envelope text on success, or None if the active facet opts out (empty kind() or no portable_state()). This is the data half the gesture handlers + tests drive; the OS write is the caller’s via clipboard::put (done for them in copy_component).

Source

pub fn copy_component(&mut self, ctx: &Context) -> bool

Copy the active facet’s portable state to the OS clipboard (the full gesture). Returns true if something was copied.

Source

pub fn paste_component(&mut self, text: &str, now: f64) -> bool

Paste component — decode a clipboard text envelope and, only if its kind matches the active facet’s Facet::kind, hand the state to Facet::load_state. Returns true if the active facet adopted it. A kind mismatch (or a non-envelope / wrong-version text) is a no-op that raises a themed mismatch toast — the type-match guard is the whole point: a table envelope NEVER loads into a graphpan.

Source

pub fn component_toast(&self) -> Option<&str>

The current component-clone toast message (if one is live), for tests / hosts that want to surface it themselves.

Source

pub fn component_menu(&mut self, ui: &mut Ui)

Right-click context-menu entries for the cross-instance clone gesture — Copy component / Paste component — themed by the active style. A host attaches these to the facet body (or its tab) via response.context_menu(|ui| deck.component_menu(ui)). Greys out when the active facet opts out (empty kind()).

Source

pub fn state_json(&self) -> Value

The whole-app observable state: the active facet + each facet’s state_json, plus an additive sibling caps map (title → caps JSON) so the existing flat facets[title] shape is unchanged for consumers.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.