summaryrefslogtreecommitdiff
path: root/eel/eel-gdk-extensions.c
diff options
context:
space:
mode:
Diffstat (limited to 'eel/eel-gdk-extensions.c')
-rw-r--r--eel/eel-gdk-extensions.c73
1 files changed, 62 insertions, 11 deletions
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 3d68d9a5..2da5bb03 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -420,6 +420,15 @@ eel_gdk_rgb_to_color_spec (const guint32 color)
* Return true if the given color is `dark'
*/
gboolean
+#if GTK_CHECK_VERSION(3,0,0)
+eel_gdk_rgba_is_dark (const GdkRGBA *color)
+{
+ int intensity;
+
+ intensity = ((((int) (color->red) >> 8) * 77)
+ + (((int) (color->green) >> 8) * 150)
+ + (((int) (color->blue) >> 8) * 28)) >> 8;
+#else
eel_gdk_color_is_dark (GdkColor *color)
{
int intensity;
@@ -427,6 +436,7 @@ eel_gdk_color_is_dark (GdkColor *color)
intensity = (((color->red >> 8) * 77)
+ ((color->green >> 8) * 150)
+ ((color->blue >> 8) * 28)) >> 8;
+#endif
return intensity < 128;
}
@@ -478,22 +488,34 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
void
#if GTK_CHECK_VERSION(3,0,0)
-eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+ GdkRGBA *text_color,
+ GdkRGBA *shadow_color,
+ int x,
+ int y,
+ PangoLayout *layout)
+{
+ cairo_save (cr);
+
+ gdk_cairo_set_source_rgba (cr, shadow_color);
+ cairo_move_to (cr, x+1, y+1);
+ pango_cairo_show_layout (cr, layout);
+
+ gdk_cairo_set_source_rgba (cr, text_color);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_restore (cr);
#else
eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
-#endif
GdkColor *text_color,
GdkColor *shadow_color,
- int x,
- int y,
+ int x,
+ int y,
PangoLayout *layout)
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr;
cr = gdk_cairo_create (drawable);
-#endif
gdk_cairo_set_source_color (cr, shadow_color);
cairo_move_to (cr, x+1, y+1);
@@ -503,13 +525,42 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
#endif
}
+#if GTK_CHECK_VERSION(3,0,0)
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1))
+#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
+
+void
+eel_make_color_inactive (GdkRGBA *color)
+{
+ double intensity, saturation;
+ gdouble t;
+
+ saturation = 0.7;
+ intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
+ color->red = SATURATE (color->red);
+ color->green = SATURATE (color->green);
+ color->blue = SATURATE (color->blue);
+
+ if (intensity > 0.5) {
+ color->red *= 0.9;
+ color->green *= 0.9;
+ color->blue *= 0.9;
+ } else {
+ color->red *= 1.25;
+ color->green *= 1.25;
+ color->blue *= 1.25;
+ }
+
+ color->red = CLAMP_COLOR (color->red);
+ color->green = CLAMP_COLOR (color->green);
+ color->blue = CLAMP_COLOR (color->blue);
+}
+#endif
+
#if ! defined (EEL_OMIT_SELF_CHECK)
static char *