[pitivi] Make sure the last second of the timeline is in view. Matters when the duration of the timeline is v



commit 9b141a40c5af035ab81af19f025d0410a63bd23a
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date:   Fri May 20 09:04:33 2011 +0200

    Make sure the last second of the timeline is in view.
    Matters when the duration of the timeline is very short.

 pitivi/ui/mainwindow.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 31a19f8..b12f0d4 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -795,11 +795,15 @@ class PitiviMainWindow(gtk.Window, Loggable):
         # preliminary seek to ensure the project pipeline is configured
         self.project.seeker.seek(0)
 
-    def setBestZoomRatio(self):
+    def setBestZoomRatio(self, p=0):
+        """Set the zoom level so that the entire timeline is in view."""
         ruler_width = self.timeline.ruler.get_allocation()[2]
-        timeline_duration = self.project.timeline.duration
+        # Add gst.SECOND - 1 to the timeline duration to make sure the
+        # last second of the timeline will be in view.
+        timeline_duration = self.project.timeline.duration + gst.SECOND - 1
+        timeline_duration_s = int(timeline_duration / gst.SECOND)
 
-        ideal_zoom_ratio = ruler_width / float(timeline_duration / gst.SECOND)
+        ideal_zoom_ratio = float(ruler_width) / timeline_duration_s
         nearest_zoom_level = Zoomable.computeZoomLevel(ideal_zoom_ratio)
         Zoomable.setZoomLevel(nearest_zoom_level)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]