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: BackgroundTypeType of background to display.
要显示的背景类型。
text_config: TextConfigConfig for the main text display.
主文本显示的配置。
hint_text_config: TextConfigConfig for the hint text display.
提示文本显示的配置。
enable_animation: [bool; 2]Enable animations for hover and click: [hover, click].
启用悬停动画和单击动画:[hover, click]。
state_amount: u32Total number of possible switch states.
开关可能的状态总数。
click_method: Vec<SwitchClickConfig>Configs for click interactions.
单击交互的配置。
enable: boolWhether the switch is enabled (disabled shows but not interactive).
开关是否启用(disabled会显示,但无法交互)。
state: u32Current state of the switch.
开关当前状态。
last_frame_hovered: boolWhether the mouse was hovering in the previous frame.
鼠标是否在前一帧中悬停。
last_frame_clicked: Option<usize>Click method from the previous frame, if any.
前一帧中的单击方法(如果有的话)。
switched: boolWhether the switch was toggled.
开关是否被切换。
If true, resources created by the switch use its tags.
如果为true,则开关创建的资源使用其标签。
Key-value pairs for categorization and metadata.
用于分类和元数据的键值对标签。
Implementations§
Source§impl Switch
impl Switch
pub fn appearance(self, appearance: &[SwitchAppearanceConfig]) -> Self
pub fn background_type(self, background_type: &BackgroundType) -> Self
pub fn text_config(self, text_config: &TextConfig) -> Self
pub fn hint_text_config(self, hint_text_config: &TextConfig) -> Self
pub fn enable_animation(self, enable_hover: bool, enable_click: bool) -> Self
pub fn state_amount(self, state_amount: u32) -> Self
pub fn click_method(self, click_method: Vec<SwitchClickConfig>) -> Self
pub fn enable(self, enable: bool) -> Self
Trait Implementations§
Source§impl RustConstructorResource for Switch
impl RustConstructorResource for Switch
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Any for extract the specific type. Read moreSource§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Any for extract the specific type. Read moreSource§fn display_display_info(&self) -> Option<DisplayInfo>
fn display_display_info(&self) -> Option<DisplayInfo>
Source§fn modify_display_info(&mut self, _display_info: DisplayInfo)
fn modify_display_info(&mut self, _display_info: DisplayInfo)
impl StructuralPartialEq for Switch
Auto Trait Implementations§
impl Freeze for Switch
impl !RefUnwindSafe for Switch
impl Send for Switch
impl Sync for Switch
impl Unpin for Switch
impl UnsafeUnpin for Switch
impl !UnwindSafe for Switch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().