[pitivi] Find an optimum zoom level when loading a project. Fixes #590153.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pitivi] Find an optimum zoom level when loading a project. Fixes #590153.
- Date: Tue, 25 Aug 2009 09:31:08 +0000 (UTC)
commit 9a09589a1f0631eb2b3ece95b7b3c330f24e270a
Author: Alessandro Decina <alessandro d gmail com>
Date: Mon Aug 24 19:27:36 2009 +0200
Find an optimum zoom level when loading a project. Fixes #590153.
pitivi/ui/mainwindow.py | 40 +++++++++++++++++++++++++++++++++++++---
pitivi/ui/zoominterface.py | 5 +++++
2 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index b95bdb0..8141022 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -42,9 +42,9 @@ from gettext import gettext as _
from pitivi.log.loggable import Loggable
-from timeline import Timeline
-from projecttabs import ProjectTabs
-from viewer import PitiviViewer
+from pitivi.ui.timeline import Timeline
+from pitivi.ui.projecttabs import ProjectTabs
+from pitivi.ui.viewer import PitiviViewer
from pitivi.configure import pitivi_version, APPNAME, get_pixmap_dir, \
get_global_pixmap_dir
from pitivi.ui import dnd
@@ -57,6 +57,7 @@ from pitivi.sourcelist import SourceListError
from pitivi.ui.sourcelist import SourceList
from pitivi.ui.common import beautify_factory
from pitivi.utils import beautify_length
+from pitivi.ui.zoominterface import Zoomable
if HAVE_GCONF:
D_G_INTERFACE = "/desktop/gnome/interface"
@@ -689,6 +690,39 @@ class PitiviMainWindow(gtk.Window, Loggable):
self.render_button.set_sensitive(can_render)
self._syncDoUndo(self.app.action_log)
+ if project.timeline.duration != 0:
+ self._setBestZoomRatio()
+
+ def _setBestZoomRatio(self):
+ # reset the default zoom ratio
+ Zoomable.setZoomRatio(2)
+
+ ruler_width = self.timeline.ruler.get_allocation()[2]
+ while True:
+ 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]:
+ break
+
+ Zoomable.zoomIn()
+ timeline_width = Zoomable.nsToPixel(self.project.timeline.duration)
+ if timeline_width > ruler_width:
+ Zoomable.zoomOut()
+ break
+
+ else:
+ if current_level == Zoomable.zoom_levels[0]:
+ break
+
+ Zoomable.zoomOut()
+
def _projectManagerNewProjectLoadingCb(self, projectManager, uri):
self.log("A NEW project is being loaded, deactivate UI")
diff --git a/pitivi/ui/zoominterface.py b/pitivi/ui/zoominterface.py
index de278e7..602ffeb 100644
--- a/pitivi/ui/zoominterface.py
+++ b/pitivi/ui/zoominterface.py
@@ -77,9 +77,14 @@ class Zoomable(object):
@classmethod
def setZoomRatio(cls, ratio):
cls.zoomratio = ratio
+ cls._cur_zoom = cls.zoom_levels.index(ratio)
cls._zoomChanged()
@classmethod
+ def getCurrentZoomLevel(cls):
+ return cls._cur_zoom
+
+ @classmethod
def zoomIn(cls):
cls._cur_zoom = min(len(cls.zoom_levels) - 1, cls._cur_zoom + 1)
cls.setZoomRatio(cls._computeZoomRatio(cls._cur_zoom))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]