Guide API
Skip to main content

Group

Struct Group 

Source
pub struct Group { /* private fields */ }
Expand description

A view that owns and routes to a tree of child views.

A Group is the node type of the view tree: it owns a set of child views, draws them, routes events to them, and tracks which one is current/focused. The tree shape drives a few design choices:

  • Ownership is a Vec, links are by id. A Group owns children: Vec<Child>; children hold no up-pointer. Each child’s ViewId is a process-global identity minted at Group::insert and stamped into the child’s own ViewState.id. Cross-links (current) are a ViewId, resolved by an internal index lookup (Group::index_of).

    The children Vec is ordered back-to-front for painting: children[0] is the bottom (drawn first); children.last() is the top/frontmost (drawn last). Group::insert pushes, so a new child lands on top. Visits that go top-to-bottom (paint occlusion, hit-testing, broadcast delivery) iterate children.iter().rev(); tab order steps to the next-frontmost child by walking decreasing index with wrap.

  • Mouse position is view-local at each level. Because a child holds no pointer back to its owner, the group itself does the coordinate translation: on each positional delivery it subtracts the child’s origin, handing the child a position already in the child’s own coordinate frame.

  • No event bubbling. “Consumed” means the event was set to Event::Nothing; an unhandled event is simply left not cleared, and as the recursive handle_event stack unwinds the parent/loop sees it still live. There is no owner pointer to bubble back to.

  • Painter’s-algorithm draw. draw paints back-to-front, so higher siblings overpaint lower ones. There is no per-cell occlusion bookkeeping: the whole tree is redrawn each frame and a diff sends only the changed cells to the terminal.

  • Z-reorder lives in the owner. A child cannot move itself in the Z-order; the group does it (Group::put_in_front_of/Group::make_first). Selecting a child that opts into raise-on-select (top_select) raises it to the top via Group::focus_child rather than merely making it current.

Running a modal loop is not a group operation: the event loop owns the capture stack, so modality runs through Program::exec_view and a ModalFrame. Bulk data transfer uses the typed View::value/View::set_value protocol, and the hardware cursor is placed by the event loop.

The sibling-ring↔Vec Z-order mapping is described above. Build with Group::new, add children with Group::insert, and drive it as any other View (draw / handle_event / …).

§Turbo Vision heritage

Ports TGroup (tgroup.cpp). The circular sibling ring plus owner back-pointers become an owned Vec of children addressed by ViewId (deviation D3); broadcasts carry a ViewId subject rather than a pointer (deviation D4); the occlusion/buffering draw machinery is replaced by whole-tree redraw + diff.

Implementations§

Source§

impl Group

Source

pub fn new(bounds: Rect) -> Self

Create a Group covering bounds, ready to receive children via insert.

The constructed group is selectable (so it participates in focus routing) and opts into both mouse-tracking event classes (move and auto-repeat) so it receives them and can route them to its children. No children are added; add them with insert after construction.

Most applications do not call Group::new directly — the standard container types (crate::desktop::Desktop, crate::dialog::Dialog) build on it internally. Call Group::new only when you need a bare, unstyled container that routes events and draws its children without any frame or background fill.

§Turbo Vision heritage

Ports TGroup::TGroup (options |= ofSelectable, eventMask = 0xFFFF). tvision-rs’s event mask exposes only those two opt-in tracking classes; the dropped constructor bits were buffering/clipping flags that do not apply under whole-tree redraw + diff.

Source

pub fn current(&self) -> Option<ViewId>

The current (selected) child’s id, if any.

Source

pub fn set_surface(&mut self, normal: Role, inactive: Role)

Paint the group’s own extent as a background surface before drawing children: normal when the group is focused (its pane is the active one), inactive when not.

Children paint over the surface (painter’s algorithm), so a fully-tiled group looks unchanged — only cells no child covers show it. Opt-in: a group with no surface set fills nothing (the default).

