pub struct CaptureStack { /* private fields */ }Expand description
A LIFO stack of CaptureHandlers.
The most-recently pushed handler is offered events first. The live event loop
in Program owns this stack and drives
dispatch; a handler that wants to push a nested capture
does so through Context::push_capture, whose deferred queue the loop
applies after dispatch — so the stack is never aliased while a handler runs.
§Turbo Vision heritage
Has no direct analogue as a data structure: it replaces the nesting of blocking event loops Turbo Vision uses for modality, drag, and press-tracking with one non-recursive loop plus this stack (deviation D9).
Implementations§
Source§impl CaptureStack
impl CaptureStack
Sourcepub fn push(&mut self, handler: Box<dyn CaptureHandler>)
pub fn push(&mut self, handler: Box<dyn CaptureHandler>)
Push a handler onto the top of the stack (it will see events first).
Sourcepub fn sync_gate_bounds(&mut self, resolve: impl FnMut(ViewId) -> Option<Rect>)
pub fn sync_gate_bounds(&mut self, resolve: impl FnMut(ViewId) -> Option<Rect>)
Refresh every handler’s gating bounds from the live tree before a dispatch.
For each handler associated with a view (CaptureHandler::view), resolve
that view’s current bounds via resolve and push them down through
CaptureHandler::set_gate_bounds. A bounds-gating handler (a modal frame)
thus follows its view when it is dragged/resized; a handler that does not
override set_gate_bounds (a drag handler) is unaffected. The loop owns the
stack, so this is the loop’s responsibility, not a handler’s.
Sourcepub fn pop(&mut self) -> Option<Box<dyn CaptureHandler>>
pub fn pop(&mut self) -> Option<Box<dyn CaptureHandler>>
Remove and return the top handler, if any. Used by
Program::exec_view to remove the
ModalFrame it pushed once the modal loop ends —
the one place a frame is popped other than a handler self-popping via
CaptureFlow::ConsumedPop. (The loop owns the stack; a handler cannot
reach it to do a valid(end_state)-conditional pop, so the owner-side
exec_view does it.)
Sourcepub fn modal_view(&self) -> Option<ViewId>
pub fn modal_view(&self) -> Option<ViewId>
Returns the ViewId of the innermost executing modal view: the
topmost modal gate (CaptureHandler::is_modal_gate) on the stack,
even when a drag or menu handler sits above it. None when no modal
view executes. The pump routes focused events to this view, as C++
TGroup::execute hands them to the modal view’s own handleEvent.
Sourcepub fn top_modal_view(&self) -> Option<ViewId>
pub fn top_modal_view(&self) -> Option<ViewId>
Returns the ViewId of the top capture handler only when it is a
modal-bounds gate (CaptureHandler::is_modal_gate == true).
Used by the pump’s outside-modal redirect to avoid firing on drag or
menu-box handlers that also carry a view().
Returns the help context from an active MenuSession on the stack, if
any. Consults only the topmost handler: a menu preempts the help
context iff it is the topmost capture handler, matching C++
TopView()->getHelpCtx() where TopView() is the active TMenuView.
Checking only the top handler avoids a scan that would let a menu sitting
below a dialog wrongly win.
Used by the status-line refresh to surface per-item help while a menu is
open, without disturbing the existing top_modal_view path.
Sourcepub fn dispatch(&mut self, ev: &mut Event, ctx: &mut Context<'_>) -> bool
pub fn dispatch(&mut self, ev: &mut Event, ctx: &mut Context<'_>) -> bool
Offer ev to the handlers top-down (last pushed first).
CaptureFlow::Pass→ continue to the next lower handler;CaptureFlow::Consumed→ stop, returntrue;CaptureFlow::ConsumedPop→ remove that handler, stop, returntrue.
Returns false if every handler passed (the loop then runs normal
view-tree routing).
A handler may push a nested capture during its handle call — but that
goes into Context’s separate deferred queue, never into
self.handlers, so there is no aliasing of the stack. The ConsumedPop
removal happens after handle returns (NLL releases the index borrow
at the end of the call expression).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CaptureStack
impl !Send for CaptureStack
impl !Sync for CaptureStack
impl !UnwindSafe for CaptureStack
impl Freeze for CaptureStack
impl Unpin for CaptureStack
impl UnsafeUnpin for CaptureStack
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.