Skip to content

Commit b6905b4

Browse files
author
Jesse van den Kieboom
committed
Draw curved lane transitions (patch by Tomas Carnecky)
1 parent becd09a commit b6905b4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

gitg/gitg-cell-renderer-path.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ draw_arrow(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, gint8 la
108108
}
109109

110110
static void
111-
draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, GitgRevision *revision, gboolean top, gdouble yoffset)
111+
draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, GitgRevision *revision, gdouble yoffset)
112112
{
113113
if (!revision)
114114
return;
@@ -129,13 +129,12 @@ draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, Git
129129
for (item = lane->from; item; item = item->next)
130130
{
131131
gint8 from = (gint8)GPOINTER_TO_INT(item->data);
132-
gdouble xf = 0.0;
133-
134-
if (from != to)
135-
xf = 0.5 * (to - from);
136-
137-
cairo_move_to(cr, area->x + (from + (top ? xf : 0)) * cw + cw / 2.0, area->y + yoffset * ch);
138-
cairo_line_to(cr, area->x + (to - (top ? 0 : xf)) * cw + cw / 2.0, area->y + (yoffset + 1) * ch);
132+
133+
cairo_move_to(cr, area->x + from * cw + cw / 2.0, area->y + yoffset * ch);
134+
cairo_curve_to(cr, area->x + from * cw + cw / 2.0, area->y + (yoffset + 1) * ch,
135+
area->x + to * cw + cw / 2.0, area->y + (yoffset + 1) * ch,
136+
area->x + to * cw + cw / 2.0, area->y + (yoffset + 2) * ch);
137+
139138
cairo_stroke(cr);
140139
}
141140

@@ -147,13 +146,13 @@ draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, Git
147146
static void
148147
draw_top_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
149148
{
150-
draw_paths_real(self, cr, area, self->priv->revision, TRUE, 0);
149+
draw_paths_real(self, cr, area, self->priv->revision, -1);
151150
}
152151

153152
static void
154153
draw_bottom_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
155154
{
156-
draw_paths_real(self, cr, area, self->priv->next_revision, FALSE, 1);
155+
draw_paths_real(self, cr, area, self->priv->next_revision, 1);
157156
}
158157

159158
static void
@@ -265,6 +264,10 @@ renderer_render(GtkCellRenderer *renderer, GdkDrawable *window, GtkWidget *widge
265264
GitgCellRendererPath *self = GITG_CELL_RENDERER_PATH(renderer);
266265

267266
cairo_t *cr = gdk_cairo_create(window);
267+
268+
cairo_rectangle(cr, area->x, area->y, area->width, area->height);
269+
cairo_clip(cr);
270+
268271
draw_paths(self, cr, area);
269272

270273
/* draw indicator */

0 commit comments

Comments
 (0)