The fill keys on the same signal the group fans to its children as DrawCtx::owner_active, so the pane’s background and its children’s content surfaces recede together. Consequently a nested group with a surface recedes whenever it is off the focus chain, even while its enclosing pane is focused — intentional: its own children’s owner_active recedes identically, so background and content always agree.

Pick the role pair matching the pane’s content, e.g. Role::ListNormal / Role::ListInactive for a pane built of lists:

use tvision_rs::{Group, Rect, Role};

let mut pane = Group::new(Rect::new(0, 0, 40, 10));
pane.set_surface(Role::ListNormal, Role::ListInactive);
§Turbo Vision heritage

tvision-rs extension to TGroup. In Turbo Vision a group never paints its own area (backgrounds are TBackground / frame territory). The faithful default is preserved: the surface is strictly opt-in.

Source

pub fn clear_surface(&mut self)

Remove a surface set by set_surface: the group reverts to painting no background (the children cover it).

Source

pub fn len(&self) -> usize

Number of children currently in the group.

Source

pub fn is_empty(&self) -> bool

Whether the group has no children.

Source

pub fn child_mut(&mut self, id: ViewId) -> Option<&mut dyn View>

Mutably borrow child id’s view — for an owner reaching into one of its own children by concrete type (downcast via View::as_any_mut, e.g. a window reaching its frame). None for a stale/foreign id.

Source

pub fn gather_data(&self) -> Vec<Option<FieldValue>>

Collect the current typed value of every child into a snapshot vector.

Returns one Option<FieldValue> per child in insertion (bottom-to-top) order — the same order scatter_data expects. A None entry means that child carries no transferable value (e.g. a label or a decorative frame).

Use this to read a dialog’s current field values before closing it, or to checkpoint the dialog state for undo. Pair with scatter_data to restore:

ⓘ
let snapshot = dialog_group.gather_data();
// … later …
dialog_group.scatter_data(&snapshot, ctx);
§Turbo Vision heritage

Ports TGroup::getData (the data-walk that collects each control’s value into a flat byte record). The typed FieldValue vector replaces the opaque byte record of the original getData/setData value protocol.

Source

