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
impl FacetDeck
pub fn new(facets: Vec<Box<dyn Facet>>) -> Self
Sourcepub fn push(&mut self, facet: Box<dyn Facet>)
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).
pub fn active(&self) -> usize
Sourcepub fn active_title(&self) -> Option<&str>
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.
Sourcepub fn titles(&self) -> Vec<&str>
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.
Sourcepub fn set_active_by_title(&mut self, title: &str) -> bool
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.
Sourcepub fn facet_mut<T: Any>(&mut self, title: &str) -> Option<&mut T>
pub fn facet_mut<T: Any>(&mut self, title: &str) -> Option<&mut T>
Typed mutable access to the facet with title, downcast to T — None 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).
Sourcepub fn replace_facet(&mut self, title: &str, facet: Box<dyn Facet>) -> bool
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).
Sourcepub fn with_fx(self, fx: DeckFx) -> Self
pub fn with_fx(self, fx: DeckFx) -> Self
Enable deck effects up front (builder form of fx_mut).
Sourcepub fn fx_mut(&mut self) -> &mut DeckFx
pub fn fx_mut(&mut self) -> &mut DeckFx
Mutate the deck-effects config (toggle glow, pin a palette, …).
Sourcepub fn set_palette(&mut self, i: usize)
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).
Sourcepub fn cycle_palette(&mut self) -> usize
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().
Sourcepub fn send_raven(&mut self, target: Rect)
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.
Sourcepub fn raven_perched(&self) -> bool
pub fn raven_perched(&self) -> bool
True once the summoned raven has landed (false if none).
Sourcepub fn clear_raven(&mut self)
pub fn clear_raven(&mut self)
Dismiss any raven.
Sourcepub fn palette_picker(&mut self, ui: &mut Ui) -> Option<usize>
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.
Sourcepub fn active_caps(&self) -> FacetCaps
pub fn active_caps(&self) -> FacetCaps
The capabilities of the currently-active facet (or NONE if empty).
Sourcepub fn wall_ui(&mut self, ui: &mut Ui, cols: usize)
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.
Sourcepub fn ui(&mut self, ui: &mut Ui)
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).
Sourcepub fn active_kind(&self) -> &'static str
pub fn active_kind(&self) -> &'static str
The active facet’s Facet::kind ("" if empty / opted out).
Sourcepub fn copy_component_envelope(&self) -> Option<String>
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).
Sourcepub fn copy_component(&mut self, ctx: &Context) -> bool
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.
Sourcepub fn paste_component(&mut self, text: &str, now: f64) -> bool
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.
Sourcepub fn component_toast(&self) -> Option<&str>
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.
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()).
Sourcepub fn state_json(&self) -> Value
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.