From 199235217056270215b965279b21526f22e242ec Mon Sep 17 00:00:00 2001 From: David Bliss Date: Sun, 31 Mar 2024 14:30:06 +0100 Subject: [PATCH] Add non-functional photo info panel --- src/app.rs | 2 +- src/app/components/mod.rs | 1 + src/app/components/one_photo.rs | 35 +++++++++++++++------ src/app/components/photo_info.rs | 53 ++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 src/app/components/photo_info.rs diff --git a/src/app.rs b/src/app.rs index 51e0a76c..0e81d8e4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -252,7 +252,7 @@ impl SimpleComponent for App { }); let one_photo = OnePhoto::builder() - .launch(repo.clone()) + .launch((scan.clone(), repo.clone())) .detach(); let about_dialog = AboutDialog::builder() diff --git a/src/app/components/mod.rs b/src/app/components/mod.rs index 034fc18c..b9df3e52 100644 --- a/src/app/components/mod.rs +++ b/src/app/components/mod.rs @@ -7,3 +7,4 @@ pub mod all_photos; pub mod month_photos; pub mod year_photos; pub mod one_photo; +pub mod photo_info; diff --git a/src/app/components/one_photo.rs b/src/app/components/one_photo.rs index 172bece7..c5d15f06 100644 --- a/src/app/components/one_photo.rs +++ b/src/app/components/one_photo.rs @@ -9,6 +9,8 @@ use relm4::gtk::prelude::WidgetExt; use relm4::*; use std::sync::{Arc, Mutex}; +use crate::app::components::photo_info::PhotoInfo; + #[derive(Debug)] pub enum OnePhotoInput { ViewPhoto(PictureId), @@ -17,12 +19,14 @@ pub enum OnePhotoInput { #[derive(Debug)] pub struct OnePhoto { repo: Arc>, + photo_info: Controller, picture: gtk::Picture, + } #[relm4::component(pub)] impl SimpleComponent for OnePhoto { - type Init = Arc>; + type Init = (photos_core::Scanner, Arc>); type Input = OnePhotoInput; type Output = (); @@ -31,33 +35,44 @@ impl SimpleComponent for OnePhoto { add_top_bar = &adw::HeaderBar, #[wrap(Some)] - set_content = >k::Box { - set_orientation: gtk::Orientation::Vertical, + set_content = &adw::OverlaySplitView { + #[wrap(Some)] + set_sidebar = model.photo_info.widget(), + + set_sidebar_position: gtk::PackType::End, + + #[wrap(Some)] + set_content = >k::Box { + set_orientation: gtk::Orientation::Vertical, - #[local_ref] - picture -> gtk::Picture { - set_can_shrink: true, - set_valign: gtk::Align::Center, + #[local_ref] + picture -> gtk::Picture { + set_can_shrink: true, + set_valign: gtk::Align::Center, + } } } } } fn init( - repo: Self::Init, + (scanner, repo): Self::Init, _root: Self::Root, _sender: ComponentSender, ) -> ComponentParts { let picture = gtk::Picture::new(); - let widgets = view_output!(); + let photo_info = PhotoInfo::builder().launch(scanner).detach(); let model = OnePhoto { repo, - picture, + picture: picture.clone(), + photo_info, }; + let widgets = view_output!(); + ComponentParts { model, widgets } } diff --git a/src/app/components/photo_info.rs b/src/app/components/photo_info.rs new file mode 100644 index 00000000..4c7ca7e4 --- /dev/null +++ b/src/app/components/photo_info.rs @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: © 2024 David Bliss +// +// SPDX-License-Identifier: GPL-3.0-or-later + +use photos_core::Scanner; +use gtk::prelude::OrientableExt; +use relm4::gtk; +use relm4::*; +use relm4::adw::prelude::PreferencesRowExt; + + +#[derive(Debug)] +pub struct PhotoInfo { + scanner: Scanner, +} + + +#[relm4::component(pub)] +impl SimpleComponent for PhotoInfo { + type Init = Scanner; + type Input = (); + type Output = (); + + view! { + gtk::Box { + set_orientation: gtk::Orientation::Vertical, + + gtk::ListBox { + adw::ActionRow { + set_title: "Test Title", + } + } + } + } + + fn init( + scanner: Self::Init, + _root: Self::Root, + _sender: ComponentSender, + ) -> ComponentParts { + + let widgets = view_output!(); + + let model = PhotoInfo { + scanner, + }; + + ComponentParts { model, widgets } + } + + fn update(&mut self, msg: Self::Input, _sender: ComponentSender) {} +} +