Skip to main content

Stackpanel

Struct Stackpanel 

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

Stackpanel will group multiple windows and arrange them according to the Orientation. It will also allow movement between them using the arrow keys. Default margin is 1.

Design (optional Border, vertical):

┌─────────┐
│Content A│
│         │
│Content B│
└─────────┘

Horizontal:

┌─────────────────────┐
│Content A   Content B│
└─────────────────────┘

Implementations§

Source§

impl Stackpanel

Source

pub fn default_callback(_: &mut Self)

Source

pub fn default_key_handler(&mut self, event: &mut WindowEvent)

Source

pub fn new(orientation: Orientation) -> Self

Constructs a new Stackpanel with the given Orientation

Source

pub fn set_selection_changed_callback<F: Fn(&mut Self) + 'static>( &mut self, callback: F, )

Source

pub fn set_key_handler(&mut self, f: StackpanelKeyHandler)

Source

pub fn set_item_alignment(&mut self, alignment: Alignment)

Sets the alignment for each child/item within the Stackpanel

Source

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

Source

pub fn set_focus(&mut self, item: &Rc<RefCell<dyn Window>>)

Sets the internal childrens focus

Source

pub fn set_child_margin(&mut self, margin: u8)

Sets the offset between each child

Source

pub fn scroll( &mut self, direction: Direction, kind: ScrollKind, scroll_only: bool, )

scroll_only specifies whether selection should also change if only the view changes

Source

pub fn has_scroll_viewer(&self) -> bool

Trait Implementations§

Source§

impl Default for Stackpanel

Source§

fn default() -> Self

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

impl HasWindowUID for Stackpanel

Source§

fn uid(&self) -> WindowUID

Must be static and unique for each object implementing Window. Generate once per instance using WindowUID::new.
Source§

impl ItemCollection<Rc<RefCell<dyn Window>>> for Stackpanel

Source§

fn add_item(&mut self, item: WindowRef)

Adds a child to the internal array

Source§

fn remove_item(&mut self, item: &WindowRef)

Removes a single child from the internal array

Source§

fn get_item(&mut self, index: Self::Index) -> Option<&WindowRef>

Returns a child by its index

Source§

fn clear_items(&mut self)

Removes all children from the internal array

Source§

fn items(&self) -> Self::Index

Returns the number of children

Source§

type Index = usize

Type used to index the underlying collection
Source§

fn remove_at(&mut self, index: Self::Index) -> WindowRef

Removes an item at the given index from the underlying collection Might panic if index is invalid
Source§

impl Scrollable for Stackpanel

Source§

fn is_scrollable(&self, axis: Orientation) -> bool

Can current Scrollable be scrolled horizontally / vertically
Source§

fn scroll(&mut self, direction: Direction, kind: ScrollKind)

Scrolls page/line-wise (see ScrollKind) in the given direction
Source§

fn set_offset(&mut self, direction: Orientation, offset: usize)

Sets the horizontal / vertical offset
Source§

fn offset(&self, axis: Orientation) -> usize

Horizontal / Vertical offset of the scrolled content
Source§

fn viewport(&self, axis: Orientation) -> usize

Horizontal / Vertical size of the viewport for current Scrollable
Source§

fn set_scroll_viewer(&mut self, scroll_viewer: Weak<RefCell<ScrollViewer>>)

Should only be called by the ScrollViewer itself
Source§

impl Widget for Stackpanel

Source§

fn set_visibility(&mut self, visibility: bool)

Source§

fn set_width(&mut self, width: Size)

Source§

fn set_height(&mut self, height: Size)

Source§

fn set_margin(&mut self, margin: Thickness)

Source§

fn set_border(&mut self, border: BorderStyle)

Source§

fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )

Source§

fn set_enabled_state(&mut self, is_enabled: bool)

Changing the IsEnabled state usually changes the highlight color
Source§

fn set_width_constraint(&mut self, width: SizeConstraint)

Source§

fn set_height_constraint(&mut self, height: SizeConstraint)

Source§

impl WidgetColors for Stackpanel

Source§

fn set_disabled_color(&mut self, color: Option<Color>)

Source§

fn set_base_fg_color(&mut self, color: Option<Color>)

Source§

fn set_base_bg_color(&mut self, color: Option<Color>)

Source§

impl Window for Stackpanel

Source§

fn render(&self, canvas: &mut Canvas)

Allows self to draw into its own Canvas The canvas size depends on other properties set and the terminal size itself It is guarenteed that the size of the Canvas is atleast 1x1
Source§

fn children(&mut self, builder: SubWindowBuilder) -> SubWindows

Returns all children windows (and layouting Rects) Note: When changing the children make sure to also adjust the focus
Source§

fn handle_event(&mut self, event: &mut WindowEvent)

The events are forwarded from crossterm with the only exception of Resize which will have the same dimensions as the resulting canvas If a event’s handled attributed is set to true it will stop bubbling otherwise it will keep bubbling until another Window marks it as handled Except for: Read more
Source§

fn focus(&self) -> Option<WindowRef>

Which child of the window has focus Is there is None, then ´self´ has focus
Source§

fn is_enabled(&self) -> bool

Is self enabled? Indicated whether or not to handle input and if its focusable When false, Window is still eligible to receive events
Source§

impl WindowLayout for Stackpanel

Source§

fn desired_size(&self, available_size: TPoint) -> TPoint

Parents call this to get the desired size of the child This must not exceed available_size on any axis When the result’s product is equal to 0, this window wont be drawn
Source§

fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)

Aligns self within its parent Window
Source§

fn border(&self) -> BorderStyle

Source§

fn is_visible(&self) -> bool

Source§

fn margin(&self) -> Thickness

Source§

fn desired_size_pre_hook(&mut self, available_size: TPoint)

This is similar to desired_size but will not return anything and can mutably change self This is executed before WindowLayout::desired_size Only implement if actually necessary

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
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: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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.
Source§

impl<T> WindowHelper for T
where T: Window,