[pitivi] viewer: Show resize status
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Show resize status
- Date: Thu, 10 Jan 2019 10:06:18 +0000 (UTC)
commit d91c1283a85b4041e57253f7086ac2706f42acdd
Author: HarishFulara07 <harish14143 iiitd ac in>
Date: Tue Aug 7 18:17:42 2018 +0530
viewer: Show resize status
pitivi/editorperspective.py | 4 ++--
pitivi/utils/ui.py | 8 +++++++-
pitivi/viewer/overlay_stack.py | 40 ++++++++++++++++++++++++++++++++++++++++
pitivi/viewer/viewer.py | 11 +++++++++++
4 files changed, 60 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/editorperspective.py b/pitivi/editorperspective.py
index b1fb4d96..8441e8c8 100644
--- a/pitivi/editorperspective.py
+++ b/pitivi/editorperspective.py
@@ -43,10 +43,10 @@ from pitivi.transitions import TransitionsListWidget
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.ui import beautify_time_delta
+from pitivi.utils.ui import EDITOR_PERSPECTIVE_CSS
from pitivi.utils.ui import info_name
from pitivi.utils.ui import PADDING
from pitivi.utils.ui import SPACING
-from pitivi.utils.ui import TIMELINE_CSS
from pitivi.viewer.viewer import ViewerContainer
@@ -110,7 +110,7 @@ class EditorPerspective(Perspective, Loggable):
def __setup_css(self):
css_provider = Gtk.CssProvider()
- css_provider.load_from_data(TIMELINE_CSS.encode('UTF-8'))
+ css_provider.load_from_data(EDITOR_PERSPECTIVE_CSS.encode("UTF-8"))
screen = Gdk.Screen.get_default()
style_context = self.app.gui.get_style_context()
style_context.add_provider_for_screen(screen, css_provider,
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index 9d9dc015..c175c8b7 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -157,7 +157,13 @@ GREETER_PERSPECTIVE_CSS = """
}
"""
-TIMELINE_CSS = """
+EDITOR_PERSPECTIVE_CSS = """
+ #resize_status {
+ font-size: 200%%;
+ background-color: black;
+ opacity: 0.8;
+ }
+
.AudioBackground {
background-color: #496c21;
}
diff --git a/pitivi/viewer/overlay_stack.py b/pitivi/viewer/overlay_stack.py
index 2da6a7f9..e1389d10 100644
--- a/pitivi/viewer/overlay_stack.py
+++ b/pitivi/viewer/overlay_stack.py
@@ -19,6 +19,7 @@
import numpy
from gi.repository import Gdk
from gi.repository import GES
+from gi.repository import GLib
from gi.repository import Gtk
from pitivi.utils.loggable import Loggable
@@ -50,6 +51,19 @@ class OverlayStack(Gtk.Overlay, Loggable):
self.add(sink_widget)
self.connect("size-allocate", self.__on_size_allocate)
+ # Whether to show the percent of the size relative to the project size.
+ # It is set to false initially because the viewer gets resized
+ # while the project is loading and we don't want to show the percent
+ # in this case.
+ self.__show_resize_status = False
+ # ID of resizing timeout callback, so it can be delayed.
+ self.__resizing_id = 0
+ self.revealer = Gtk.Revealer(transition_type=Gtk.RevealerTransitionType.CROSSFADE)
+ self.resize_status = Gtk.Label(name="resize_status")
+ self.revealer.add(self.resize_status)
+ self.add_overlay(self.revealer)
+ sink_widget.connect("size-allocate", self.__sink_widget_size_allocate_cb)
+
def __on_size_allocate(self, widget, rectangle):
self.window_size = numpy.array([rectangle.width,
rectangle.height])
@@ -169,3 +183,29 @@ class OverlayStack(Gtk.Overlay, Loggable):
def get_normalized_cursor_position(self, cursor_position):
return cursor_position / self.window_size
+
+ def enable_resize_status(self, enabled):
+ self.__show_resize_status = enabled
+
+ def __sink_widget_size_allocate_cb(self, unused_widget, allocation):
+ if not self.__show_resize_status:
+ return
+
+ if not self.revealer.get_reveal_child():
+ self.revealer.set_transition_duration(10)
+ self.revealer.set_reveal_child(True)
+
+ video_width = self.app.project_manager.current_project.videowidth
+ percent = int(allocation.width / video_width * 100)
+ self.resize_status.set_text("{}%".format(percent))
+
+ # Add timeout function to hide the resize percent.
+ if self.__resizing_id:
+ GLib.source_remove(self.__resizing_id)
+ self.__resizing_id = GLib.timeout_add(1000, self.__resizing_timeout_cb, None)
+
+ def __resizing_timeout_cb(self, unused_data):
+ self.__resizing_id = 0
+ self.revealer.set_transition_duration(500)
+ self.revealer.set_reveal_child(False)
+ return False
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index 9affab43..679bd443 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -21,6 +21,7 @@ from time import time
from gi.repository import Gdk
from gi.repository import GES
+from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gst
from gi.repository import Gtk
@@ -148,6 +149,10 @@ class ViewerContainer(Gtk.Box, Loggable):
self.setDisplayAspectRatio(self.app.project_manager.current_project.getDAR())
self.target.show_all()
+ # Wait for 1s to make sure that the viewer has completely realized
+ # and then we can mark the resize status as showable.
+ GLib.timeout_add(1000, self.__viewer_realization_done_cb, None)
+
def _disconnectFromPipeline(self):
if self.pipeline is None:
# silently return, there's nothing to disconnect from
@@ -402,6 +407,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.docked = False
self.settings.viewerDocked = False
+ self.overlay_stack.enable_resize_status(False)
self.remove(self.buttons_container)
position = None
if self.pipeline:
@@ -431,6 +437,10 @@ class ViewerContainer(Gtk.Box, Loggable):
self.pipeline.pause()
self.pipeline.simple_seek(position)
+ def __viewer_realization_done_cb(self, unused_data):
+ self.overlay_stack.enable_resize_status(True)
+ return False
+
def dock(self):
if self.docked:
self.warning("The viewer is already docked")
@@ -438,6 +448,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.docked = True
self.settings.viewerDocked = True
+ self.overlay_stack.enable_resize_status(False)
position = None
if self.pipeline:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]