From 525cc88c2591cfaf9c1dcf48b2574fca7b6031d7 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 25 Jan 2024 09:03:55 -0500 Subject: [PATCH] Add buttons with icons to represent workouts --- fitnesstrax/app/Cargo.toml | 1 + fitnesstrax/app/gresources.xml | 7 ++++ .../app/resources/resources.gresource.xml | 6 ++++ .../app/resources/running-symbolic.svg | 2 ++ .../app/resources/walking2-symbolic.svg | 2 ++ fitnesstrax/app/src/app_window.rs | 2 +- fitnesstrax/app/src/components/day.rs | 35 ++++++++++++++++++- fitnesstrax/app/src/main.rs | 3 ++ 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 fitnesstrax/app/resources/resources.gresource.xml create mode 100644 fitnesstrax/app/resources/running-symbolic.svg create mode 100644 fitnesstrax/app/resources/walking2-symbolic.svg diff --git a/fitnesstrax/app/Cargo.toml b/fitnesstrax/app/Cargo.toml index 1a1de9e..e7bcbc1 100644 --- a/fitnesstrax/app/Cargo.toml +++ b/fitnesstrax/app/Cargo.toml @@ -15,6 +15,7 @@ emseries = { path = "../../emseries" } ft-core = { path = "../core" } gio = { version = "0.18" } glib = { version = "0.18" } +gdk = { version = "0.7", package = "gdk4" } gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] } thiserror = { version = "1.0" } tokio = { version = "1.34", features = [ "full" ] } diff --git a/fitnesstrax/app/gresources.xml b/fitnesstrax/app/gresources.xml index a597670..4eafed7 100644 --- a/fitnesstrax/app/gresources.xml +++ b/fitnesstrax/app/gresources.xml @@ -3,4 +3,11 @@ style.css + + walking2-symbolic.svg + + + + running-symbolic.svg + diff --git a/fitnesstrax/app/resources/resources.gresource.xml b/fitnesstrax/app/resources/resources.gresource.xml new file mode 100644 index 0000000..67e604b --- /dev/null +++ b/fitnesstrax/app/resources/resources.gresource.xml @@ -0,0 +1,6 @@ + + + + start-here-symbolic.svg + + \ No newline at end of file diff --git a/fitnesstrax/app/resources/running-symbolic.svg b/fitnesstrax/app/resources/running-symbolic.svg new file mode 100644 index 0000000..89eba11 --- /dev/null +++ b/fitnesstrax/app/resources/running-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/fitnesstrax/app/resources/walking2-symbolic.svg b/fitnesstrax/app/resources/walking2-symbolic.svg new file mode 100644 index 0000000..c43dc8b --- /dev/null +++ b/fitnesstrax/app/resources/walking2-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/fitnesstrax/app/src/app_window.rs b/fitnesstrax/app/src/app_window.rs index 75f6dbb..69218f8 100644 --- a/fitnesstrax/app/src/app_window.rs +++ b/fitnesstrax/app/src/app_window.rs @@ -54,7 +54,7 @@ impl AppWindow { let window = adw::ApplicationWindow::builder() .application(adw_app) .width_request(800) - .height_request(600) + .height_request(746) .build(); let stylesheet = String::from_utf8( diff --git a/fitnesstrax/app/src/components/day.rs b/fitnesstrax/app/src/components/day.rs index ce6ed28..025235a 100644 --- a/fitnesstrax/app/src/components/day.rs +++ b/fitnesstrax/app/src/components/day.rs @@ -230,11 +230,11 @@ impl DayEdit { let s: Self = Object::builder().build(); s.set_orientation(gtk::Orientation::Vertical); s.set_hexpand(true); - *s.imp().on_finished.borrow_mut() = Box::new(on_finished); s.append(&control_buttons(&s, &view_model)); s.append(&weight_and_steps_row(&view_model)); + s.append(&workout_buttons()); s } @@ -293,3 +293,36 @@ fn weight_and_steps_row(view_model: &DayDetailViewModel) -> gtk::Box { row } + +fn workout_buttons() -> gtk::Box { + let sunrise_button = gtk::Button::builder() + .icon_name("daytime-sunrise-symbolic") + .width_request(64) + .height_request(64) + .build(); + + let walking_button = gtk::Button::builder() + .icon_name("walking2-symbolic") + .width_request(64) + .height_request(64) + .build(); + + let running_button = gtk::Button::builder() + .icon_name("running-symbolic") + .width_request(64) + .height_request(64) + .build(); + + let layout = gtk::Box::builder() + .orientation(gtk::Orientation::Vertical) + .build(); + let row = gtk::Box::builder() + .orientation(gtk::Orientation::Horizontal) + .build(); + row.append(&sunrise_button); + row.append(&walking_button); + row.append(&running_button); + layout.append(&row); + + layout +} diff --git a/fitnesstrax/app/src/main.rs b/fitnesstrax/app/src/main.rs index 316bfa6..bbad804 100644 --- a/fitnesstrax/app/src/main.rs +++ b/fitnesstrax/app/src/main.rs @@ -62,6 +62,9 @@ fn main() { .build(); adw_app.connect_activate(move |adw_app| { + let icon_theme = gtk::IconTheme::for_display(&gdk::Display::default().unwrap()); + icon_theme.add_resource_path(&(RESOURCE_BASE_PATH.to_owned() + "/icons/scalable/actions")); + AppWindow::new(app_id, RESOURCE_BASE_PATH, adw_app, ft_app.clone()); });