Skip to main content

CaptureStack

Struct CaptureStack 

Source
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

Source

pub fn new() -> Self

An empty capture stack.

Source

pub fn push(&mut self, handler: Box<dyn CaptureHandler>)

Push a handler onto the top of the stack (it will see events first).

Source

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.

Source

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.)

Source

pub fn len(&self) -> usize

Number of handlers currently on the stack.

Source

pub fn is_empty(&self) -> bool

Whether the stack has no handlers.

Source

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.

Source

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().

Source

pub fn active_menu_help_ctx(&self) -> Option<HelpCtx>

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.

Source

pub fn dispatch(&mut self, ev: &mut Event, ctx: &mut Context<'_>) -> bool

Offer ev to the handlers top-down (last pushed first).

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§

Source§

impl Default for CaptureStack

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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, 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.