From 3d956b10ee15264f93758422755378e758f7e74b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 24 Nov 2010 23:21:28 +0100 Subject: [PATCH] GtkStyleContext: handle prelight transitions --- gtk/gtkthemingengine.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 4b4450275e..b1db53861f 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1588,7 +1588,8 @@ render_frame_internal (GtkThemingEngine *engine, GdkRGBA *border_color; GtkBorderStyle border_style; gint border_width, radius; - gdouble d1, d2, m; + gdouble progress, d1, d2, m; + gboolean running; state = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, state, @@ -1598,6 +1599,33 @@ render_frame_internal (GtkThemingEngine *engine, "border-radius", &radius, NULL); + running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); + + if (running) + { + GtkStateFlags other_state; + GdkRGBA *other_color; + + if (state & GTK_STATE_FLAG_PRELIGHT) + { + other_state = state & ~(GTK_STATE_FLAG_PRELIGHT); + progress = 1 - progress; + } + else + other_state = state | GTK_STATE_FLAG_PRELIGHT; + + gtk_theming_engine_get (engine, other_state, + "border-color", &other_color, + NULL); + + border_color->red = CLAMP (border_color->red + ((other_color->red - border_color->red) * progress), 0, 1); + border_color->green = CLAMP (border_color->green + ((other_color->green - border_color->green) * progress), 0, 1); + border_color->blue = CLAMP (border_color->blue + ((other_color->blue - border_color->blue) * progress), 0, 1); + border_color->alpha = CLAMP (border_color->alpha + ((other_color->alpha - border_color->alpha) * progress), 0, 1); + + gdk_rgba_free (other_color); + } + cairo_save (cr); color_shade (border_color, 1.8, &lighter);