aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-01-19 14:40:59 -0330
committerSam Anthony <sam@samanthony.xyz>2023-01-19 14:40:59 -0330
commitb16b909074691c5d528774827b43c66cefc5f865 (patch)
tree265d5d564520e98cd8da1bc8b7914ea894b52eef /src/main.rs
parent74c5641b7a46c02e999f1e0cf506c983ede37995 (diff)
downloadvolute-b16b909074691c5d528774827b43c66cefc5f865.zip
use Volume in text_input widget
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 9bf6c51..2872fcf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,13 +3,14 @@ use iced::{
Element, Sandbox, Settings,
};
+use volute::volume::{CubicMetre, Volume};
+
pub fn main() -> iced::Result {
App::run(Settings::default())
}
-#[derive(Default)]
struct App {
- displacement: f64,
+ displacement: Box<dyn Volume>,
ui: UI,
}
@@ -21,11 +22,21 @@ struct UI {
impl App {
fn set_displacement(&mut self, displacement: &str) {
if displacement.len() == 0 {
- self.displacement = 0.;
+ self.displacement.set(0.0);
+ self.ui.displacement = "".to_string();
} else if let Ok(d) = displacement.parse::<f64>() {
- self.displacement = d;
+ self.displacement.set(d);
+ self.ui.displacement = String::from(displacement);
+ }
+ }
+}
+
+impl Default for App {
+ fn default() -> Self {
+ Self {
+ displacement: Box::new(CubicMetre::default()),
+ ui: UI::default(),
}
- self.ui.displacement = String::from(displacement);
}
}