From aae3a8398fe91bd19c5f8d41bcdcefe941387e54 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 7 Oct 2024 10:38:31 -0600 Subject: [PATCH] Use popover for controls --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 6 +++++- src/gstreamer/mod.rs | 40 ++++++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec913ff..4c98711 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "quote", "syn 1.0.109", @@ -1220,7 +1220,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "almost", "cosmic-config", @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "dnd", "iced_accessibility", @@ -2724,7 +2724,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "accesskit", "accesskit_winit", @@ -2733,7 +2733,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "bitflags 2.6.0", "dnd", @@ -2753,7 +2753,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "futures", "iced_core", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -2790,7 +2790,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2802,7 +2802,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "dnd", "iced_core", @@ -2814,7 +2814,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "iced_core", "once_cell", @@ -2824,7 +2824,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "bytemuck", "cosmic-text", @@ -2857,7 +2857,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2886,7 +2886,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "dnd", "iced_renderer", @@ -2902,7 +2902,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "dnd", "iced_graphics", @@ -3219,7 +3219,7 @@ checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#173a9557c2f03bc5fda132e884c11bf8661256ff" +source = "git+https://github.com/pop-os/libcosmic.git#93578816f9a3ac6aeb24d6f3223d43e3f228d106" dependencies = [ "apply", "ashpd 0.9.1", diff --git a/Cargo.toml b/Cargo.toml index c1c49db..f9ca92a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ optional = true git = "https://github.com/pop-os/libcosmic.git" default-features = false features = ["tokio", "winit"] -#path = "../libcosmic" [dependencies.smol_str] version = "0.2.1" @@ -45,3 +44,8 @@ wgpu = ["libcosmic/wgpu"] [profile.release-with-debug] inherits = "release" debug = true + +# [patch.'https://github.com/pop-os/libcosmic'] +# libcosmic = { path = "../libcosmic" } +# cosmic-config = { path = "../libcosmic/cosmic-config" } +# cosmic-theme = { path = "../libcosmic/cosmic-theme" } diff --git a/src/gstreamer/mod.rs b/src/gstreamer/mod.rs index a4d4874..46d8747 100644 --- a/src/gstreamer/mod.rs +++ b/src/gstreamer/mod.rs @@ -12,7 +12,7 @@ use cosmic::{ window, Alignment, Color, Length, Limits, Size, }, theme, - widget::{self, Column, Row, Slider}, + widget::{self, Slider}, Application, ApplicationExt, Element, }; use iced_video_player::{ @@ -434,25 +434,27 @@ impl Application for App { format!("{:02}:{:02}:{:02}", hours, minutes, seconds) }; - let mut column = widget::column::with_capacity(4); - column = column.push(widget::vertical_space(Length::Fill)); - if let Some(video) = &self.video_opt { - column = column.push( - VideoPlayer::new(video) - .on_end_of_stream(Message::EndOfStream) - .on_missing_plugin(Message::MissingPlugin) - .on_new_frame(Message::NewFrame) - .width(Length::Fill) - .height(Length::Fill), - ); - } - //TODO: open button if no video? - column = column.push(widget::vertical_space(Length::Fill)); + let Some(video) = &self.video_opt else { + //TODO: open button if no video? + return widget::container(widget::text("No video open")) + .width(Length::Fill) + .height(Length::Fill) + .style(theme::Container::WindowBackground) + .into(); + }; + let video_player = VideoPlayer::new(video) + .on_end_of_stream(Message::EndOfStream) + .on_missing_plugin(Message::MissingPlugin) + .on_new_frame(Message::NewFrame) + .width(Length::Fill) + .height(Length::Fill); + + let mut popover = widget::popover(video_player).position(widget::popover::Position::Bottom); if !self.fullscreen { - column = column.push( + popover = popover.popup( widget::container( - Row::new() + widget::row::with_capacity(4) .align_items(Alignment::Center) .spacing(8) .padding([0, 8]) @@ -483,7 +485,9 @@ impl Application for App { ); } - widget::container(column) + widget::container(popover) + .width(Length::Fill) + .height(Length::Fill) .style(theme::Container::Custom(Box::new(|_theme| { widget::container::Appearance::default().with_background(Color::BLACK) })))