Guide API
Skip to main content

OutlineViewerState

Struct OutlineViewerState 

Source
pub struct OutlineViewerState {
    pub state: ViewState,
    pub delta: Point,
    pub limit: Point,
    pub h_scroll_bar: Option<ViewId>,
    pub v_scroll_bar: Option<ViewId>,
    pub foc: i32,
    /* private fields */
}
Expand description

The shared state of every outline viewer. A concrete outline widget embeds one and exposes it via OutlineViewer::ov/OutlineViewer::ov_mut.

§Turbo Vision heritage

The data half of TOutlineViewer (toutline.cpp) plus the scroll offset/limit it inherits from the scroller base.

Fields§

§state: ViewState

View state (geometry, flags, …) — the View composition target.

§delta: Point

The scroll offset: x is the number of character columns to skip on the left; y is the DFS position of the first visible row.

Read delta to find out which part of the tree is visible. Do not assign it directly — changes come from scrollbar broadcasts that the pump resolves and applies via apply_delta.

§limit: Point

The content extent: x is the maximum graph+text width (in character columns); y is the total number of currently-visible nodes.

Updated by ov_update after every tree mutation. Read it to know the scrollable content size; do not assign directly.

§h_scroll_bar: Option<ViewId>

The horizontal scrollbar view id, or None if none was wired.

Set at construction via OutlineViewerState::new; the outline viewer reads and writes its value through the pump broker.

§v_scroll_bar: Option<ViewId>

The vertical scrollbar view id, or None if none was wired.

Set at construction via OutlineViewerState::new; the outline viewer reads and writes its value through the pump broker.

§foc: i32

The DFS position (0-based) of the focused node.

Read this to find out which node is focused. To move the focus programmatically, call adjust_focus (it also scrolls the focused row into view and notifies the trait via OutlineViewer::focused_item). Do not assign directly.

Implementations§

Source§

impl OutlineViewerState

Source

pub fn new(bounds: Rect, h: Option<ViewId>, v: Option<ViewId>) -> Self

Create the shared state for an outline viewer.

bounds sets the initial geometry; h and v are the optional horizontal and vertical scrollbar ids (pass None when scrollbars are absent). The view starts selectable, grows with its lower-right corner, and focuses at DFS position 0 with a zero scroll offset.

The initial scrollbar population is seeded automatically the first time a context-bearing lifecycle call reaches the viewer (event, state change, or bounds change), so no explicit ov_update is needed after construction. Call ov_update explicitly only after mutating the tree (swapping Outline::root, or expanding/collapsing programmatically) to recount visible nodes and republish the limits.

Source

pub fn set_limit(&mut self, x: i32, y: i32, ctx: &mut Context<'_>)

Set the content extent and (re)publish each bar’s range/page params. Same formula as Scroller::set_limit.

Source

pub fn scroll_to(&mut self, x: i32, y: i32, ctx: &mut Context<'_>)

Set each bar’s value (preserving range and steps). Same as Scroller::scroll_to.

Source

pub fn apply_delta(&mut self, d: Point)

Apply a freshly-read scrollbar delta. Unlike the scroller’s apply_delta there is no cursor adjust (the outline viewer has no editor cursor); just overwrite delta. Called by the pump (the read broker) after it resolves the bars and reads their values.

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
§

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

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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.