Skip to main content

SplitPanelState

Struct SplitPanelState 

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

State for a SplitPanel component.

Manages the split ratio, orientation, and which pane has focus. The parent is responsible for rendering content into each pane.

Implementations§

Source§

impl SplitPanelState

Source

pub fn new(orientation: SplitOrientation) -> Self

Creates a new split panel with the given orientation and a 50/50 split.

§Example
use envision::component::{SplitPanelState, SplitOrientation};

let state = SplitPanelState::new(SplitOrientation::Horizontal);
assert_eq!(state.ratio(), 0.5);
assert_eq!(state.orientation(), &SplitOrientation::Horizontal);
Source

pub fn with_ratio(orientation: SplitOrientation, ratio: f32) -> Self

Creates a split panel with a custom ratio.

The ratio is clamped to [min_ratio, max_ratio].

§Example
use envision::component::{SplitPanelState, SplitOrientation};

let state = SplitPanelState::with_ratio(SplitOrientation::Vertical, 0.3);
assert!((state.ratio() - 0.3).abs() < f32::EPSILON);
Source

pub fn orientation(&self) -> &SplitOrientation

Returns the current orientation.

Source

pub fn set_orientation(&mut self, orientation: SplitOrientation)

Sets the orientation.

Source

pub fn ratio(&self) -> f32

Returns the current split ratio.

0.5 means equal split. Values closer to 1.0 give more space to the first pane.

Source

pub fn set_ratio(&mut self, ratio: f32)

Sets the split ratio, clamped to [min_ratio, max_ratio].

Source

pub fn is_first_pane_focused(&self) -> bool

Returns true if the first pane has focus.

Source

pub fn is_second_pane_focused(&self) -> bool

Returns true if the second pane has focus.

Source

pub fn resize_step(&self) -> f32

Returns the resize step size (default 0.1 = 10%).

Source

pub fn with_resize_step(self, step: f32) -> Self

Sets the resize step size.

§Example
use envision::component::{SplitPanelState, SplitOrientation};

let state = SplitPanelState::new(SplitOrientation::Vertical)
    .with_resize_step(0.05);
assert!((state.resize_step() - 0.05).abs() < f32::EPSILON);
Source

pub fn with_bounds(self, min: f32, max: f32) -> Self

Sets the minimum and maximum ratio bounds.

§Example
use envision::component::{SplitPanelState, SplitOrientation};

let state = SplitPanelState::new(SplitOrientation::Vertical)
    .with_bounds(0.2, 0.8);
Source

pub fn is_focused(&self) -> bool

Returns true if the component is focused.

Source

pub fn set_focused(&mut self, focused: bool)

Sets the focus state.

Source

pub fn is_disabled(&self) -> bool

Returns true if the component is disabled.

Source

pub fn set_disabled(&mut self, disabled: bool)

Sets the disabled state.

Source

pub fn with_disabled(self, disabled: bool) -> Self

Sets the disabled state (builder pattern).

Source

pub fn handle_event(&self, event: &Event) -> Option<SplitPanelMessage>

Maps an input event to a split panel message.

Source

pub fn dispatch_event(&mut self, event: &Event) -> Option<SplitPanelOutput>

Dispatches an event, updating state and returning any output.

Source

pub fn update(&mut self, msg: SplitPanelMessage) -> Option<SplitPanelOutput>

Updates the state with a message, returning any output.

Source

pub fn layout(&self, area: Rect) -> (Rect, Rect)

Computes the layout areas for the two panes.

Returns (first_pane_area, second_pane_area).

Trait Implementations§

Source§

impl Clone for SplitPanelState

Source§

fn clone(&self) -> SplitPanelState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SplitPanelState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SplitPanelState

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for SplitPanelState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SplitPanelState

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SplitPanelState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> StateExt for T

Source§

fn updated(self, cmd: Command<impl Clone>) -> UpdateResult<Self, impl Clone>

Updates self and returns a command.
Source§

fn unchanged(self) -> UpdateResult<Self, ()>

Returns self with no command.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,