pub fn scatter_data( &mut self, values: &[Option<FieldValue>], ctx: &mut Context<'_>, )

Distribute typed values back to children in the same bottom-to-top order as gather_data.

Use this to initialize or reset a dialog’s fields from application data before showing it, or to restore a snapshot previously taken with gather_data. A typical dialog open sequence:

ⓘ
let initial = vec![
    Some(FieldValue::String("default".into())),
    None, // label — no value
    Some(FieldValue::Bool(true)),
];
dialog_group.scatter_data(&initial, ctx);

values shorter than children: remaining children are left untouched. Extra values beyond the children count are silently ignored. None entries skip the corresponding child without writing it.

Uses set_value_ctx rather than set_value so widgets that need a Context for side effects (e.g. ListBox updating its scroll bar) receive it correctly.

§Turbo Vision heritage

Ports TGroup::setData (the data-walk that writes each control’s value back from a flat byte record). The typed FieldValue slice replaces the opaque byte record of the original getData/setData value protocol.

Source

pub fn gather_list(&self) -> FieldValue

Gather the whole record as a single ordered FieldValue::List — the typed image of C++ getData(void *rec)’s offset-addressed walk. Only data-bearing children (those whose value is Some) contribute, in child order; a child with no value is the dataSize == 0 case and is absent. Built on gather_data.

§Turbo Vision heritage

TGroup::getData viewed as producing one record value.

Source

pub fn scatter_list(&mut self, record: &FieldValue, ctx: &mut Context<'_>)

Scatter an ordered FieldValue::List record back to the data-bearing children, in child order (the inverse of gather_list). Children with no value are skipped (they consume no record slot — the dataSize == 0 walk). A non-List argument is ignored.

§Turbo Vision heritage

TGroup::setData viewed as consuming one record value.

Source

pub fn insert(&mut self, view: Box<dyn View>) -> ViewId

Insert view on top of the group (it becomes the frontmost child), mint a process-global ViewId, stamp it into the view’s own ViewState.id, and return it.

Applies center_x/center_y centering (the only observable effect at insert time). insert alone never focuses — to make the new child current, callers use set_current/reset_current.

Insert-time currency: inserting a visible+selectable child sets currency_dirty, a deferred request to re-establish the group’s current view. It is settled by View::settle_currency (run by the event loop / at program start), which runs reset_current; any explicit set_current in between supersedes it and clears the flag.

§Turbo Vision heritage

Ports TGroup::insert (insert-on-top). The hide/show/active-restore dance around the original insert is a no-op here (no occlusion tracking); only the centering and the deferred currency cascade survive.

Source

pub fn insert_with_id(&mut self, view: Box<dyn View>, id: ViewId)

Insert view on top of the group stamping a caller-supplied ViewId instead of minting a fresh one — the pre-minted-id sibling of insert.

The menu modal layer pre-mints each open box’s ViewId from the global counter (ViewId::next) before requesting the box be opened, so the MenuSession capture handler already knows every box id with no insert-time callback or downcast. The event loop then builds the MenuBox and inserts it here, stamping the id the session already holds. Otherwise identical to insert: centering applies; current is not touched — a menu box is never focused, the session owns every event.

The caller is responsible for the id being globally unique (a ViewId::next value is, by construction); reusing a live id would make find_mut resolve the wrong child.

Source

pub fn remove(&mut self, id: ViewId, ctx: &mut Context<'_>)

Remove the child named by id from this group, dropping it, and re-establish focus if needed (no-op if id is not a direct child).

Use remove when you hold a &mut Context — typically inside a handle_event override or a deferred-effect callback. For closes triggered inside event dispatch (the common “close window” path) prefer Context::request_close, which defers the removal to after the dispatch unwinds; Group::remove is available for the rare case where you already hold &mut Group directly outside the dispatch stack.

Removing a visible+selectable child re-establishes currency (reset_current) whether or not that child was the current one. A removed current additionally vacates the current slot first. The removed child is dropped (Rust ownership): unlike the C++ Delete there is no returned detached pointer.

§Turbo Vision heritage

Ports TGroup::Delete and TGroup::remove (tgroup.cpp): hiding the view before unlinking it runs the visibility-change currency tail, which is why any visible+selectable removal resets currency, not just removal of the current view. The Rust port drops the child (owned Box) rather than handing it back as a raw pointer.

Source

pub fn set_current( &mut self, p: Option<ViewId>, mode: SelectMode, ctx: &mut Context<'_>, )

Select child p as the current view (or clear the current to None), applying focus/select side effects without validating the outgoing view.

This is the unvalidated current-change path — it does not call valid(RELEASED_FOCUS) on the outgoing child. For the validated Tab/Shift-Tab navigation path use focus_next or focus_child, both of which gate on the outgoing view’s consent before switching.

mode controls which selection side effects fire:

  • SelectMode::Normal: deselect the old current, select the new one.
  • SelectMode::Enter: entering a modal — do not deselect the old current (it keeps its selected state underneath the modal).
  • SelectMode::Leave: leaving a modal — do not select the new current (restores the pre-modal current without re-selecting it).

When the group itself is focused the focused flag is moved between the outgoing and incoming children as well.

Unvalidated SelectNext equivalent: to advance focus without validation (the C++ SelectNext behavior), compose find_next + set_current:

ⓘ
if let Some(next) = group.find_next(forwards) {
    group.set_current(Some(next), SelectMode::Normal, ctx);
}
§Turbo Vision heritage

Ports TGroup::setCurrent plus its focus/select helpers (tgroup.cpp), with the redraw-locking bracket dropped (whole-tree redraw + diff). SelectNext (guide p. 453, unvalidated sibling ring walk) is realized by composing find_next + set_current rather than a dedicated method.

Source

pub fn focus_child(&mut self, id: ViewId, ctx: &mut Context<'_>) -> bool

Make the child id the current/focused one (the group is assumed focused).

First the outgoing current is validated: if it opts into validation (validate) and reports it is not yet ready to release focus, the switch is refused and this returns false. Otherwise the child is selected: a child that opts into raise-on-select (top_select) is raised to the top (make_first); any other selectable child is just made current via set_current. Returns true on success.

Self-heal: after raising a top_select child, if it is somehow still not current we re-assert currency with an explicit set_current. Normally raising a child also re-establishes currency, but that step no-ops when the child is already on top — and a just-inserted topmost child has not yet had its deferred insert-time currency settled, so without this its current slot could still be empty. When currency is already correct this re-assert is itself a no-op (set_current early-returns when nothing changes).

Selectability is checked by the callers, not here: the mouse-down auto-select path checks selectable && !selected && !disabled first, and focus_next only iterates visible, enabled, selectable children — so focus_child itself does not re-check it.

§Turbo Vision heritage

Realizes TView::focus() → TView::select() (tview.cpp) in the owner: the validate-then-select sequence, where ofTopSelect views call makeFirst and others call setCurrent. The self-heal covers a case the C++ leaves to its synchronous insert-time resetCurrent, which tvision-rs defers (deviation D3).

Source

pub fn reset_current(&mut self, ctx: &mut Context<'_>)

Re-establish current as the first visible+selectable child.

§Turbo Vision heritage

Ports TGroup::resetCurrent (re-select the first matching child).

Source

pub fn find_next(&self, forwards: bool) -> Option<ViewId>

The next selectable child in tab order from current, or None if there is no other eligible child (the search wraps back to current).

forwards walks toward the next-frontmost child (decreasing index, with wrap); the reverse direction walks increasing index. Eligible means visible, enabled, and selectable.

§Turbo Vision heritage

Ports TGroup::findNext (tab-order search over the sibling ring).

Source

pub fn focus_next(&mut self, forwards: bool, ctx: &mut Context<'_>) -> bool

Move focus to the next selectable child in tab order: focuses the find_next result, or returns true when there is no other eligible child (so a no-other-child group reports success rather than blocking the keystroke).

§Turbo Vision heritage

Ports TGroup::focusNext.

Source

pub fn focus_by_number(&mut self, num: i16, ctx: &mut Context<'_>) -> bool

Select (raise + focus) the selectable child whose number matches num. Returns whether a match was found. This backs the “select window N” shortcut (Alt-1 … Alt-9): it walks the children directly and uses focus_child, so a matching window that opts into raise-on-select is raised to the top as well as focused.

Unlike the tab-order path, selectability is filtered here (the match requires a selectable child); the validation re-check inside focus_child is harmless because the caller has already confirmed focus may move.

§Turbo Vision heritage

Realizes the “select window by number” broadcast arm of TWindow::handleEvent as a direct child walk (deviations D3/D4).

Source

pub fn put_in_front_of( &mut self, id: ViewId, target: Option<ViewId>, ctx: &mut Context<'_>, )

Reposition child id to sit immediately in front of (above in Z-order) target, or at the very top if target is None.

Use this to control the stacking order of child views — for example, to ensure a newly opened panel appears behind an existing top-level dialog, or to implement a “send to back of peers” layout. A child cannot reorder itself (it holds no owner pointer); the owning group is always the actor.

Concretely, “in front of target” means id lands one slot above target in the back-to-front children Vec (painted later, therefore on top). target == None is a sentinel meaning “the top” (used internally by make_first).

Guards: this is a no-op if id == target, if id is already immediately in front of target, or (for target == None) if id is already the topmost child. Unknown or foreign ids are silently ignored. If the moved view is selectable, currency is re-established (reset_current) afterwards.

No send-to-bottom: there is intentionally no send-to-bottom path — no current consumer needs it.

§Turbo Vision heritage

Realizes TView::putInFrontOf in the owner. The original send-to-bottom overload (putInFrontOf(0)) is unimplemented; the visibility hide/show redraw dance is dropped (whole-tree redraw + diff).

Source

pub fn make_first(&mut self, id: ViewId, ctx: &mut Context<'_>)

Move child id to the top (frontmost) of the Z-order. Equivalent to put_in_front_of with target == None. Realized in the owner.

§Turbo Vision heritage

Ports TView::makeFirst (putInFrontOf(first())).

Trait Implementations§

Source§

impl View for Group

Source§

fn draw(&mut self, ctx: &mut DrawCtx<'_>)

Paint visible children back-to-front (children[0] → children.last()), each through a sub-context clipped to its bounds — painter’s algorithm, so higher siblings overpaint lower ones. By default the group does not fill its own area — the children cover it; a group given a surface via Group::set_surface first fills its extent (normal role when focused, inactive when not), which the children then overpaint. After each child that casts a drop shadow the group draws the shadow (DrawCtx::cast_shadow): back-to-front order means later (higher) siblings overwrite the shadow cells they occlude.

§Turbo Vision heritage

Ports TGroup::draw/drawSubViews, with the paint order reversed: the original paints top-first and tracks occlusion, which tvision-rs drops in favor of whole-tree redraw + diff.

Source§

fn set_state(&mut self, flag: StateFlag, enable: bool, ctx: &mut Context<'_>)

Flip the group’s own state flag (emitting the focus-gained/lost broadcast for the focused flag) then propagate: Active/Dragging to all children; Focused to the current child only.

§Turbo Vision heritage

Ports TGroup::setState. The dropped flag cases (visible/exposed) were occlusion side effects, unneeded under whole-tree redraw + diff.

Source§

fn change_bounds(&mut self, bounds: Rect)

Apply bounds; if the size changed, propagate the size delta to every child via calc_bounds/change_bounds (the grow-mode resize math), so children grow/move with their owner.

§Turbo Vision heritage

Ports TGroup::changeBounds, with the buffer-reallocation/redraw-locking bracket dropped (whole-tree redraw + diff).

Source§

fn on_bounds_changed(&mut self, ctx: &mut Context<'_>)

Forward on_bounds_changed to every child when the last change_bounds resized them, so a list viewer or scroller at any depth re-publishes its scroll-bar state. A move without a size change re-bounds no child and forwards nothing.

§Turbo Vision heritage

TGroup::changeBounds calls changeBounds on every child after a size change, and TListViewer/TScroller::changeBounds re-publish inline. Here change_bounds has no Context, so the re-publish half runs in this hook; the dirty flag carries “the children were re-bounded” from one call to the other.

Source§

fn get_help_ctx(&self) -> HelpCtx

The focused child’s help context (recursively), falling back to the group’s own when there is no current child or the chain yields no context.

§Turbo Vision heritage

Ports TGroup::getHelpCtx: returns current->getHelpCtx(), and only when that is hcNoContext (or there is no current) falls back to TView::getHelpCtx (own help_ctx, or DRAGGING while dragging). The dragging case is therefore preserved by the fallback leg.

Source§

fn cursor_request(&self) -> Option<Point>

Descend into the current child to find where the hardware cursor should sit, accumulating the child’s origin so the result is in this group’s coordinate frame. The event loop walks this chain from the root to place the cursor.

None (caret hidden) if there is no current child or it wants no cursor shown, if this group or the child is hidden, if the caret lies outside the child’s extent, or if a visible sibling above the child in Z-order covers the caret cell. Each level checks its own child, so a caret scrolled out of any owner on the chain is hidden; the root’s own extent is checked by the caller.

§Turbo Vision heritage

The group case of the focused-chain cursor walk (TView::resetCursor), with the clipping of TVCursor::computeCaretSize / caretCovered (tvcursor.cpp): there the walk runs bottom-up from the focused view; here it runs top-down over the same chain and applies the same tests.

Source§

fn caret_size(&self) -> u8

The caret size of the current child (recursively) — the view whose caret cursor_request places. Falls back to the group’s own state when there is no current child.

§Turbo Vision heritage

TVCursor::decideCaretSize reads sfCursorIns of the view whose resetCursor runs: the focused leaf at the end of this chain.

Source§

fn find_mut(&mut self, id: ViewId) -> Option<&mut dyn View>

The group’s View::find_mut override — the recursive tree-walk. One pass per child: match the child’s own id, else recurse into it. A two-pass split (all direct children, then all recursions) fails the borrow checker (E0499) — the early return of &mut in the first loop escapes to the function’s return lifetime, blocking the second iter_mut. The single pass is semantically identical here: ids are process-global and unique, so at most one node in the subtree matches and visit order is irrelevant.

Source§

fn descendant_global_bounds(&self, id: ViewId, acc: Point) -> Option<Rect>

The group’s View::descendant_global_bounds override — resolve id to its absolute bounds. acc is THIS group’s absolute origin; a child’s owner-local bounds come from child.view.state().get_bounds() (the Child struct carries no bounds field). Mirrors find_mut’s recursion but accumulates origins: the child’s absolute origin is acc + child.origin, and the returned rect is the child’s size placed at that origin. Recurses into each child with the child’s accumulated origin, so it is faithful for any nesting depth (root → dialog → link).

Source§

fn remove_descendant(&mut self, id: ViewId, ctx: &mut Context<'_>) -> bool

The group’s View::remove_descendant override — route to the owning group’s remove (which also re-establishes currency). If id is a direct child, remove it here; otherwise recurse so the group that actually owns it does the removal.

Source§

fn focus_descendant(&mut self, id: ViewId, ctx: &mut Context<'_>) -> bool

The group’s View::focus_descendant override — route to the owning group’s focus_child. If id is a direct child, gate on selectability and select it; either way id was found, so return true to stop the walk (a non-selectable match is still a match — it just doesn’t get focused). Otherwise recurse so the group that actually owns id does the selection.

Source§

fn has_focusable_leaf(&self) -> bool

A group has a focusable leaf iff any visible, enabled child does (a leaf child reports itself; a group child recurses).

Source§

fn focus_to_edge(&mut self, backward: bool, ctx: &mut Context<'_>) -> bool

Enter this group at its edge child for hierarchical Tab: the first child (Tab) or last (Shift-Tab) that has a focusable leaf, made current and then recursively entered. Returns whether a leaf was focused.

Source§

fn set_visible_descendant( &mut self, id: ViewId, visible: bool, ctx: &mut Context<'_>, ) -> bool

The group’s View::set_visible_descendant — write the visible flag in the OWNING group and run the visibility-change currency tail: if the flag actually changed and the child is selectable, re-establish currency (reset_current) — in both directions (show and hide). A no-change write runs no tail (an idempotent toggle has no cascade). Recurses like find_mut when id is not a direct child.

Delivers StateFlag::Visible via child.set_state so that widgets that own sibling scroll bars (e.g. ListViewer) can show/hide them in sync — mirroring C++ setState(sfVisible).

Source§

fn reset_current(&mut self, ctx: &mut Context<'_>)

The View::reset_current override — re-establish the group’s internal currency (first visible+selectable child). Delegates to the inherent Group::reset_current. Inherent methods take resolution priority over same-named trait methods, so the fully-qualified call below is NOT recursion — it dispatches to the inherent fn, not back here.

Source§

fn settle_currency(&mut self, ctx: &mut Context<'_>)

The group’s View::settle_currency — run pending insert-time currency cascades, POST-ORDER (children first, so a child group’s currency exists before this group’s focus cascade descends into it). Runs the INHERENT Group::reset_current (not the trait override) — see the trait method’s doc for why (a file dialog’s one-time init must stay on the exec_view path).

Source§

fn valid(&mut self, cmd: Command, ctx: &mut Context<'_>) -> bool

Validity check. For the “may I release focus?” command (Command::RELEASED_FOCUS) it defers to the current child only when that child opts into validation (else true); for any other command every child must be valid.

Threads &mut Context because a child’s validity check may itself want to pop up a modal message box. The all-children branch stops at the first invalid child, which also ensures only that child enqueues an error box (a single box, not one per invalid field).

§Turbo Vision heritage

Ports TGroup::valid.

Source§

fn awaken(&mut self)

Finish initialization for every child after the group (or the dialog that owns it) is fully wired into the view tree.

awaken is called once by the framework — after all siblings and the group itself have been inserted — so each child can safely inspect the tree topology or its siblings at this point. The call order across children is intentionally unspecified; do not rely on one child’s awaken completing before another’s.

When to override (in a type that embeds a Group): if your container widget needs a one-time startup action that requires a live Context (e.g. triggering a data scatter), override View::awaken and call self.group.awaken() first so children are ready before your own logic runs.

§Turbo Vision heritage

Ports TGroup::awaken, which iterates each subview calling subview->awaken() before the group’s own TView::awaken. The children-first ordering is preserved.

Source§

fn handle_event(&mut self, ev: &mut Event, ctx: &mut Context<'_>)

The three-phase event router.

  • focused events (KeyDown/Command): a pre-process pass (top→bottom, only children that opt into pre-processing) → the focused pass (the current child) → a post-process pass (top→bottom, only children that opt into post-processing).
  • broadcasts: delivered to every child (top→bottom).
  • positional (mouse): the topmost visible child whose bounds contain the (group-local) position — with mouse-down auto-select applied before delivery, so clicking a selectable child focuses it.

A group does not run a self-focus step on itself here: selecting a child is the parent’s job, and the base view’s event handler is a no-op.

Owner size: the routing body is bracketed by a ctx.set_owner_size(self.size) / restore so a child can read its owner’s size (e.g. a window computing its zoomed bounds). The restore is unconditional because the actual routing lives in route_event, which may return early — the bracket here guarantees a parent group’s later sibling deliveries never see this group’s size.

§Turbo Vision heritage

Ports TGroup::handleEvent (the pre/focused/post phase router and positional hit-test).

Source§

fn state(&self) -> &ViewState

Borrow the embedded ViewState (the view’s data members).
Source§

fn state_mut(&mut self) -> &mut ViewState

Mutably borrow the embedded ViewState.
Source§

fn set_modal_answer(&mut self, _cmd: Command)

Stash the user’s choice from an async modal message box this view requested via Context::request_message_box (the answer_to/RouteModalAnswer round-trip). Default: no-op. Overridden by views that drive a Yes/No/Cancel prompt out of valid (e.g. FileEditor caches it for the re-validate).
Source§

fn value(&self) -> Option<FieldValue>

This control’s current value as a FieldValue, or None for a view that carries no transferable data. Read more
Source§

fn set_value(&mut self, _v: FieldValue)

Load a typed FieldValue into this control. Read more
Source§

fn set_modal_data(&mut self, _data: FieldValue)

Deliver a finished modal’s typed result record to the view that launched it. Defaulted no-op; a launcher view overrides it to load the record. Two producers call it: Read more
Source§

fn set_value_ctx(&mut self, v: FieldValue, ctx: &mut Context<'_>)

Scatter a typed FieldValue into this control with a Context. Default: calls set_value (the context-free setter). Override when scatter needs deferred publishing (e.g. ListBox republishes its vertical scrollbar via focus_item).
Source§

fn size_limits(&self, owner_size: Point) -> (Point, Point)

The (min, max) size this view may take inside an owner of owner_size. Read more
Source§

fn calc_bounds(&mut self, owner_size: Point, delta: Point) -> Rect

The new bounds after the owner resized to owner_size (delta = new - old). Computes the size limits via the overridable size_limits hook — so a widget override (e.g. a window’s minimum) participates — then delegates the grow math to ViewState::calc_bounds (the single source). Returns the bounds; it does not apply them (change_bounds does).
Source§

fn number(&self) -> Option<i16>

The window number for Alt-N selection. Base views are unnumbered (None); Window overrides to return its number when > 0 (0 means unnumbered → None).
Source§

fn grabs_focus_on_click(&self) -> bool

Whether a mouse-down inside this view should auto-select (focus) it — the per-view opt-out for the group’s mouse-down auto-select (see Group::route_event). Default true (the common case); a Button overrides to return its grab-focus flag. A view returning false is not focused by a click but still receives the click (so it can act, e.g. press, without becoming the current view).
Source§

fn select_window_num(&mut self, num: i16, ctx: &mut Context<'_>) -> bool

Tree-op: ask this subtree to select the window numbered num. Returns whether one matched. Consistent with the find_mut / remove_descendant tree-op family: the live loop holds a subtree only by id (here, the desktop) and asks it to act. Default: no-op (false). Desktop overrides.
Source§

fn tile(&mut self, _r: Rect)

Tree-op: lay this subtree’s tileable windows out in a grid (the tile command). Base: no-op (only Desktop lays out windows). r is the desktop-local layout rect. Mirrors select_window_num: the live loop drives the desktop by id through &mut dyn View.
Source§

fn cascade(&mut self, _r: Rect)

Tree-op: lay this subtree’s tileable windows out cascaded (the cascade command). Base: no-op; Desktop overrides.
Source§

fn apply_scroll_sync( &mut self, _h: Option<i32>, _v: Option<i32>, _ctx: &mut Context<'_>, )

The shared scrollbar read-sync broker hook. Defaulted no-op; scroll-aware widgets override it to apply a freshly-read scrollbar delta to themselves. The pump passes the horizontal/vertical scrollbar values (None if that bar is absent or unresolved), each read via View::value. Overridden by the list viewers (delegate to list_viewer::apply_scroll), Scroller, the outline viewer, and the editor — every sibling-scrollbar read sync routes through this one method instead of a pump downcast. Read more
Source§

fn update_menu_commands(&mut self, _disabled_cmds: &CommandSet)

The menu command-graying broker hook. Defaulted no-op; menu views override to re-gray their menu tree against the program’s live disabled-command set (denylist — the argument is the set of commands currently disabled; an item grays iff its command is in it). The free fn menu::menu_view::update_menu_commands implements the re-gray walk. Read more
Source§

fn set_menu_current(&mut self, _current: Option<usize>)

The menu-highlight write-back hook. Defaulted no-op; menu views (MenuBar / MenuBox) override to set their MenuViewState::current — the write-only display cache their draw reads to pick the selected colour. Read more
Source§

fn as_any_mut(&mut self) -> Option<&mut dyn Any>

Downcast hook for the rare parent→child push that needs the concrete type (e.g. a window pushing its zoomed flag to its frame). Base returns None; only views that must be reached concretely override it. (Any requires 'static, which every view is.)
Source§

fn set_indicator_value(&mut self, _location: Point, _modified: bool)

The editor→indicator status-push broker hook. Defaulted no-op; the editor’s status Indicator overrides it to store the new cursor location + modified flag. Driven by Deferred::IndicatorSetValue: the editor (a leaf) cannot reach its indicator sibling inline, so it requests this and the pump calls the method by id — virtual dispatch, not a downcast.
Source§

fn apply_page_sync(&mut self, _idx: usize, _ctx: &mut Context<'_>)

The tab-bar→page-stack switch broker hook. Defaulted no-op; PageStack overrides it to make page idx active. Driven by Deferred::PageStackSync: the pump reads the bound tab bar’s value and calls this method by id — virtual dispatch, not a downcast.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Group

§

impl !Send for Group

§

impl !Sync for Group

§

impl !UnwindSafe for Group

§

impl Freeze for Group

§

impl Unpin for Group

§

impl UnsafeUnpin for Group

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
§

impl<T> Downcast for T
where T: Any,

§

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

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

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

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.