[pitivi] MainWindow: Fix algorithm for finding best zoom ratio.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pitivi] MainWindow: Fix algorithm for finding best zoom ratio.
- Date: Sat, 5 Sep 2009 15:20:47 +0000 (UTC)
commit c1e9a569acdd74f68c0d53dba8815033f780586d
Author: Edward Hervey <bilboed bilboed com>
Date: Sat Sep 5 16:13:04 2009 +0200
MainWindow: Fix algorithm for finding best zoom ratio.
Zoomable.getCurrentZoomLevel is an index in the zoom_levels table and not
the actual zoom ratio.
pitivi/ui/mainwindow.py | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 8141022..6723432 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -698,29 +698,39 @@ class PitiviMainWindow(gtk.Window, Loggable):
Zoomable.setZoomRatio(2)
ruler_width = self.timeline.ruler.get_allocation()[2]
+ # FIXME : The problem with this algorithm is that all widget classes using
+ # the Zoomable interface will be redrawn when doing ZoomIn/Out.
+ # We should ideally figure out the optimal zoom level without redrawing widgets
while True:
+ current_level = Zoomable.getCurrentZoomLevel()
+
+ self.log("Setting best zoom ratio. Current level %r",
+ current_level)
timeline_width = Zoomable.nsToPixel(self.project.timeline.duration)
if ruler_width == timeline_width:
# perfect
break
- current_level = Zoomable.getCurrentZoomLevel()
-
if ruler_width > timeline_width:
- if current_level == Zoomable.zoom_levels[-1]:
+ self.log("Trying to zoom in")
+ if current_level == len(Zoomable.zoom_levels) - 1:
+ self.log("Reached maximum zoom level, breaking out")
break
Zoomable.zoomIn()
timeline_width = Zoomable.nsToPixel(self.project.timeline.duration)
if timeline_width > ruler_width:
+ self.log("too big, zooming out and breaking out")
Zoomable.zoomOut()
break
else:
- if current_level == Zoomable.zoom_levels[0]:
+ if current_level == 0:
+ self.log("Reached minimum zoom level, breaking out")
break
+ self.log("zooming out")
Zoomable.zoomOut()
def _projectManagerNewProjectLoadingCb(self, projectManager, uri):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]