[pitivi/ges: 114/287] Ensure that previewed videos fit within a reasonable size
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 114/287] Ensure that previewed videos fit within a reasonable size
- Date: Thu, 15 Mar 2012 16:35:24 +0000 (UTC)
commit 23d08bbdd31cb27d001cf0ff064c01e89660cbaf
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Sat Dec 24 02:10:40 2011 -0500
Ensure that previewed videos fit within a reasonable size
pitivi/ui/mainwindow.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index eb5bcf3..c650003 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -1090,10 +1090,24 @@ class PitiviMainWindow(gtk.Window, Loggable):
previewer.setMinimal()
info = self.project.sources.getInfoFromUri(path)
try:
- image_width = info.get_video_streams()[0].get_width()
- image_height = info.get_video_streams()[0].get_height()
+ # For videos and images, automatically resize the window
+ # Try to keep it 1:1 if it can fit within 85% of the parent window
+ img_width = info.get_video_streams()[0].get_width()
+ img_height = info.get_video_streams()[0].get_height()
controls_height = previewer.bbox.size_request()[1]
- preview_window.resize(image_width, image_height + controls_height)
+ mainwindow_width, mainwindow_height = self.get_size()
+ max_width = 0.85 * mainwindow_width
+ max_height = 0.85 * mainwindow_height
+ if img_width < max_width \
+ and (img_height + controls_height) < max_height:
+ # The video is small enough, keep it 1:1
+ preview_window.resize(img_width, img_height + controls_height)
+ else:
+ # The video is too big, size it down
+ # TODO: be smarter, figure out which (width, height) is bigger
+ new_height = max_width * img_height / img_width
+ preview_window.resize(int(max_width),
+ int(new_height + controls_height))
except:
# There is no video/image stream. This is an audio file.
# Resize to the minimum and let the window manager deal with it
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]