forked from AuroraMiddleware/gtk
treeview: Use Cairo for all bin window drawing
This commit is contained in:
parent
62f5fdc856
commit
f679516ce1
@ -326,6 +326,7 @@ static void gtk_tree_view_queue_draw_arrow (GtkTreeView
|
|||||||
GtkRBTree *tree,
|
GtkRBTree *tree,
|
||||||
GtkRBNode *node);
|
GtkRBNode *node);
|
||||||
static void gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
static void gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
||||||
|
cairo_t *cr,
|
||||||
GtkRBTree *tree,
|
GtkRBTree *tree,
|
||||||
GtkRBNode *node,
|
GtkRBNode *node,
|
||||||
gint x,
|
gint x,
|
||||||
@ -4254,16 +4255,14 @@ typedef enum {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_tree_view_draw_line (GtkTreeView *tree_view,
|
gtk_tree_view_draw_line (GtkTreeView *tree_view,
|
||||||
GdkWindow *window,
|
cairo_t *cr,
|
||||||
GtkTreeViewLineType type,
|
GtkTreeViewLineType type,
|
||||||
int x1,
|
int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int x2,
|
int x2,
|
||||||
int y2)
|
int y2)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_save (cr);
|
||||||
|
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -4297,12 +4296,12 @@ gtk_tree_view_draw_line (GtkTreeView *tree_view,
|
|||||||
cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
|
cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
|
gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
|
||||||
GdkEventExpose *event,
|
cairo_t *cr,
|
||||||
gint n_visible_columns)
|
gint n_visible_columns)
|
||||||
{
|
{
|
||||||
GList *list = tree_view->priv->columns;
|
GList *list = tree_view->priv->columns;
|
||||||
@ -4327,7 +4326,7 @@ gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
|
|||||||
|
|
||||||
current_x += column->width;
|
current_x += column->width;
|
||||||
|
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_GRID_LINE,
|
GTK_TREE_VIEW_GRID_LINE,
|
||||||
current_x - 1, 0,
|
current_x - 1, 0,
|
||||||
current_x - 1, tree_view->priv->height);
|
current_x - 1, tree_view->priv->height);
|
||||||
@ -4416,11 +4415,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
if (tree_view->priv->height < bin_window_height)
|
if (tree_view->priv->height < bin_window_height)
|
||||||
{
|
{
|
||||||
gtk_paint_flat_box (style,
|
gtk_cairo_paint_flat_box (style,
|
||||||
event->window,
|
cr,
|
||||||
gtk_widget_get_state (widget),
|
gtk_widget_get_state (widget),
|
||||||
GTK_SHADOW_NONE,
|
GTK_SHADOW_NONE,
|
||||||
&event->area,
|
|
||||||
widget,
|
widget,
|
||||||
"cell_even",
|
"cell_even",
|
||||||
0, tree_view->priv->height,
|
0, tree_view->priv->height,
|
||||||
@ -4682,11 +4680,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
g_snprintf (new_detail, 127, "%s_middle", detail);
|
g_snprintf (new_detail, 127, "%s_middle", detail);
|
||||||
|
|
||||||
gtk_paint_flat_box (style,
|
gtk_cairo_paint_flat_box (style,
|
||||||
event->window,
|
cr,
|
||||||
state,
|
state,
|
||||||
GTK_SHADOW_NONE,
|
GTK_SHADOW_NONE,
|
||||||
&event->area,
|
|
||||||
widget,
|
widget,
|
||||||
new_detail,
|
new_detail,
|
||||||
background_area.x,
|
background_area.x,
|
||||||
@ -4715,10 +4712,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
expander_cell_width = cell_area.width;
|
expander_cell_width = cell_area.width;
|
||||||
|
|
||||||
if (is_separator)
|
if (is_separator)
|
||||||
gtk_paint_hline (style,
|
gtk_cairo_paint_hline (style,
|
||||||
event->window,
|
cr,
|
||||||
state,
|
state,
|
||||||
&cell_area,
|
|
||||||
widget,
|
widget,
|
||||||
NULL,
|
NULL,
|
||||||
cell_area.x,
|
cell_area.x,
|
||||||
@ -4741,6 +4737,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_view_draw_arrow (GTK_TREE_VIEW (widget),
|
gtk_tree_view_draw_arrow (GTK_TREE_VIEW (widget),
|
||||||
|
cr,
|
||||||
tree,
|
tree,
|
||||||
node,
|
node,
|
||||||
pointer_x, pointer_y);
|
pointer_x, pointer_y);
|
||||||
@ -4749,10 +4746,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (is_separator)
|
if (is_separator)
|
||||||
gtk_paint_hline (style,
|
gtk_cairo_paint_hline (style,
|
||||||
event->window,
|
cr,
|
||||||
state,
|
state,
|
||||||
&cell_area,
|
|
||||||
widget,
|
widget,
|
||||||
NULL,
|
NULL,
|
||||||
cell_area.x,
|
cell_area.x,
|
||||||
@ -4769,14 +4765,14 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
if (draw_hgrid_lines)
|
if (draw_hgrid_lines)
|
||||||
{
|
{
|
||||||
if (background_area.y > 0)
|
if (background_area.y > 0)
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_GRID_LINE,
|
GTK_TREE_VIEW_GRID_LINE,
|
||||||
background_area.x, background_area.y,
|
background_area.x, background_area.y,
|
||||||
background_area.x + background_area.width,
|
background_area.x + background_area.width,
|
||||||
background_area.y);
|
background_area.y);
|
||||||
|
|
||||||
if (y_offset + max_height >= event->area.height)
|
if (y_offset + max_height >= event->area.height)
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_GRID_LINE,
|
GTK_TREE_VIEW_GRID_LINE,
|
||||||
background_area.x, background_area.y + max_height,
|
background_area.x, background_area.y + max_height,
|
||||||
background_area.x + background_area.width,
|
background_area.x + background_area.width,
|
||||||
@ -4798,7 +4794,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
if ((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT
|
if ((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT
|
||||||
&& depth > 1)
|
&& depth > 1)
|
||||||
{
|
{
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_TREE_LINE,
|
GTK_TREE_VIEW_TREE_LINE,
|
||||||
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
||||||
y1,
|
y1,
|
||||||
@ -4807,7 +4803,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
else if (depth > 1)
|
else if (depth > 1)
|
||||||
{
|
{
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_TREE_LINE,
|
GTK_TREE_VIEW_TREE_LINE,
|
||||||
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
||||||
y1,
|
y1,
|
||||||
@ -4822,14 +4818,14 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
GtkRBTree *tmp_tree;
|
GtkRBTree *tmp_tree;
|
||||||
|
|
||||||
if (!_gtk_rbtree_next (tree, node))
|
if (!_gtk_rbtree_next (tree, node))
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_TREE_LINE,
|
GTK_TREE_VIEW_TREE_LINE,
|
||||||
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
||||||
y0,
|
y0,
|
||||||
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
||||||
y1);
|
y1);
|
||||||
else
|
else
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_TREE_LINE,
|
GTK_TREE_VIEW_TREE_LINE,
|
||||||
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
x + tree_view->priv->expander_size * (depth - 1.5) * mult,
|
||||||
y0,
|
y0,
|
||||||
@ -4842,7 +4838,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
for (i = depth - 2; i > 0; i--)
|
for (i = depth - 2; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (_gtk_rbtree_next (tmp_tree, tmp_node))
|
if (_gtk_rbtree_next (tmp_tree, tmp_node))
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_TREE_LINE,
|
GTK_TREE_VIEW_TREE_LINE,
|
||||||
x + tree_view->priv->expander_size * (i - 0.5) * mult,
|
x + tree_view->priv->expander_size * (i - 0.5) * mult,
|
||||||
y0,
|
y0,
|
||||||
@ -4901,10 +4897,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
gdk_drawable_get_size (tree_view->priv->bin_window,
|
gdk_drawable_get_size (tree_view->priv->bin_window,
|
||||||
&width, NULL);
|
&width, NULL);
|
||||||
|
|
||||||
gtk_paint_focus (style,
|
gtk_cairo_paint_focus (style,
|
||||||
tree_view->priv->bin_window,
|
cr,
|
||||||
gtk_widget_get_state (widget),
|
gtk_widget_get_state (widget),
|
||||||
&event->area,
|
|
||||||
widget,
|
widget,
|
||||||
(is_first
|
(is_first
|
||||||
? (is_last ? "treeview-drop-indicator" : "treeview-drop-indicator-left" )
|
? (is_last ? "treeview-drop-indicator" : "treeview-drop-indicator-left" )
|
||||||
@ -4918,7 +4913,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
if (highlight_y >= 0)
|
if (highlight_y >= 0)
|
||||||
{
|
{
|
||||||
gtk_tree_view_draw_line (tree_view, event->window,
|
gtk_tree_view_draw_line (tree_view, cr,
|
||||||
GTK_TREE_VIEW_FOREGROUND_LINE,
|
GTK_TREE_VIEW_FOREGROUND_LINE,
|
||||||
rtl ? highlight_x + expander_cell_width : highlight_x,
|
rtl ? highlight_x + expander_cell_width : highlight_x,
|
||||||
highlight_y,
|
highlight_y,
|
||||||
@ -4956,10 +4951,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
tmp_height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
|
tmp_height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_paint_focus (style,
|
gtk_cairo_paint_focus (style,
|
||||||
tree_view->priv->bin_window,
|
cr,
|
||||||
focus_rect_state,
|
focus_rect_state,
|
||||||
&event->area,
|
|
||||||
widget,
|
widget,
|
||||||
(is_first
|
(is_first
|
||||||
? (is_last ? "treeview" : "treeview-left" )
|
? (is_last ? "treeview" : "treeview-left" )
|
||||||
@ -5029,7 +5023,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
|||||||
while (y_offset < event->area.height);
|
while (y_offset < event->area.height);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gtk_tree_view_draw_grid_lines (tree_view, event, n_visible_columns);
|
gtk_tree_view_draw_grid_lines (tree_view, cr, n_visible_columns);
|
||||||
|
|
||||||
if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
|
if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
|
||||||
{
|
{
|
||||||
@ -9514,6 +9508,7 @@ gtk_tree_view_queue_draw_path (GtkTreeView *tree_view,
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
||||||
|
cairo_t *cr,
|
||||||
GtkRBTree *tree,
|
GtkRBTree *tree,
|
||||||
GtkRBNode *node,
|
GtkRBNode *node,
|
||||||
/* in bin_window coordinates */
|
/* in bin_window coordinates */
|
||||||
@ -9576,10 +9571,9 @@ gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
|||||||
else
|
else
|
||||||
expander_style = GTK_EXPANDER_COLLAPSED;
|
expander_style = GTK_EXPANDER_COLLAPSED;
|
||||||
|
|
||||||
gtk_paint_expander (gtk_widget_get_style (widget),
|
gtk_cairo_paint_expander (gtk_widget_get_style (widget),
|
||||||
tree_view->priv->bin_window,
|
cr,
|
||||||
state,
|
state,
|
||||||
&area,
|
|
||||||
widget,
|
widget,
|
||||||
"treeview",
|
"treeview",
|
||||||
area.x + area.width / 2,
|
area.x + area.width / 2,
|
||||||
|
Loading…
Reference in New Issue
Block a user