Skip to main content

PushSpecs

Struct PushSpecs 

Source
pub struct PushSpecs {
    pub side: Side,
    pub width: Option<f32>,
    pub height: Option<f32>,
    pub hidden: bool,
    pub cluster: bool,
}
Expand description

Information on how a Widget should be pushed onto another.

This information is composed of four parts:

  • A side to push;
  • An optional width;
  • An optional height;
  • Wether to hide it by default;
  • wether to cluster the Widget

Constraints are demands that must be met by the widget’s Area, on a best effort basis.

So, for example, if the PushSpecs are:

use duat::prelude::*;
let specs = ui::PushSpecs {
    side: ui::Side::Left,
    width: Some(3.0),
    height: None,
    hidden: false,
    cluster: true,
};

Then the widget should be pushed to the left, with a width of 3, an unspecified height, not hidden by default and clustered if possible. Note that you can shorten the definition above:

use duat::prelude::*;
let specs = ui::PushSpecs {
    side: ui::Side::Left,
    width: Some(3.0),
    ..Default::default()
};

Since the remaining values are the default.

Fields§

§side: Side

Which Side to push the Widget to.

§width: Option<f32>

A width (in character cells) for this Widget.

Note that this may be ignored if it is not possible to create an area big (or small) enough.

§height: Option<f32>

A height (in lines) for this Widget.

Note that this may be ignored if it is not possible to create an area big (or small) enough.

§hidden: bool

Hide this Widget by default.

You can call Area::hide or Area::reveal to toggle this property.

§cluster: bool

Cluster this Widget when pushing.

This makes it so, if the main Widget is moved or deleted, then this one will follow. Useful for things like LineNumbers, since they should follow their Buffer around.

Implementations§

Source§

impl PushSpecs

Source

pub const fn axis(&self) -> Axis

The Axis where it will be pushed.

Source

pub const fn comes_earlier(&self) -> bool

Wether this “comes earlier” on the screen.

This returns true if self.side() == Side::Left || self.side() == Side::Above, since that is considered “earlier” on screens.

Source

pub fn len_on(&self, axis: Axis) -> Option<f32>

The constraints on a given Axis.

Trait Implementations§

Source§

impl Clone for PushSpecs

Source§

fn clone(&self) -> PushSpecs

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 PushSpecs

Source§

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

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

impl Default for PushSpecs

Source§

fn default() -> PushSpecs

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

impl From<PushSpecs> for Axis

Source§

fn from(value: PushSpecs) -> Axis

Converts to this type from the input type.
Source§

impl Copy for PushSpecs

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> 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> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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.