[pitivi] ruler: Show the hours and millis only if useful



commit 3f78e856c4566712d3a5ccb161e40748ab08d3b6
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Jan 10 14:37:57 2014 +0100

    ruler: Show the hours and millis only if useful

 pitivi/timeline/ruler.py    |   10 ++++++++--
 pitivi/timeline/timeline.py |    1 +
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 7109262..3b756a9 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -325,6 +325,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         style = self.get_style_context()
         setCairoColor(context, style.get_color(state))
         y_bearing = context.text_extents("0")[1]
+        millis = scale < 1
 
         def split(x):
             # Seven elements: h : mm : ss . mmm
@@ -337,13 +338,18 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         while paintpos < width:
             context.move_to(int(paintpos), 1 - y_bearing)
             current = split(time_to_string(long(current_time)))
-            self._drawTime(context, current, previous)
+            self._drawTime(context, current, previous, millis)
             previous = current
             paintpos += spacing
             current_time += interval
 
-    def _drawTime(self, context, current, previous):
+    def _drawTime(self, context, current, previous, millis):
+        hour = int(current[0])
         for index, (element, previous_element) in enumerate(zip(current, previous)):
+            if index <= 1 and not hour:
+                continue
+            if index >= 5 and not millis:
+                break
             if element == previous_element:
                 color = self._color_dimmed
             else:
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index d7f6c33..3909764 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -718,6 +718,7 @@ class Timeline(Gtk.Grid, Zoomable, Loggable):
         self._projectmanager = None
         self._project = None
         self.pipeline = None
+        self.bTimeline = None
 
         self._createUi()
         self._createActions()


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