fade out video controls if there is no mouse movement

This commit is contained in:
Jonas Weinz 2020-10-23 20:06:37 +02:00
parent dcf4615033
commit 9a5b4227a2
2 changed files with 17 additions and 0 deletions

View File

@ -43,6 +43,11 @@ class MainApp(Gtk.Window):
self.add(self._main_container)
self.connect('motion-notify-event', self.on_mouse_move)
def on_mouse_move(self, _, __):
self._player_widget.show_controls()
def on_search(self, _ = None):
if self.get_active_pane() == "player":
self._player_widget.pause()

View File

@ -28,6 +28,8 @@ class PlayerWidget(Gtk.Overlay):
self._is_update = False
self._seconds_after_mouse_move = 0
GLib.timeout_add_seconds(1, self.update_controls)
self._slider.connect("value-changed", self._on_user_slider_change)
@ -49,6 +51,11 @@ class PlayerWidget(Gtk.Overlay):
self._is_update = False
if self._seconds_after_mouse_move > 3:
self._controls.set_reveal_child(False)
self._seconds_after_mouse_move += 1
return True
def _on_user_slider_change(self, range):
@ -101,6 +108,7 @@ class PlayerWidget(Gtk.Overlay):
self._controls.set_valign(Gtk.Align.END)
self._controls.set_transition_type(Gtk.RevealerTransitionType.SLIDE_UP)
self._controls.set_reveal_child(True)
style_context = self._controls.get_style_context()
@ -128,3 +136,7 @@ class PlayerWidget(Gtk.Overlay):
def get_state(self):
return self._videoarea.get_state()
def show_controls(self):
self._controls.set_reveal_child(True)
self._seconds_after_mouse_move = 0