[pitivi] ruler: Reuse values when we already have them



commit d5d269f14d148695df58d647d15b0f12f7d43cc8
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Jan 2 16:35:49 2014 +0100

    ruler: Reuse values when we already have them

 pitivi/timeline/ruler.py |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 17c438d..5820484 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -271,18 +271,6 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         self.drawTicks(context, offset, spacing, scale)
         self.drawTimes(context, offset, spacing, scale)
 
-    def drawTick(self, context, paintpos, height):
-        # We need to use 0.5 pixel offsets to get a sharp 1 px line in cairo
-        paintpos = int(paintpos - 0.5) + 0.5
-        height = int(context.get_target().get_height() * (1 - height))
-        style = self.get_style_context()
-        setCairoColor(context, style.get_color(Gtk.StateFlags.NORMAL))
-        context.set_line_width(1)
-        context.move_to(paintpos, height)
-        context.line_to(paintpos, context.get_target().get_height())
-        context.close_path()
-        context.stroke()
-
     def drawTicks(self, context, offset, spacing, scale):
         for subdivide, height in self.subdivide:
             spc = spacing / float(subdivide)
@@ -291,9 +279,21 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
             paintpos = -spacing + 0.5
             paintpos += spacing - offset
             while paintpos < context.get_target().get_width():
-                self.drawTick(context, paintpos, height)
+                self._drawTick(context, paintpos, height)
                 paintpos += spc
 
+    def _drawTick(self, context, paintpos, tick_height):
+        # We need to use 0.5 pixel offsets to get a sharp 1 px line in cairo
+        paintpos = int(paintpos - 0.5) + 0.5
+        target_height = context.get_target().get_height()
+        y = int(target_height * (1 - tick_height))
+        setCairoColor(context, self._color_normal)
+        context.set_line_width(1)
+        context.move_to(paintpos, y)
+        context.line_to(paintpos, target_height)
+        context.close_path()
+        context.stroke()
+
     def drawTimes(self, context, offset, spacing, scale):
         # figure out what the optimal offset is
         interval = long(Gst.SECOND * scale)


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