forked from AuroraMiddleware/gtk
treeview: Convert GtkTreeViewColumn rendering to Cairo
This commit is contained in:
parent
b259dd9aba
commit
f085bc67cd
@ -439,10 +439,9 @@ gboolean _gtk_tree_selection_row_is_selectable (GtkTreeSelection *sele
|
||||
GtkTreePath *path);
|
||||
|
||||
void _gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
|
||||
GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
const GdkRectangle *expose_area,
|
||||
guint flags);
|
||||
void _gtk_tree_view_column_get_focus_area (GtkTreeViewColumn *tree_column,
|
||||
const GdkRectangle *background_area,
|
||||
@ -453,10 +452,9 @@ gboolean _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_colu
|
||||
gboolean left,
|
||||
gboolean right);
|
||||
void _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
|
||||
GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
const GdkRectangle *expose_area,
|
||||
guint flags);
|
||||
void _gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column,
|
||||
gboolean install_handler);
|
||||
|
@ -4390,6 +4390,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
gint grid_line_width;
|
||||
gboolean got_pointer = FALSE;
|
||||
gboolean draw_vgrid_lines, draw_hgrid_lines;
|
||||
cairo_t *cr;
|
||||
|
||||
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
||||
|
||||
@ -4410,6 +4411,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
if (event->area.height < 0)
|
||||
return TRUE;
|
||||
|
||||
cr = gdk_cairo_create (event->window);
|
||||
gdk_cairo_region (cr, event->region);
|
||||
cairo_clip (cr);
|
||||
|
||||
validate_visible_area (tree_view);
|
||||
|
||||
style = gtk_widget_get_style (widget);
|
||||
@ -4437,7 +4442,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
}
|
||||
|
||||
if (node == NULL)
|
||||
return TRUE;
|
||||
{
|
||||
cairo_destroy (cr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* find the path for the node */
|
||||
path = _gtk_tree_view_find_path ((GtkTreeView *)widget,
|
||||
@ -4731,10 +4739,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
cell_area.y + cell_area.height / 2);
|
||||
else
|
||||
_gtk_tree_view_column_cell_render (column,
|
||||
event->window,
|
||||
cr,
|
||||
&background_area,
|
||||
&cell_area,
|
||||
&event->area,
|
||||
flags);
|
||||
if (TREE_VIEW_DRAW_EXPANDERS(tree_view)
|
||||
&& (node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT)
|
||||
@ -4766,10 +4773,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
cell_area.y + cell_area.height / 2);
|
||||
else
|
||||
_gtk_tree_view_column_cell_render (column,
|
||||
event->window,
|
||||
cr,
|
||||
&background_area,
|
||||
&cell_area,
|
||||
&event->area,
|
||||
flags);
|
||||
}
|
||||
|
||||
@ -4869,10 +4875,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
(column == tree_view->priv->edited_column)))
|
||||
{
|
||||
_gtk_tree_view_column_cell_draw_focus (column,
|
||||
event->window,
|
||||
cr,
|
||||
&background_area,
|
||||
&cell_area,
|
||||
&event->area,
|
||||
flags);
|
||||
}
|
||||
|
||||
@ -5059,6 +5064,8 @@ done:
|
||||
if (drag_dest_path)
|
||||
gtk_tree_path_free (drag_dest_path);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -13883,21 +13890,19 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
|
||||
if (gtk_tree_view_column_cell_is_visible (column))
|
||||
{
|
||||
if (is_separator)
|
||||
gtk_paint_hline (style,
|
||||
drawable,
|
||||
GTK_STATE_NORMAL,
|
||||
&cell_area,
|
||||
widget,
|
||||
NULL,
|
||||
cell_area.x,
|
||||
cell_area.x + cell_area.width,
|
||||
cell_area.y + cell_area.height / 2);
|
||||
gtk_cairo_paint_hline (style,
|
||||
cr,
|
||||
GTK_STATE_NORMAL,
|
||||
widget,
|
||||
NULL,
|
||||
cell_area.x,
|
||||
cell_area.x + cell_area.width,
|
||||
cell_area.y + cell_area.height / 2);
|
||||
else
|
||||
_gtk_tree_view_column_cell_render (column,
|
||||
drawable,
|
||||
cr,
|
||||
&background_area,
|
||||
&cell_area,
|
||||
&expose_area,
|
||||
0);
|
||||
}
|
||||
cell_offset += column->width;
|
||||
|
@ -2670,12 +2670,11 @@ enum {
|
||||
|
||||
static gboolean
|
||||
gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
guint flags,
|
||||
gint action,
|
||||
const GdkRectangle *expose_area, /* RENDER */
|
||||
GdkRectangle *focus_rectangle, /* FOCUS */
|
||||
GtkCellEditable **editable_widget, /* EVENT */
|
||||
GdkEvent *event, /* EVENT */
|
||||
@ -2684,7 +2683,6 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
GList *list;
|
||||
GdkRectangle real_cell_area;
|
||||
GdkRectangle real_background_area;
|
||||
GdkRectangle real_expose_area = *cell_area;
|
||||
gint depth = 0;
|
||||
gint expand_cell_count = 0;
|
||||
gint full_requested_width = 0;
|
||||
@ -2828,13 +2826,12 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
/* RENDER */
|
||||
if (action == CELL_ACTION_RENDER)
|
||||
{
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
&rtl_background_area,
|
||||
&rtl_cell_area,
|
||||
&real_expose_area,
|
||||
flags);
|
||||
gtk_cell_renderer_render_cairo (info->cell,
|
||||
cr,
|
||||
tree_column->tree_view,
|
||||
&rtl_background_area,
|
||||
&rtl_cell_area,
|
||||
flags);
|
||||
}
|
||||
/* FOCUS */
|
||||
else if (action == CELL_ACTION_FOCUS)
|
||||
@ -2997,13 +2994,12 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
/* RENDER */
|
||||
if (action == CELL_ACTION_RENDER)
|
||||
{
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
&rtl_background_area,
|
||||
&rtl_cell_area,
|
||||
&real_expose_area,
|
||||
flags);
|
||||
gtk_cell_renderer_render_cairo (info->cell,
|
||||
cr,
|
||||
tree_column->tree_view,
|
||||
&rtl_background_area,
|
||||
&rtl_cell_area,
|
||||
flags);
|
||||
}
|
||||
/* FOCUS */
|
||||
else if (action == CELL_ACTION_FOCUS)
|
||||
@ -3147,10 +3143,9 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
/**
|
||||
* gtk_tree_view_column_cell_render:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
* @window: a #GdkDrawable to draw to
|
||||
* @cr: cairo context to draw to
|
||||
* @background_area: entire cell area (including tree expanders and maybe padding on the sides)
|
||||
* @cell_area: area normally rendered by a cell renderer
|
||||
* @expose_area: area that actually needs updating
|
||||
* @flags: flags that affect rendering
|
||||
*
|
||||
* Renders the cell contained by #tree_column. This is used primarily by the
|
||||
@ -3158,25 +3153,27 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
**/
|
||||
void
|
||||
_gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
|
||||
GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
const GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
g_return_if_fail (cr != NULL);
|
||||
g_return_if_fail (background_area != NULL);
|
||||
g_return_if_fail (cell_area != NULL);
|
||||
g_return_if_fail (expose_area != NULL);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
gtk_tree_view_column_cell_process_action (tree_column,
|
||||
window,
|
||||
cr,
|
||||
background_area,
|
||||
cell_area,
|
||||
flags,
|
||||
CELL_ACTION_RENDER,
|
||||
expose_area,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -3191,12 +3188,12 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
|
||||
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
|
||||
|
||||
return gtk_tree_view_column_cell_process_action (tree_column,
|
||||
NULL,
|
||||
NULL,
|
||||
background_area,
|
||||
cell_area,
|
||||
flags,
|
||||
CELL_ACTION_EVENT,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
editable_widget,
|
||||
event,
|
||||
path_string);
|
||||
@ -3214,7 +3211,6 @@ _gtk_tree_view_column_get_focus_area (GtkTreeViewColumn *tree_column,
|
||||
cell_area,
|
||||
0,
|
||||
CELL_ACTION_FOCUS,
|
||||
NULL,
|
||||
focus_area,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
@ -3470,16 +3466,17 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
|
||||
|
||||
void
|
||||
_gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
|
||||
GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
const GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
{
|
||||
gint focus_line_width;
|
||||
GtkStateType cell_state;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
|
||||
"focus-line-width", &focus_line_width, NULL);
|
||||
if (tree_column->editable_widget)
|
||||
@ -3503,28 +3500,26 @@ _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
|
||||
{
|
||||
GdkRectangle focus_rectangle;
|
||||
gtk_tree_view_column_cell_process_action (tree_column,
|
||||
window,
|
||||
cr,
|
||||
background_area,
|
||||
cell_area,
|
||||
flags,
|
||||
CELL_ACTION_FOCUS,
|
||||
expose_area,
|
||||
&focus_rectangle,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
|
||||
(flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
|
||||
(flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
|
||||
gtk_paint_focus (gtk_widget_get_style (tree_column->tree_view),
|
||||
window,
|
||||
cell_state,
|
||||
cell_area,
|
||||
tree_column->tree_view,
|
||||
"treeview",
|
||||
focus_rectangle.x,
|
||||
focus_rectangle.y,
|
||||
focus_rectangle.width,
|
||||
focus_rectangle.height);
|
||||
gtk_cairo_paint_focus (gtk_widget_get_style (tree_column->tree_view),
|
||||
cr,
|
||||
cell_state,
|
||||
tree_column->tree_view,
|
||||
"treeview",
|
||||
focus_rectangle.x,
|
||||
focus_rectangle.y,
|
||||
focus_rectangle.width,
|
||||
focus_rectangle.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user