mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add widget egui::reset_button
This commit is contained in:
@@ -106,7 +106,7 @@ impl DemoWindow {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[derive(PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)]
|
||||
struct ColorWidgets {
|
||||
srgba_unmul: [u8; 4],
|
||||
@@ -129,9 +129,7 @@ impl Default for ColorWidgets {
|
||||
|
||||
impl ColorWidgets {
|
||||
fn ui(&mut self, ui: &mut Ui) {
|
||||
if ui.button("Reset").clicked {
|
||||
*self = Default::default();
|
||||
}
|
||||
egui::reset_button(ui, self);
|
||||
|
||||
ui.label("Egui lets you edit colors stored as either sRGBA or linear RGBA and with or without premultiplied alpha");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use egui::*;
|
||||
use std::f64::INFINITY;
|
||||
|
||||
/// Showcase sliders
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[derive(PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct Sliders {
|
||||
pub min: f64,
|
||||
@@ -108,8 +108,6 @@ impl Sliders {
|
||||
ui.checkbox(smart_aim, "Smart Aim");
|
||||
ui.label("Smart Aim will guide you towards round values when you drag the slider so you you are more likely to hit 250 than 247.23");
|
||||
|
||||
if ui.button("Reset slider demo").clicked {
|
||||
*self = Default::default();
|
||||
}
|
||||
egui::reset_button(ui, self);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user