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: boolSettings-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: f32Hold 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: HoldBurstCompletion effect. Default HoldBurst::Glow.
burst_color: Option<Color32>Burst colour, or None for the resolved fill colour at completion.
Default None.
burst_intensity: f32Multiplier over the effect’s own profile, in 0.0..=1.0. 0.0 disables
the burst entirely.
Default 1.0.
burst_ms: f32Burst duration in milliseconds. Default 300.0.
burst_bolts: usizeNumber of bolts for a HoldBurst::Lightning burst; ignored by the other
kinds.
Default 1.
burst_branch_depth: u32Branch recursion depth for a HoldBurst::Lightning burst (0 draws the
trunk only); ignored by the other kinds.
Default 1.
burst_thickness: f32Core 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: f32Midpoint-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: f32Radius 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: f32Radius 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: f32Falloff 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
impl HoldSettings
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Knobs back to defaults; open is preserved (a reset must not close the window).
Sourcepub fn show_window(&mut self, ctx: &Context) -> Option<Response>
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.
Sourcepub fn body_ui(&mut self, ui: &mut Ui)
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
impl Clone for HoldSettings
impl Copy for HoldSettings
Source§impl Debug for HoldSettings
impl Debug for HoldSettings
Source§impl Default for HoldSettings
impl Default for HoldSettings
Source§impl PartialEq for HoldSettings
impl PartialEq for HoldSettings
impl StructuralPartialEq for HoldSettings
Auto Trait Implementations§
impl Freeze for HoldSettings
impl RefUnwindSafe for HoldSettings
impl Send for HoldSettings
impl Sync for HoldSettings
impl Unpin for HoldSettings
impl UnsafeUnpin for HoldSettings
impl UnwindSafe for HoldSettings
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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