[pitivi: 5/11] take scroll position into consideration when rendering previews



commit aed7d82c0277f769f9fb240cbb8b11091ae16472
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Fri Oct 1 15:21:28 2010 +0100

    take scroll position into consideration when rendering previews

 pitivi/ui/preview.py   |    7 ++++---
 pitivi/ui/previewer.py |    9 +++++----
 2 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/ui/preview.py b/pitivi/ui/preview.py
index 196f1c7..0b2b65e 100644
--- a/pitivi/ui/preview.py
+++ b/pitivi/ui/preview.py
@@ -49,6 +49,8 @@ class Preview(goocanvas.ItemSimple, goocanvas.Item, Zoomable):
         self.height = float(height)
         self.element = element
         self.props.pointer_events = False
+        # ghetto hack
+        self.hadj = instance.gui.timeline.hadj
 
 ## properties
 
@@ -100,12 +102,11 @@ class Preview(goocanvas.ItemSimple, goocanvas.Item, Zoomable):
                 border_width), self.height)
 
     def do_simple_paint(self, cr, bounds):
-
-
+        x1 = -self.hadj.get_value()
         cr.identity_matrix()
         if self.element.factory:
             self.previewer.render_cairo(cr, intersect(self.bounds, bounds),
-            self.element, self.bounds.y1)
+            self.element, x1, self.bounds.y1)
 
     def do_simple_is_item_at(self, x, y, cr, pointer_event):
         return (between(0, x, self.nsToPixel(self.element.duration)) and
diff --git a/pitivi/ui/previewer.py b/pitivi/ui/previewer.py
index f0dcdd2..00c35a5 100644
--- a/pitivi/ui/previewer.py
+++ b/pitivi/ui/previewer.py
@@ -149,7 +149,7 @@ class Previewer(Signallable, Loggable):
         self.default_thumb = cairo.ImageSurface.create_from_png(path)
         self._connectSettings(instance.settings)
 
-    def render_cairo(self, cr, bounds, element, y1):
+    def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
         """Render a preview of element onto a cairo context within the current
         bounds, which may or may not be the entire object and which may or may
         not intersect the visible portion of the object"""
@@ -160,7 +160,7 @@ class Previewer(Signallable, Loggable):
 
 class DefaultPreviewer(Previewer):
 
-    def render_cairo(self, cr, bounds, element, y1):
+    def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
         # TODO: draw a single thumbnail
         pass
 
@@ -202,7 +202,7 @@ class RandomAccessPreviewer(Previewer):
 
 ## public interface
 
-    def render_cairo(self, cr, bounds, element, y1):
+    def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
         if not self._view:
             return
         # The idea is to conceptually divide the clip into a sequence of
@@ -224,7 +224,8 @@ class RandomAccessPreviewer(Previewer):
         # tdur = duration in ns of thumbnail
         # sof  = start of file in pixel coordinates
         x1 = bounds.x1;
-        sof = Zoomable.nsToPixel(element.start - element.in_point)
+        sof = Zoomable.nsToPixel(element.start - element.in_point) +\
+            hscroll_pos
 
         # i = left edge of thumbnail to be drawn. We start with x1 and
         # subtract the distance to the nearest leftward rectangle.



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