1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Memory usage example in the widget gallery (#307)

* init example

* add comments

* fix grammar in comments

* fix CI

* change example from view_edit to password

* rename file

* fix CI
This commit is contained in:
ilya sheprut
2021-04-18 14:13:08 +06:00
committed by GitHub
parent 580d27e0d3
commit c69ecfe421
3 changed files with 133 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ pub struct WidgetGallery {
scalar: f32,
string: String,
color: egui::Color32,
memory_example: String,
}
impl Default for WidgetGallery {
@@ -25,6 +26,7 @@ impl Default for WidgetGallery {
scalar: 42.0,
string: Default::default(),
color: egui::Color32::LIGHT_BLUE.linear_multiply(0.5),
memory_example: "qwerty_is_bad_password".to_owned(),
}
}
}
@@ -86,6 +88,7 @@ impl WidgetGallery {
scalar,
string,
color,
memory_example,
} = self;
ui.set_enabled(*enabled);
@@ -201,6 +204,19 @@ impl WidgetGallery {
This toggle switch is just 15 lines of code.",
);
ui.end_row();
ui.hyperlink_to(
"egui::Memory usage:",
super::password::url_to_file_source_code(),
)
.on_hover_text(
"You can use `egui::Memory` to store your own data.\n\
And state of this widget can be saved and loaded \n\
between runs automatically under the `persistence`\n\
feature.",
);
ui.add(super::password::password(memory_example, "memory example"));
ui.end_row();
}
}