Skip to content
Snippets Groups Projects
Commit c1b8dc11 authored by Nick Schermer's avatar Nick Schermer
Browse files

Use cairo to draw the hovered item.

parent 92e4868d
No related branches found
No related tags found
No related merge requests found
......@@ -309,10 +309,9 @@ thunar_icon_renderer_get_size (GtkCellRenderer *renderer,
static void
thunar_icon_renderer_mask_selected (cairo_t *cr,
GtkWidget *widget)
thunar_icon_renderer_color_selected (cairo_t *cr,
GtkWidget *widget)
{
cairo_pattern_t *source;
GtkStateType state;
......@@ -331,6 +330,26 @@ thunar_icon_renderer_mask_selected (cairo_t *cr,
static void
thunar_icon_renderer_color_lighten (cairo_t *cr,
GtkWidget *widget)
{
cairo_pattern_t *source;
cairo_save (cr);
source = cairo_pattern_reference (cairo_get_source (cr));
cairo_set_source_rgb (cr, .15, .15, .15);
cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
cairo_mask (cr, source);
cairo_pattern_destroy (source);
cairo_restore (cr);
}
static void
thunar_icon_renderer_render (GtkCellRenderer *renderer,
GdkWindow *window,
......@@ -359,7 +378,8 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
cairo_t *cr;
gdouble alpha;
gint emblem_size;
gboolean mask_selected;
gboolean color_selected;
gboolean color_lighten;
if (G_UNLIKELY (icon_renderer->file == NULL))
return;
......@@ -405,7 +425,9 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
icon_area.x = cell_area->x + (cell_area->width - icon_area.width) / 2;
icon_area.y = cell_area->y + (cell_area->height - icon_area.height) / 2;
mask_selected = (flags & GTK_CELL_RENDERER_SELECTED) != 0 && icon_renderer->follow_state;
/* bools for cairo transformations */
color_selected = (flags & GTK_CELL_RENDERER_SELECTED) != 0 && icon_renderer->follow_state;
color_lighten = (flags & GTK_CELL_RENDERER_PRELIT) != 0 && icon_renderer->follow_state;
/* create the context */
cr = gdk_cairo_create (window);
......@@ -431,14 +453,6 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
}
g_object_unref (G_OBJECT (clipboard));
/* colorize the icon if we should follow the selection state */
if ((flags & GTK_CELL_RENDERER_PRELIT) != 0 && icon_renderer->follow_state)
{
temp = exo_gdk_pixbuf_spotlight (icon);
g_object_unref (G_OBJECT (icon));
icon = temp;
}
/* check if we should render an insensitive icon */
if (G_UNLIKELY (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE || !renderer->sensitive))
{
......@@ -463,9 +477,13 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
gdk_cairo_rectangle (cr, &draw_area);
cairo_paint_with_alpha (cr, alpha);
/* paint the lighten mask */
if (color_lighten)
thunar_icon_renderer_color_lighten (cr, widget);
/* paint the selected mask */
if (mask_selected)
thunar_icon_renderer_mask_selected (cr, widget);
if (color_selected)
thunar_icon_renderer_color_selected (cr, widget);
}
/* release the file's icon */
......@@ -552,9 +570,13 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
gdk_cairo_rectangle (cr, &draw_area);
cairo_paint (cr);
/* paint the lighten mask */
if (color_lighten)
thunar_icon_renderer_color_lighten (cr, widget);
/* paint the selected mask */
if (mask_selected)
thunar_icon_renderer_mask_selected (cr, widget);
if (color_selected)
thunar_icon_renderer_color_selected (cr, widget);
}
/* release the emblem */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment