From e1a397c192ed91f9cac03a56d607976e68017ac4 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 17 Nov 2024 06:54:57 -0600 Subject: [PATCH] composed the view better to use same data for preview and present --- src/main.rs | 16 +++++++++------- src/ui/presenter.rs | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index bc5a243..b3fbac2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -478,10 +478,7 @@ impl cosmic::Application for App { // Main window view fn view(&self) -> Element { debug!("Main view"); - let preview = presenter::slide_view( - &self.current_slide, - &self.preview_video, - ); + let preview = self.presenter.view(); let icon_left = icon::from_name("arrow-left"); let icon_right = icon::from_name("arrow-right"); let row = row![ @@ -497,7 +494,13 @@ impl cosmic::Application for App { .center_y(Length::Fill) .align_right(Length::Fill) .width(Length::FillPortion(1)), - preview.width(Length::FillPortion(3)), + Container::new( + Container::new(preview.map(|m| Message::Present(m))) + .center(Length::Fill) + .max_height(270) + ) + .center_y(Length::Fill) + .width(Length::FillPortion(3)), Container::new( button::icon(icon_right) .icon_size(128) @@ -520,8 +523,7 @@ impl cosmic::Application for App { // View for presentation fn view_window(&self, _id: window::Id) -> Element { debug!("window"); - presenter::slide_view(&self.current_slide, &self.active_video) - .into() + self.presenter.view().map(|m| Message::Present(m)) } } diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 2075c8b..43fd5fb 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -130,10 +130,10 @@ impl Presenter { } } }; - let stack = stack!(container, text) + stack!(container, text) .width(Length::Fill) - .height(Length::Fill); - stack.into() + .height(Length::Fill) + .into() } }