From 8105bd3b48c6454a4ab87cfb363a98e47b437ac6 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 7 Oct 2024 11:06:32 -0600 Subject: [PATCH] Auto hide controls --- src/gstreamer/mod.rs | 91 +++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/src/gstreamer/mod.rs b/src/gstreamer/mod.rs index 46d8747..5f00a64 100644 --- a/src/gstreamer/mod.rs +++ b/src/gstreamer/mod.rs @@ -8,6 +8,7 @@ use cosmic::{ iced::{ event::{self, Event}, keyboard::{Event as KeyEvent, Key, Modifiers}, + mouse::Event as MouseEvent, subscription::{self, Subscription}, window, Alignment, Color, Length, Limits, Size, }, @@ -19,7 +20,11 @@ use iced_video_player::{ gst::{self, prelude::*}, gst_pbutils, Video, VideoPlayer, }; -use std::{any::TypeId, collections::HashMap, time::Duration}; +use std::{ + any::TypeId, + collections::HashMap, + time::{Duration, Instant}, +}; use crate::{ config::{Config, CONFIG_VERSION}, @@ -27,6 +32,8 @@ use crate::{ localize, }; +static CONTROLS_TIMEOUT: Duration = Duration::new(2, 0); + /// Runs application with these settings #[rustfmt::skip] pub fn main() -> Result<(), Box> { @@ -110,6 +117,7 @@ pub enum Message { MissingPlugin(gst::Message), NewFrame, Reload, + ShowControls, SystemThemeModeChange(cosmic_theme::ThemeMode), } @@ -117,6 +125,8 @@ pub enum Message { pub struct App { core: Core, flags: Flags, + controls: bool, + controls_time: Instant, fullscreen: bool, key_binds: HashMap, video_opt: Option