[pitivi] ruler: Clarify what the spacing and scale values represent



commit a5d0f124f21209dbfbb5e68bcdffdc78cb4a54ec
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Jan 2 19:02:21 2014 +0100

    ruler: Clarify what the spacing and scale values represent

 pitivi/timeline/ruler.py |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 8312542..a52bb49 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -71,6 +71,9 @@ def setCairoColor(context, color):
 class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
     """
     Widget for displaying the ruler.
+
+    Displays a series of consecutive intervals. For each interval its beginning
+    time is shown. If zoomed in enough, shows the frames in alternate colors.
     """
 
     __gsignals__ = {
@@ -268,18 +271,22 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         # FIXME use system defaults
         context.set_font_face(cairo.ToyFontFace("Cantarell"))
         context.set_font_size(13)
-        textwidth = context.text_extents(time_to_string(0))[2]
-
-        for scale in self.scales:
-            spacing = Zoomable.zoomratio * scale
-            if spacing >= textwidth * 1.5:
-                break
 
+        spacing, scale = self._getSpacing(context)
         offset = self.pixbuf_offset % spacing
         self.drawFrameBoundaries(context)
         self.drawTicks(context, offset, spacing)
         self.drawTimes(context, offset, spacing, scale)
 
+    def _getSpacing(self, context):
+        textwidth = context.text_extents(time_to_string(0))[2]
+        zoom = Zoomable.zoomratio
+        for scale in self.scales:
+            spacing = scale * zoom
+            if spacing >= textwidth * 1.5:
+                return spacing, scale
+        raise Exception("Failed to find an interval size for textwidth:%s, zoomratio:%s" % (textwidth, 
Zoomable.zoomratio))
+
     def drawTicks(self, context, offset, spacing):
         for count_per_interval, height_ratio in TICK_TYPES:
             space = float(spacing) / count_per_interval


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