# HG changeset patch
# User Peer Sommerlund <p...@users.sourceforge.net>
# Date 1251705047 -7200
logview: Add different line types

For lines in the log graph, add a type. This makes
it possible to distinguish between full and dashed lines.

diff -r 6706113d1ab3 -r 74b2963abd9b hggtk/logview/graphcell.py
--- a/hggtk/logview/graphcell.py
+++ b/hggtk/logview/graphcell.py
@@ -19,14 +19,17 @@
 import pango
 import cairo
 
+# Styles used when rendering revision graph edges
+style_SOLID = 0
+style_DASHED = 1
 
 class CellRendererGraph(gtk.GenericCellRenderer):
     """Cell renderer for directed graph.
 
     Properties:
       node              (column, colour) tuple to draw revision node,
-      in_lines          (start, end, colour) tuple list to draw inward lines,
-      out_lines         (start, end, colour) tuple list to draw outward lines.
+      in_lines          (start, end, colour, style) tuple list to draw inward 
lines,
+      out_lines         (start, end, colour, style) tuple list to draw outward 
lines.
     """
 
     columns_len = 0
@@ -144,16 +147,22 @@
         ctx.set_line_cap(cairo.LINE_CAP_ROUND)
 
         # Draw lines into the cell
-        for start, end, colour in self.in_lines:
+        for start, end, colour, type in self.in_lines:
+            style = style_SOLID
+            if type & 1:
+                style = style_DASHED
             self.render_line (ctx, cell_area, box_size,
                          bg_area.y, bg_area.height,
-                         start, end, colour)
+                         start, end, colour, style)
 
         # Draw lines out of the cell
-        for start, end, colour in self.out_lines:
+        for start, end, colour, type in self.out_lines:
+            style = style_SOLID
+            if type & 2:
+                style = style_DASHED
             self.render_line (ctx, cell_area, box_size,
                          bg_area.y + bg_area.height, bg_area.height,
-                         start, end, colour)
+                         start, end, colour, style)
 
         # Draw the revision node in the right column
         (column, colour) = self.node
@@ -168,7 +177,7 @@
         ctx.fill()
 
     def render_line (self, ctx, cell_area, box_size, mid,
-            height, start, end, colour):
+            height, start, end, colour, style):
         if start is None:
             x = cell_area.x + box_size * end + box_size / 2
             ctx.move_to(x, mid + height / 3)
@@ -200,4 +209,8 @@
                              endx, mid + height / 2)
 
         self.set_colour(ctx, colour, 0.0, 0.65)
+        if style == style_DASHED:
+            dashes = [1, 2]
+            ctx.set_dash(dashes)
         ctx.stroke()
+        ctx.set_dash([])
diff -r 6706113d1ab3 -r 74b2963abd9b hggtk/logview/revgraph.py
--- a/hggtk/logview/revgraph.py
+++ b/hggtk/logview/revgraph.py
@@ -11,7 +11,7 @@
 
   - Current revision.
   - node; defined as tuple (rev_column, rev_color)
-  - lines; a list of (col, next_col, color) indicating the edges between
+  - lines; a list of (col, next_col, color, type) indicating the edges between
     the current row and the next row
   - parent revisions of current revision
   
@@ -23,6 +23,10 @@
   - col: Column for the upper end of the line.
   - nextcol: Column for the lower end of the line.
   - color: Colour used for line
+  - type: 0 for plain line, 1 for loose upper end, 2 for loose lower end
+    loose ends are rendered as dashed lines. They indicate that the
+    edge of the graph does not really end here. This is used to render 
+    a branch view where the focus is on branches instead of revisions.
     
 The data is used in treeview.populate with the following signature
     (rev, node, lines, parents) = self.grapher.next()
@@ -65,6 +69,10 @@
     else:
         return sum([ord(c) for c in repo[rev].branch()])
 
+type_PLAIN = 0
+type_LOOSE_LOW = 1
+type_LOOSE_HIGH = 2
+
 def revision_grapher(repo, start_rev, stop_rev, branch=None, noheads=False, 
branch_color=False):
     """incremental revision grapher
 
@@ -126,11 +134,11 @@
         for i, rev in enumerate(revs):
             if rev in next_revs:
                 color = rev_color[rev]
-                lines.append( (i, next_revs.index(rev), color) )
+                lines.append( (i, next_revs.index(rev), color, type_PLAIN) )
             elif rev == curr_rev:
                 for parent in parents:
                     color = rev_color[parent]
-                    lines.append( (i, next_revs.index(parent), color) )
+                    lines.append( (i, next_revs.index(parent), color, 
type_PLAIN) )
 
         yield (curr_rev, (rev_index, rev_color[curr_rev]), lines, parents)
         revs = next_revs

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to