Skip to main content

ShellContext

Struct ShellContext 

Source
pub struct ShellContext<'a> {
    pub active_panel_id: Option<&'a WidgetId>,
    pub sidebar_visible: bool,
    pub layout: &'a AppShellLayout,
    /* private fields */
}
Expand description

Context passed to ShellApp::handle so the consumer can route events by panel without tracking shell state themselves.

Fields§

§active_panel_id: Option<&'a WidgetId>

Currently active sidebar panel, if any.

§sidebar_visible: bool

Whether the sidebar is visible.

§layout: &'a AppShellLayout

Layout bounds from the last render.

Implementations§

Source§

impl<'a> ShellContext<'a>

Source

pub fn shell(&self) -> Ref<'_, &'a mut AppShell>

Borrow the real, rendered AppShell read-only.

Prefer the narrow accessors above (in_sidebar, sidebar_bounds, …) for layout queries — this exists for the rest of AppShell’s API (e.g. bottom_panel_visible(), activity_selected_id()) that ShellContext doesn’t otherwise mirror.

§Panics

Panics if Self::shell_mut is borrowed at the same time (standard RefCell rules). Each borrow is meant to be short-lived — grab it, read, drop.

Source

pub fn shell_mut(&self) -> RefMut<'_, &'a mut AppShell>

Borrow the real, rendered AppShell mutably.

Call any AppShell mutator directly on the instance [crate::shell_adapter::ShellAdapter] actually renders — ctx.shell_mut().toggle_sidebar(), ctx.shell_mut().show_bottom_panel(), ctx.shell_mut().set_sidebar_width(w), etc. — to keep shell state in sync with the rendered display.

§Panics

Panics if Self::shell / Self::shell_mut is borrowed at the same time (standard RefCell rules). Each borrow is meant to be short-lived — grab it, mutate, drop.

Source

pub fn request_activity_keyboard_focus(&self)

Request that the activity bar take keyboard focus, with its cursor reset to the top item, once the current ShellApp::handle call returns.

Call this from your own handle() in response to whatever key you want to bind as the “focus the activity bar” trigger (Tab, Ctrl+W, a command-palette action, …) — quadraui does not reserve a key for this itself, so different consumers can pick different triggers. Once focused, [crate::shell_adapter::ShellAdapter] owns the navigation keys (j/k/arrows to move, Enter/Space to activate, Esc to cancel) by driving the same crate::compose::app_shell::AppShell methods the raw AppLogic pattern uses directly — see examples/common/shell_app.rs.

A no-op if called more than once per handle() call (the flag is simply set, not counted).

Source

pub fn in_sidebar(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the sidebar content area.

Source

pub fn in_main(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the main content area.

Source

pub fn in_bottom_panel(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the bottom panel.

Source

pub fn in_title_bar(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the title bar.

Source

pub fn in_status_bar(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the status bar.

Source

pub fn in_command_line(&self, x: f32, y: f32) -> bool

Check if a mouse position lands inside the command line.

Source

pub fn sidebar_bounds(&self) -> Option<Rect>

Sidebar content bounds (convenience for coordinate translation).

Source

pub fn main_bounds(&self) -> Rect

Main content bounds.

Source

pub fn bottom_panel_bounds(&self) -> Option<Rect>

Bottom panel bounds.

Source

pub fn bottom_band_bounds(&self, id: &WidgetId) -> Option<Rect>

Resolved bounds for one currently-visible BottomBand, or None if id names no registered band or the band is not visible in the last computed layout.

Reads AppShell::bottom_band_bounds rather than a field on AppShellLayout — see that struct’s doc for why bottom-band bounds live there instead of on the layout snapshot.

Source

pub fn in_bottom_band(&self, id: &WidgetId, x: f32, y: f32) -> bool

Check if a mouse position lands inside one currently-visible BottomBand.

Source

pub fn title_bar_bounds(&self) -> Option<Rect>

Title bar bounds.

Source

pub fn window_bounds(&self) -> Rect

The full window/viewport bounds this layout was computed against.

Source

pub fn window_edge(&self, x: f32, y: f32, margin: f32) -> Option<ResizeEdge>

Which edge or corner of the window (x, y) is within margin of, or None if the position isn’t near any outer border.

Mirrors Self::in_title_bar’s pattern: the app hit-tests the pointer against a stored bounds field every frame rather than the backend owning edge detection. Callers should derive margin from a portable backend unit (e.g. backend.line_height()) rather than a hardcoded pixel/cell constant — see quadraui/docs/LESSONS.md “Shared AppLogic code must not hardcode backend-native units”.

Call from a MouseDown handler (pass the result to Backend::begin_window_resize) and from a MouseMoved handler (pass PointerShape::Resize(edge) / PointerShape::Default to Backend::set_cursor).

Source

pub fn status_bar_bounds(&self) -> Option<Rect>

Status bar bounds.

Source

pub fn command_line_bounds(&self) -> Option<Rect>

Command line bounds.

Auto Trait Implementations§

§

impl<'a> !Freeze for ShellContext<'a>

§

impl<'a> !RefUnwindSafe for ShellContext<'a>

§

impl<'a> !Sync for ShellContext<'a>

§

impl<'a> !UnwindSafe for ShellContext<'a>

§

impl<'a> Send for ShellContext<'a>

§

impl<'a> Unpin for ShellContext<'a>

§

impl<'a> UnsafeUnpin for ShellContext<'a>

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<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more