Skip to main content

Style

Struct Style 

Source
#[repr(C)]
pub struct Style { pub width: Length, pub height: Length, pub padding: Edges<i8>, pub bg: Color, pub border_color: Color, pub gap: i8, pub rounded: u8, pub border_width: u8, pub flex_flags: u8, }
Expand description

紧凑位域样式结构体(严格 24 字节)。

Fields§

§width: Length

宽度策略(4 Bytes)。

§height: Length

高度策略(4 Bytes)。

§padding: Edges<i8>

四周内边距(4 Bytes)。

§bg: Color

背景填充色(4 Bytes)。

§border_color: Color

边框颜色(4 Bytes)。

§gap: i8

子节点间距(1 Byte)。

§rounded: u8

圆角半径 0..=127px(1 Byte)。

§border_width: u8

边框宽度(1 Byte)。

§flex_flags: u8

位域:flex_dir(1b) | justify(3b) | items_align(2b) | flex_grow(2b)(1 Byte)。

Implementations§

Source§

impl Style

Source

pub const DEFAULT: Self

全零默认值样式常量(供所有组件 const fn new 零成本初始化)。

Source

pub const fn new() -> Self

构造全默认样式。

Source

pub fn set_row(&mut self)

设置水平主轴 Row。

Source

pub fn set_col(&mut self)

设置垂直主轴 Col。

Source

pub const fn flex_dir(&self) -> FlexDir

读取主轴方向。

Source

pub fn set_justify(&mut self, justify: Justify)

设置主轴对齐方式。

Source

pub fn set_justify_center(&mut self)

设置主轴居中对齐。

Source

pub fn set_justify_between(&mut self)

设置主轴两端对齐。

Source

pub const fn justify(&self) -> Justify

读取主轴对齐方式。

Source

pub fn set_items_align(&mut self, align: AlignItems)

设置交叉轴对齐方式。

Source

pub fn set_items_center(&mut self)

设置交叉轴居中对齐。

Source

pub const fn items_align(&self) -> AlignItems

读取交叉轴对齐方式。

Source

pub fn set_grow(&mut self, weight: u8)

设置弹性拉伸权重(0..=3)。

Source

pub const fn flex_grow(&self) -> u8

读取弹性拉伸权重(0..=3)。

Source

pub const fn rounded_radius(&self) -> u8

读取圆角半径(0..=127px,剥离最高位 flex_wrap 标志)。

Source

pub fn set_rounded(&mut self, radius: u8)

设置圆角半径(0..=127px,保留最高位 flex_wrap 标志)。

Source

pub const fn flex_wrap(&self) -> bool

是否启用多行自动折行(flex_wrap,存储在 rounded 的第 7 位)。

Source

pub fn set_flex_wrap(&mut self, wrap: bool)

设置多行自动折行(flex_wrap)。

Source

pub const fn border_px(&self) -> u8

读取边框宽度(0..=15px,存储在 border_width 低 4 位)。

Source

pub fn set_border_px(&mut self, width: u8)

设置边框宽度(0..=15px)。

Source

pub const fn margin_px(&self) -> i8

读取四边统一外边距(0..=15px,存储在 border_width 高 4 位)。

Source

pub fn set_margin_px(&mut self, px: i8)

设置四边统一外边距(0..=15px)。

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Style

Source§

impl Debug for Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Self

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

impl Eq for Style

Source§

impl PartialEq for Style

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Forget for Style

§

impl Freeze for Style

§

impl Move for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

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

fn try_from(value: U) -> Result<T, !>

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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,