[Xfce4-commits] <thunar:master> Use cairo to draw the hovered item.
Nick Schermer
noreply at xfce.org
Sat Dec 15 21:58:01 CET 2012
Updating branch refs/heads/master
to c1b8dc11319a3c7b8e4ca56b82cfb9dea81933af (commit)
from 92e4868d1e2075f99b7ded4142c413cafc783309 (commit)
commit c1b8dc11319a3c7b8e4ca56b82cfb9dea81933af
Author: Nick Schermer <nick at xfce.org>
Date: Sat Dec 15 21:56:17 2012 +0100
Use cairo to draw the hovered item.
thunar/thunar-icon-renderer.c | 56 ++++++++++++++++++++++++++++------------
1 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c
index 3a61b68..f42cdc2 100644
--- a/thunar/thunar-icon-renderer.c
+++ b/thunar/thunar-icon-renderer.c
@@ -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;
@@ -332,6 +331,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,
GtkWidget *widget,
@@ -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 */
More information about the Xfce4-commits
mailing list