pub struct OptionSelect {}Expand description
A settings row that cycles through a fixed set of values on click.
OptionSelect is a build-time shorthand for one row of a settings menu: a
left-aligned name, a right-aligned current value, and a clickable region
that advances the value. It expands into a TextLabel for the
name, a TextLabel for the value, and a HitRegion that fires a
"setting:<setting>:next" action.
The setting field names an engine setting the runtime knows how to read,
cycle, and apply (e.g. "vsync"); its option list lives in the engine, not
here. The value label shows a placeholder at build time and is corrected to
the live value when the world starts.
Generated names are prefixed with this asset’s name (<name>_label,
<name>_value, <name>_btn), so they never clash with hand-authored assets.
OptionSelect {
setting: "vsync".into(),
label: "Vsync".into(),
..Default::default()
};Fields§
§setting: StringEngine setting this row controls (e.g. "vsync"). Must be a setting the
runtime recognises; an unknown key renders but does nothing on click.
label: StringDisplay name shown at the left of the row.
x: f32Left edge of the row in window pixels.
y: f32Top edge of the row in window pixels.
width: f32Row width in window pixels (name sits at the left, value at the right).
height: f32Row height in window pixels (the clickable region’s height).
font: StringFont for the row text. Empty uses the built-in font.
font_px: f32Pixel size of the row text when it uses the built-in font (that is, when
font is empty). Ignored when font names a Font, which
carries its own size.
text_color: [f32; 3]Linear-space RGB color of the name text.
value_color: [f32; 3]Linear-space RGB color of the value text.
text_scale: f32Scale applied to the row text.
hover_color: [f32; 3]RGB color of the value text while the row is hovered.
hover_scale: f32Scale of the value text while the row is hovered.
stepper_width: f32Width in pixels of the < previous-value click region. The >
next-value region spans the rest of the row’s right half (the value
sits inside it), so a click on the value advances to the next option.
Trait Implementations§
Source§impl Authored for OptionSelect
impl Authored for OptionSelect
impl BuildOnlyAsset for OptionSelect
Source§impl Clone for OptionSelect
impl Clone for OptionSelect
Source§fn clone(&self) -> OptionSelect
fn clone(&self) -> OptionSelect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OptionSelect
impl Debug for OptionSelect
Source§impl Default for OptionSelect
impl Default for OptionSelect
Source§impl<'de> Deserialize<'de> for OptionSelectwhere
OptionSelect: Default,
impl<'de> Deserialize<'de> for OptionSelectwhere
OptionSelect: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for OptionSelect
impl RefUnwindSafe for OptionSelect
impl Send for OptionSelect
impl Sync for OptionSelect
impl Unpin for OptionSelect
impl UnsafeUnpin for OptionSelect
impl UnwindSafe for OptionSelect
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more