Skip to main content

PanelView

Trait PanelView 

Source
pub trait PanelView:
    'static
    + Send
    + Sync {
Show 13 methods // Required methods fn panel_name(&self, cx: &App) -> &'static str; fn panel_id(&self, cx: &App) -> PanelId; fn closable(&self, cx: &App) -> bool; fn zoomable(&self, cx: &App) -> bool; fn visible(&self, cx: &App) -> bool; fn set_active(&self, active: bool, window: &mut Window, cx: &mut App); fn set_zoomed(&self, zoomed: bool, window: &mut Window, cx: &mut App); fn on_added_to( &self, group: WeakEntity<TabGroup>, window: &mut Window, cx: &mut App, ); fn on_removed(&self, window: &mut Window, cx: &mut App); fn view(&self) -> AnyView; fn focus_handle(&self, cx: &App) -> FocusHandle; fn dump(&self, cx: &App) -> PanelState; fn as_any(&self) -> &dyn Any;
}
Expand description

Object-safe counterpart of Panel, used to hold heterogeneous panel entities behind a single handle.

Required Methods§

Source

fn panel_name(&self, cx: &App) -> &'static str

Source

fn panel_id(&self, cx: &App) -> PanelId

Source

fn closable(&self, cx: &App) -> bool

Source

fn zoomable(&self, cx: &App) -> bool

Source

fn visible(&self, cx: &App) -> bool

Source

fn set_active(&self, active: bool, window: &mut Window, cx: &mut App)

Source

fn set_zoomed(&self, zoomed: bool, window: &mut Window, cx: &mut App)

Source

fn on_added_to( &self, group: WeakEntity<TabGroup>, window: &mut Window, cx: &mut App, )

Source

fn on_removed(&self, window: &mut Window, cx: &mut App)

Source

fn view(&self) -> AnyView

Source

fn focus_handle(&self, cx: &App) -> FocusHandle

Source

fn dump(&self, cx: &App) -> PanelState

Source

fn as_any(&self) -> &dyn Any

The concrete value behind this handle.

A layer above base cannot recover its own richer panel trait object from this one: Arc<dyn some_skin::PanelView> coerces to Arc<dyn PanelView>, and Rust has no coercion back — a sub-trait object cannot be recovered from a super-trait object. The registry documents the same wall one layer in.

So a layer that needs more off a panel than this trait carries defines a concrete handle type, implements this trait for it by delegation, hands base that, and recovers it here with panel.as_any().downcast_ref::<ItsOwnHandle>(). That downcast works precisely because the type it names is concrete.

The blanket implementation for Entity<T> answers with the entity, so a caller that knows the panel type can recover Entity<T> instead. Which of the two a given handle holds is not fixed: a failed downcast_ref means only that this handle was built by someone else, and every caller needs a path for that.

Trait Implementations§

Source§

impl From<&(dyn PanelView + 'static)> for AnyView

Source§

fn from(handle: &dyn PanelView) -> Self

Converts to this type from the input type.
Source§

impl<T: Panel> From<&(dyn PanelView + 'static)> for Entity<T>

Source§

fn from(value: &dyn PanelView) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for dyn PanelView

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Panel> PanelView for Entity<T>

Source§

fn panel_name(&self, cx: &App) -> &'static str

Source§

fn panel_id(&self, _: &App) -> PanelId

Source§

fn closable(&self, cx: &App) -> bool

Source§

fn zoomable(&self, cx: &App) -> bool

Source§

fn visible(&self, cx: &App) -> bool

Source§

fn set_active(&self, active: bool, window: &mut Window, cx: &mut App)

Source§

fn set_zoomed(&self, zoomed: bool, window: &mut Window, cx: &mut App)

Source§

fn on_added_to( &self, group: WeakEntity<TabGroup>, window: &mut Window, cx: &mut App, )

Source§

fn on_removed(&self, window: &mut Window, cx: &mut App)

Source§

fn view(&self) -> AnyView

Source§

fn focus_handle(&self, cx: &App) -> FocusHandle

Source§

fn dump(&self, cx: &App) -> PanelState

Source§

fn as_any(&self) -> &dyn Any

Implementors§