Skip to main content

HoldSettings

Struct HoldSettings 

Source
pub struct HoldSettings {
Show 15 fields pub open: bool, pub seconds: f32, pub fill_from: Option<Color32>, pub fill_to: Option<Color32>, pub burst: HoldBurst, pub burst_color: Option<Color32>, pub burst_intensity: f32, pub burst_ms: f32, pub burst_bolts: usize, pub burst_branch_depth: u32, pub burst_thickness: f32, pub burst_jitter: f32, pub burst_glow_from: f32, pub burst_glow_to: f32, pub burst_glow_softness: f32,
}
Expand description

Knobs for a hold-to-confirm button: the hold duration, the progressive fill and the completion burst.

Button::hold_settings replaces the whole configuration at once; the per-field shortcuts Button::hold, Button::hold_fill and Button::hold_burst compose field by field instead.

The defaults reproduce the look of a button that configures nothing: a 1 s hold, the theme’s accent colour, and a 300 ms HoldBurst::Glow burst.

With the serde feature enabled the whole struct is serializable, so a host can persist it as part of its own settings instead of copying each knob. Deserialization ignores unknown fields (serde’s default) and fills missing ones from HoldSettings::default, so a file written before a knob existed still loads and that knob takes its default — which is what lets a host persist this type across crate upgrades. Self::open is serialized like every other field; a host that owns the settings window sets it to false after loading.

Fields§

§open: bool

Settings-window visibility. Default false (the example opens it).

Button ignores this field; it exists so a host can keep one settings value for both the window and the buttons.

§seconds: f32

Hold duration in seconds; 0.0 or less means “not a hold button”.

Default 1.0.

§fill_from: Option<Color32>

Sweep colour at the start of the hold, or None for the installed theme’s colors.accent.

Default None.

§fill_to: Option<Color32>

Sweep colour at completion. When Some, the sweep shifts from Self::fill_from towards this colour as the hold fills; None keeps it solid.

Default None.

§burst: HoldBurst

Completion effect. Default HoldBurst::Glow.

§burst_color: Option<Color32>

Burst colour, or None for the resolved fill colour at completion.

Default None.

§burst_intensity: f32

Multiplier over the effect’s own profile, in 0.0..=1.0. 0.0 disables the burst entirely.

Default 1.0.

§burst_ms: f32

Burst duration in milliseconds. Default 300.0.

§burst_bolts: usize

Number of bolts for a HoldBurst::Lightning burst; ignored by the other kinds.

Default 1.

§burst_branch_depth: u32

Branch recursion depth for a HoldBurst::Lightning burst (0 draws the trunk only); ignored by the other kinds.

Default 1.

§burst_thickness: f32

Core stroke thickness of a HoldBurst::Lightning burst, in pixels; ignored by the other kinds.

Default 2.0, the LightningSettings::default value (see DEFAULT_THICKNESS in widgets/particles/lightning/effect.rs).

§burst_jitter: f32

Midpoint-displacement jitter of a HoldBurst::Lightning burst, as a fraction of each segment’s length; ignored by the other kinds.

Default 0.18, the LightningSettings::default value (see DEFAULT_JITTER in widgets/particles/lightning/effect.rs).

§burst_glow_from: f32

Radius of a HoldBurst::Glow at the start of the burst, as a multiple of the button’s shorter side; ignored by the other kinds.

Default 1.0 (HOLD_GLOW_START).

§burst_glow_to: f32

Radius of a HoldBurst::Glow at the end of the burst, as a multiple of the button’s shorter side; ignored by the other kinds.

At paint time this is clamped to at least Self::burst_glow_from, so a pair that would shrink (or a negative one) paints a constant radius instead of a shrinking band.

Default 2.2 (HOLD_GLOW_END).

§burst_glow_softness: f32

Falloff softness of a HoldBurst::Glow; ignored by the other kinds.

The shared fan keeps its hot-core ring at 0.15 of the radius and its inner ring at 0.45, carrying 0.55 and 0.18 of the colour. This knob maps each interior ring fraction r to r.powf(1.0 / softness); the rim and every alpha stay put. Values above 1.0 push the two interior rings outward, spreading the colour over a longer run to the transparent rim (a gentler falloff); values below 1.0 pull them in for a tighter, harder core. Exactly 1.0 reproduces the shared profile vertex for vertex.

Default 1.0.

Implementations§

Source§

impl HoldSettings

Source

pub fn reset(&mut self)

Knobs back to defaults; open is preserved (a reset must not close the window).

Source

pub fn show_window(&mut self, ctx: &Context) -> Option<Response>

Themed floating settings window; returns the window’s outer Response when open.

Window chrome plus a vertical scroll area around Self::body_ui, so a viewport shorter than the controls scrolls instead of clipping them.

Source

pub fn body_ui(&mut self, ui: &mut Ui)

Draw the settings controls into ui — no window chrome.

Render them in your own container (egui::Window, SidePanel, ScrollArea, …) instead of using Self::show_window. If that container can be shorter than the controls, wrap it in an egui::ScrollArea. This method never touches Self::open.

Trait Implementations§

Source§

impl Clone for HoldSettings

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 HoldSettings

Source§

impl Debug for HoldSettings

Source§

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

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

impl Default for HoldSettings

Source§

fn default() -> Self

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

impl PartialEq for HoldSettings

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 HoldSettings

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<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<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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.