Cleanup timeline warning/error triangle drawing, add TODOs
authorRené Stadler <mail@renestadler.de>
Fri, 7 Dec 2007 12:10:03 +0000 (14:10 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Thu, 11 Sep 2014 18:51:42 +0000 (20:51 +0200)
debug-viewer/GstDebugViewer/Plugins/Timeline.py

index 5676ca7..5a437db 100644 (file)
@@ -524,16 +524,19 @@ class TimelineWidget (gtk.DrawingArea):
 
         # Draw error and warning triangle indicators:
 
+        def triangle (ctx, size = 8):
+            ctx.move_to (-size // 2, 0)
+            ctx.line_to ((size + 1) // 2, 0)
+            ctx.line_to (0, size / 1.41)
+            ctx.close_path ()            
+
         for level in (Data.debug_level_warning, Data.debug_level_error,):
             ctx.set_source_rgb (*(theme.colors_float (level)[1]))
             for i, counts in enumerate (dist_data):
                 if counts[level] == 0:
                     continue
-                SIZE = 8
-                ctx.move_to (i - SIZE // 2, 0)
-                ctx.line_to (i + SIZE // 2, 0)
-                ctx.line_to (i, SIZE / 1.41)
-                ctx.close_path ()
+                ctx.translate (i, 0)
+                triangle (ctx)
                 ctx.fill ()
 
     def __draw_graph (self, ctx, w, h, maximum, data):
@@ -809,18 +812,34 @@ class TimelineFeature (FeatureBase):
         if event.button != 1:
             return True
 
+        # TODO: Check if clicked inside a warning/error indicator triangle and
+        # navigate there.
+
         pos = int (event.x)
         self.goto_time_position (pos)
         return False
 
     def handle_timeline_motion_notify_event (self, widget, event):
 
-        if not event.state & gtk.gdk.BUTTON1_MASK:
+        x = event.x
+        y = event.y
+
+        if event.state & gtk.gdk.BUTTON1_MASK:
+            self.handle_timeline_motion_button1 (x, y)
             return True
+        else:
+            self.handle_timeline_motion (x, y)
+            return False
 
-        pos = int (event.x)
-        self.goto_time_position (pos)
-        return False
+    def handle_timeline_motion (self, x, y):
+
+        # TODO: Prelight warning and error indicator triangles.
+
+        pass
+
+    def handle_timeline_motion_button1 (self, x, y):
+
+        self.goto_time_position (int (x))
 
     def goto_time_position (self, pos):