From 54c264f55d31853d5a6a165efafc056cc80280bc Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 22 Nov 2024 16:46:25 -0600 Subject: [PATCH] move the slider as video is playing --- src/main.rs | 64 ++++++++++++++++++++++++++++----------------- src/ui/presenter.rs | 11 ++++++++ 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/main.rs b/src/main.rs index 830f4dd..d8a449b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -183,11 +183,34 @@ impl cosmic::Application for App { Some(&self.nav_model) } - fn nav_bar( - &self, - ) -> Option>> { - None - } + // fn nav_bar( + // &self, + // ) -> Option>> { + // if !self.core().nav_bar_active() { + // return None; + // } + + // let nav_model = self.nav_model()?; + + // let mut nav = cosmic::widget::nav_bar(nav_model, |id| { + // cosmic::app::Message::Cosmic(cosmic::Message::NavBar(id)) + // }) + // .on_context(|id| { + // Message::Cosmic(cosmic::Message::NavBarContext(id)) + // }) + // .context_menu( + // self.nav_context_menu(self.core.nav_bar_context()), + // ) + // .into_container() + // // XXX both must be shrink to avoid flex layout from ignoring it + // .width(iced::Length::Shrink) + // .height(iced::Length::Shrink); + + // if !self.core().is_condensed() { + // nav = nav.max_width(280); + // } + // Some(nav.into()) + // } /// Called when a navigation item is selected. fn on_nav_select( @@ -411,7 +434,6 @@ impl cosmic::Application for App { // Main window view fn view(&self) -> Element { - debug!("Main view"); let icon_left = icon::from_name("arrow-left"); let icon_right = icon::from_name("arrow-right"); @@ -423,13 +445,6 @@ impl cosmic::Application for App { 0.0 }; - let video_pos = if let Some(video) = &self.presenter.video { - let range = video.position(); - range.as_secs_f32() - } else { - 0.0 - }; - let video_button_icon = if let Some(video) = &self.presenter.video { if video.paused() { @@ -456,9 +471,7 @@ impl cosmic::Application for App { let slide_preview = column![ Space::with_height(Length::Fill), Responsive::new(|size| { - debug!(?size); let height = size.width * 9.0 / 16.0; - debug!(?height); Container::new( Container::new( self.presenter @@ -473,15 +486,18 @@ impl cosmic::Application for App { Container::new(if self.presenter.video.is_some() { row![ video_button_icon, - Container::new(slider( - 0.0..=video_range, - video_pos, - |pos| { - Message::Present( - presenter::Message::VideoPos(pos), - ) - } - )) + Container::new( + slider( + 0.0..=video_range, + self.presenter.video_position, + |pos| { + Message::Present( + presenter::Message::VideoPos(pos), + ) + } + ) + .step(0.1) + ) .center_x(Length::Fill) .padding([7, 0, 0, 0]) ] diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index fa22521..d64ef26 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -24,6 +24,7 @@ pub(crate) struct Presenter { pub current_slide: Slide, pub current_slide_index: u16, pub video: Option