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.
Whether the sidebar is visible.
layout: &'a AppShellLayoutLayout bounds from the last render.
Implementations§
Source§impl<'a> ShellContext<'a>
impl<'a> ShellContext<'a>
Sourcepub fn shell(&self) -> Ref<'_, &'a mut AppShell>
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.
Sourcepub fn shell_mut(&self) -> RefMut<'_, &'a mut AppShell>
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.
Sourcepub fn request_activity_keyboard_focus(&self)
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).
Check if a mouse position lands inside the sidebar content area.
Sourcepub fn in_main(&self, x: f32, y: f32) -> bool
pub fn in_main(&self, x: f32, y: f32) -> bool
Check if a mouse position lands inside the main content area.
Sourcepub fn in_bottom_panel(&self, x: f32, y: f32) -> bool
pub fn in_bottom_panel(&self, x: f32, y: f32) -> bool
Check if a mouse position lands inside the bottom panel.
Sourcepub fn in_title_bar(&self, x: f32, y: f32) -> bool
pub fn in_title_bar(&self, x: f32, y: f32) -> bool
Check if a mouse position lands inside the title bar.
Sourcepub fn in_status_bar(&self, x: f32, y: f32) -> bool
pub fn in_status_bar(&self, x: f32, y: f32) -> bool
Check if a mouse position lands inside the status bar.
Sourcepub fn in_command_line(&self, x: f32, y: f32) -> bool
pub fn in_command_line(&self, x: f32, y: f32) -> bool
Check if a mouse position lands inside the command line.
Sidebar content bounds (convenience for coordinate translation).
Sourcepub fn main_bounds(&self) -> Rect
pub fn main_bounds(&self) -> Rect
Main content bounds.
Sourcepub fn bottom_panel_bounds(&self) -> Option<Rect>
pub fn bottom_panel_bounds(&self) -> Option<Rect>
Bottom panel bounds.
Sourcepub fn bottom_band_bounds(&self, id: &WidgetId) -> Option<Rect>
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.
Sourcepub fn in_bottom_band(&self, id: &WidgetId, x: f32, y: f32) -> bool
pub fn in_bottom_band(&self, id: &WidgetId, x: f32, y: f32) -> bool
Check if a mouse position lands inside one currently-visible
BottomBand.
Sourcepub fn title_bar_bounds(&self) -> Option<Rect>
pub fn title_bar_bounds(&self) -> Option<Rect>
Title bar bounds.
Sourcepub fn window_bounds(&self) -> Rect
pub fn window_bounds(&self) -> Rect
The full window/viewport bounds this layout was computed against.
Sourcepub fn window_edge(&self, x: f32, y: f32, margin: f32) -> Option<ResizeEdge>
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).
Sourcepub fn status_bar_bounds(&self) -> Option<Rect>
pub fn status_bar_bounds(&self) -> Option<Rect>
Status bar bounds.
Sourcepub fn command_line_bounds(&self) -> Option<Rect>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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