pub struct Switch {Show 15 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 radio_group: String,
pub enable: bool,
pub state: usize,
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.
单击交互的配置。
radio_group: StringSet the single-choice grouping of the switch.
设置开关的单选分组。
Only one switch can be activated within the same single-choice group.
同一单选分组内只能有一个开关被激活。
enable: boolWhether the switch is enabled (disabled shows but not interactive).
开关是否启用(disabled会显示,但无法交互)。
state: usizeCurrent 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 radio_group(self, radio_group: &str) -> Self
pub fn enable(self, enable: bool) -> Self
pub fn state(self, state: usize) -> 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 more