From c1ca4c591bf0ae7aeb83f8c90412ee340f910e0c 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/resources/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 | 36 +++++++++++++++++-- fitnesstrax/app/src/main.rs | 3 ++ 8 files changed, 56 insertions(+), 3 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 2f58d54..86b0eca 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/resources/gresources.xml b/fitnesstrax/app/resources/gresources.xml index a597670..4eafed7 100644 --- a/fitnesstrax/app/resources/gresources.xml +++ b/fitnesstrax/app/resources/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 2494a62..b121a4c 100644 --- a/fitnesstrax/app/src/components/day.rs +++ b/fitnesstrax/app/src/components/day.rs @@ -228,12 +228,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 } @@ -288,3 +287,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 1e86d60..b423a65 100644 --- a/fitnesstrax/app/src/main.rs +++ b/fitnesstrax/app/src/main.rs @@ -60,6 +60,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()); });