Skip to main content

Switch

Struct Switch 

Source
pub struct Switch {
Show 14 fields pub appearance: Vec<SwitchAppearanceConfig>, pub background_type: BackgroundType, pub text_config: TextConfig, pub hint_text_config: TextConfig, pub enable_animation: [bool; 2], pub state_amount: u32, pub click_method: Vec<SwitchClickConfig>, pub enable: bool, pub state: u32, pub last_frame_hovered: bool, pub last_frame_clicked: Option<usize>, pub switched: bool, pub use_switch_tags: bool, pub tags: Vec<[String; 2]>,
}
Expand description

Switch resource for toggleable UI elements.

用于可切换UI元素的开关资源。

Fields§

§appearance: Vec<SwitchAppearanceConfig>

Appearance configs for each state combination.

每个状态组合的外观配置。

§background_type: BackgroundType

Type of background to display.

要显示的背景类型。

§text_config: TextConfig

Config for the main text display.

主文本显示的配置。

§hint_text_config: TextConfig

Config for the hint text display.

提示文本显示的配置。

§enable_animation: [bool; 2]

Enable animations for hover and click: [hover, click].

启用悬停动画和单击动画:[hover, click]。

§state_amount: u32

Total number of possible switch states.

开关可能的状态总数。

§click_method: Vec<SwitchClickConfig>

Configs for click interactions.

单击交互的配置。

§enable: bool

Whether the switch is enabled (disabled shows but not interactive).

开关是否启用(disabled会显示,但无法交互)。

§state: u32

Current state of the switch.

开关当前状态。

§last_frame_hovered: bool

Whether the mouse was hovering in the previous frame.

鼠标是否在前一帧中悬停。

§last_frame_clicked: Option<usize>

Click method from the previous frame, if any.

前一帧中的单击方法(如果有的话)。

§switched: bool

Whether the switch was toggled.

开关是否被切换。

§use_switch_tags: bool

If true, resources created by the switch use its tags.

如果为true,则开关创建的资源使用其标签。

§tags: Vec<[String; 2]>

Key-value pairs for categorization and metadata.

用于分类和元数据的键值对标签。

Implementations§

Source§

impl Switch

Source

pub fn appearance(self, appearance: &[SwitchAppearanceConfig]) -> Self

Source

pub fn background_type(self, background_type: &BackgroundType) -> Self

Source

pub fn text_config(self, text_config: &TextConfig) -> Self

Source

pub fn hint_text_config(self, hint_text_config: &TextConfig) -> Self

Source

pub fn enable_animation(self, enable_hover: bool, enable_click: bool) -> Self

Source

pub fn state_amount(self, state_amount: u32) -> Self

Source

pub fn click_method(self, click_method: Vec<SwitchClickConfig>) -> Self

Source

pub fn enable(self, enable: bool) -> Self

Source

pub fn use_switch_tags(self, use_switch_tags: bool) -> Self

Source

pub fn tags(self, tags: &[[String; 2]], replace: bool) -> Self

Trait Implementations§

Source§

impl Clone for Switch

Source§

fn clone(&self) -> Switch

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 Switch

Source§

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

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

impl Default for Switch

Source§

fn default() -> Self

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

impl PartialEq for Switch

Source§

fn eq(&self, other: &Switch) -> 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 RustConstructorResource for Switch

Source§

fn as_any(&self) -> &dyn Any

Returns a reference to the resource as Any for extract the specific type. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to the resource as Any for extract the specific type. Read more
Source§

fn display_display_info(&self) -> Option<DisplayInfo>

Retrieves the display info field for this resource. Read more
Source§

fn modify_display_info(&mut self, _display_info: DisplayInfo)

Updates the display info field for this resource. Read more
Source§

fn display_tags(&self) -> Vec<[String; 2]>

Returns all tags associated with this resource. Read more
Source§

fn modify_tags(&mut self, tags: &[[String; 2]], replace: bool)

Updates the tags for this resource. Read more
Source§

impl StructuralPartialEq for Switch

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

Source§

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

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

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

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

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

Source§

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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,