[gtk+/rendering-cleanup: 61/113] treeview: Unify all line drawing into the same function
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 61/113] treeview: Unify all line drawing into the same function
- Date: Wed, 21 Jul 2010 23:26:27 +0000 (UTC)
commit 09bb4614cca5273a9a76862ecf8d8661d924bd17
Author: Benjamin Otte <otte redhat com>
Date: Thu Jul 15 03:36:07 2010 +0200
treeview: Unify all line drawing into the same function
This is useful because the dashing stuff needs to be done and it seems
like a good idea to unify it.
gtk/gtktreeview.c | 138 ++++++++++++++++++++++++++++++++++-------------------
1 files changed, 88 insertions(+), 50 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 5ba92d5..3828e8d 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -4221,6 +4221,44 @@ draw_empty_focus (GtkTreeView *tree_view, GdkRectangle *clip_area)
1, 1, w, h);
}
+typedef enum {
+ GTK_TREE_VIEW_GRID_LINE,
+ GTK_TREE_VIEW_TREE_LINE,
+ GTK_TREE_VIEW_FOREGROUND_LINE
+} GtkTreeViewLineType;
+
+static void
+gtk_tree_view_draw_line (GtkTreeView *tree_view,
+ GdkWindow *window,
+ GtkTreeViewLineType type,
+ int x1,
+ int y1,
+ int x2,
+ int y2)
+{
+ GdkGC *gc;
+
+ switch (type)
+ {
+ case GTK_TREE_VIEW_TREE_LINE:
+ gc = tree_view->priv->tree_line_gc;
+ break;
+ case GTK_TREE_VIEW_GRID_LINE:
+ gc = tree_view->priv->grid_line_gc;
+ break;
+ default:
+ g_assert_not_reached ();
+ /* fall through */
+ case GTK_TREE_VIEW_FOREGROUND_LINE:
+ gc = GTK_WIDGET (tree_view)->style->fg_gc[gtk_widget_get_state (GTK_WIDGET (tree_view))];
+ break;
+ }
+
+ gdk_draw_line (window, gc,
+ x1, y1,
+ x2, y2);
+}
+
static void
gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
GdkEventExpose *event,
@@ -4248,10 +4286,10 @@ gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
current_x += column->width;
- gdk_draw_line (event->window,
- tree_view->priv->grid_line_gc,
- current_x - 1, 0,
- current_x - 1, tree_view->priv->height);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_GRID_LINE,
+ current_x - 1, 0,
+ current_x - 1, tree_view->priv->height);
}
}
@@ -4630,18 +4668,18 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (draw_hgrid_lines)
{
if (background_area.y > 0)
- gdk_draw_line (event->window,
- tree_view->priv->grid_line_gc,
- background_area.x, background_area.y,
- background_area.x + background_area.width,
- background_area.y);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_GRID_LINE,
+ background_area.x, background_area.y,
+ background_area.x + background_area.width,
+ background_area.y);
if (y_offset + max_height >= event->area.height)
- gdk_draw_line (event->window,
- tree_view->priv->grid_line_gc,
- background_area.x, background_area.y + max_height,
- background_area.x + background_area.width,
- background_area.y + max_height);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_GRID_LINE,
+ background_area.x, background_area.y + max_height,
+ background_area.x + background_area.width,
+ background_area.y + max_height);
}
if (gtk_tree_view_is_expander_column (tree_view, column))
@@ -4733,21 +4771,21 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if ((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT
&& depth > 1)
{
- gdk_draw_line (event->window,
- tree_view->priv->tree_line_gc,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y1,
- x + tree_view->priv->expander_size * (depth - 1.1) * mult,
- y1);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_TREE_LINE,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y1,
+ x + tree_view->priv->expander_size * (depth - 1.1) * mult,
+ y1);
}
else if (depth > 1)
{
- gdk_draw_line (event->window,
- tree_view->priv->tree_line_gc,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y1,
- x + tree_view->priv->expander_size * (depth - 0.5) * mult,
- y1);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_TREE_LINE,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y1,
+ x + tree_view->priv->expander_size * (depth - 0.5) * mult,
+ y1);
}
if (depth > 1)
@@ -4757,19 +4795,19 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
GtkRBTree *tmp_tree;
if (!_gtk_rbtree_next (tree, node))
- gdk_draw_line (event->window,
- tree_view->priv->tree_line_gc,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y0,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y1);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_TREE_LINE,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y0,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y1);
else
- gdk_draw_line (event->window,
- tree_view->priv->tree_line_gc,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y0,
- x + tree_view->priv->expander_size * (depth - 1.5) * mult,
- y2);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_TREE_LINE,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y0,
+ x + tree_view->priv->expander_size * (depth - 1.5) * mult,
+ y2);
tmp_node = tree->parent_node;
tmp_tree = tree->parent_tree;
@@ -4777,12 +4815,12 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
for (i = depth - 2; i > 0; i--)
{
if (_gtk_rbtree_next (tmp_tree, tmp_node))
- gdk_draw_line (event->window,
- tree_view->priv->tree_line_gc,
- x + tree_view->priv->expander_size * (i - 0.5) * mult,
- y0,
- x + tree_view->priv->expander_size * (i - 0.5) * mult,
- y2);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_TREE_LINE,
+ x + tree_view->priv->expander_size * (i - 0.5) * mult,
+ y0,
+ x + tree_view->priv->expander_size * (i - 0.5) * mult,
+ y2);
tmp_node = tmp_tree->parent_node;
tmp_tree = tmp_tree->parent_tree;
@@ -4866,12 +4904,12 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (highlight_y >= 0)
{
- gdk_draw_line (event->window,
- widget->style->fg_gc[gtk_widget_get_state (widget)],
- rtl ? highlight_x + expander_cell_width : highlight_x,
- highlight_y,
- rtl ? 0 : bin_window_width,
- highlight_y);
+ gtk_tree_view_draw_line (tree_view, event->window,
+ GTK_TREE_VIEW_FOREGROUND_LINE,
+ rtl ? highlight_x + expander_cell_width : highlight_x,
+ highlight_y,
+ rtl ? 0 : bin_window_width,
+ highlight_y);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]