Use popover for controls

This commit is contained in:
Jeremy Soller 2024-10-07 10:38:31 -06:00
parent ce59addefd
commit aae3a8398f
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
3 changed files with 43 additions and 35 deletions

32
Cargo.lock generated
View file

@ -1147,7 +1147,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config" name = "cosmic-config"
version = "0.1.0" 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 = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -1166,7 +1166,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config-derive" name = "cosmic-config-derive"
version = "0.1.0" 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 = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -1220,7 +1220,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-theme" name = "cosmic-theme"
version = "0.1.0" 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 = [ dependencies = [
"almost", "almost",
"cosmic-config", "cosmic-config",
@ -2706,7 +2706,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.12.0" 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 = [ dependencies = [
"dnd", "dnd",
"iced_accessibility", "iced_accessibility",
@ -2724,7 +2724,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_accessibility" name = "iced_accessibility"
version = "0.1.0" 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 = [ dependencies = [
"accesskit", "accesskit",
"accesskit_winit", "accesskit_winit",
@ -2733,7 +2733,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.12.0" 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 = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"dnd", "dnd",
@ -2753,7 +2753,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.12.0" 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 = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -2766,7 +2766,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.12.0" 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 = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytemuck", "bytemuck",
@ -2790,7 +2790,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.12.0" 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 = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -2802,7 +2802,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.12.0" 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 = [ dependencies = [
"dnd", "dnd",
"iced_core", "iced_core",
@ -2814,7 +2814,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.12.0" 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 = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -2824,7 +2824,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.12.0" 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 = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -2857,7 +2857,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.12.0" 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 = [ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"bitflags 2.6.0", "bitflags 2.6.0",
@ -2886,7 +2886,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.12.0" 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 = [ dependencies = [
"dnd", "dnd",
"iced_renderer", "iced_renderer",
@ -2902,7 +2902,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_winit" name = "iced_winit"
version = "0.12.0" 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 = [ dependencies = [
"dnd", "dnd",
"iced_graphics", "iced_graphics",
@ -3219,7 +3219,7 @@ checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" 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 = [ dependencies = [
"apply", "apply",
"ashpd 0.9.1", "ashpd 0.9.1",

View file

@ -30,7 +30,6 @@ optional = true
git = "https://github.com/pop-os/libcosmic.git" git = "https://github.com/pop-os/libcosmic.git"
default-features = false default-features = false
features = ["tokio", "winit"] features = ["tokio", "winit"]
#path = "../libcosmic"
[dependencies.smol_str] [dependencies.smol_str]
version = "0.2.1" version = "0.2.1"
@ -45,3 +44,8 @@ wgpu = ["libcosmic/wgpu"]
[profile.release-with-debug] [profile.release-with-debug]
inherits = "release" inherits = "release"
debug = true debug = true
# [patch.'https://github.com/pop-os/libcosmic']
# libcosmic = { path = "../libcosmic" }
# cosmic-config = { path = "../libcosmic/cosmic-config" }
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }

View file

@ -12,7 +12,7 @@ use cosmic::{
window, Alignment, Color, Length, Limits, Size, window, Alignment, Color, Length, Limits, Size,
}, },
theme, theme,
widget::{self, Column, Row, Slider}, widget::{self, Slider},
Application, ApplicationExt, Element, Application, ApplicationExt, Element,
}; };
use iced_video_player::{ use iced_video_player::{
@ -434,25 +434,27 @@ impl Application for App {
format!("{:02}:{:02}:{:02}", hours, minutes, seconds) format!("{:02}:{:02}:{:02}", hours, minutes, seconds)
}; };
let mut column = widget::column::with_capacity(4); let Some(video) = &self.video_opt else {
column = column.push(widget::vertical_space(Length::Fill)); //TODO: open button if no video?
if let Some(video) = &self.video_opt { return widget::container(widget::text("No video open"))
column = column.push( .width(Length::Fill)
VideoPlayer::new(video) .height(Length::Fill)
.on_end_of_stream(Message::EndOfStream) .style(theme::Container::WindowBackground)
.on_missing_plugin(Message::MissingPlugin) .into();
.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 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 { if !self.fullscreen {
column = column.push( popover = popover.popup(
widget::container( widget::container(
Row::new() widget::row::with_capacity(4)
.align_items(Alignment::Center) .align_items(Alignment::Center)
.spacing(8) .spacing(8)
.padding([0, 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| { .style(theme::Container::Custom(Box::new(|_theme| {
widget::container::Appearance::default().with_background(Color::BLACK) widget::container::Appearance::default().with_background(Color::BLACK)
}))) })))