diff --git a/src/app.rs b/src/app.rs index 559d4f7..99b1521 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,9 @@ use egui::Align2; use egui_toast::{Toasts}; +use std::{ + sync::{Arc, Mutex}, + time::Duration, +}; /// We derive Deserialize/Serialize so we can persist app state on shutdown. #[derive(serde::Deserialize, serde::Serialize)] @@ -12,6 +16,8 @@ pub struct TwoDBApp { value: f32, pub(crate) is_busy: bool, // This field is for Spinner + + pub field: Arc>, } impl Default for TwoDBApp { @@ -21,6 +27,7 @@ impl Default for TwoDBApp { label: "Hello World! 2".to_owned(), value: 2.6, is_busy: false, + field: Arc::new(Mutex::new(0)), } } } @@ -87,6 +94,12 @@ impl eframe::App for TwoDBApp { // The central panel the region left after adding TopPanel's and SidePanel's ui.heading("Clean Tables"); + ui.horizontal(|ui| { + ui.label( + format!("{}", self.field.lock().unwrap()) + ); + }); + ui.horizontal(|ui| { ui.label("Write something: "); ui.text_edit_singleline(&mut self.label); diff --git a/src/widgets/update_empty_tables_button.rs b/src/widgets/update_empty_tables_button.rs index 0f077ce..68060c3 100644 --- a/src/widgets/update_empty_tables_button.rs +++ b/src/widgets/update_empty_tables_button.rs @@ -16,7 +16,9 @@ impl TwoDBApp { } fn get_empty_tables_event(&mut self) { + let field = self.field.clone(); thread::spawn(move || { + *field.lock().unwrap() += 1; let mut thread_toasts = Toasts::new() .anchor(Align2::RIGHT_BOTTOM, (-10.0, -10.0)) // 10 units from the bottom right corner .direction(egui::Direction::BottomUp); diff --git a/src/widgets/update_tables_button.rs b/src/widgets/update_tables_button.rs index beb74d9..cbac9cb 100644 --- a/src/widgets/update_tables_button.rs +++ b/src/widgets/update_tables_button.rs @@ -5,7 +5,7 @@ use crate::working_database::{update_all_tables}; impl TwoDBApp { pub fn render_update_tables_button(&mut self, ui: &mut egui::Ui) { - if ui.button("Update Tables (not yet implemented)").clicked() { + if ui.button("Update Tables").clicked() { self.is_busy = true; ui.close_menu(); self.button_update_tables_event();