summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-gdk-extensions.c49
-rw-r--r--eel/eel-gdk-extensions.h10
2 files changed, 42 insertions, 17 deletions
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index bbb8a69a..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,22 +525,19 @@ 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, G_MAXUSHORT))
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1))
#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
void
-eel_make_color_inactive (GdkColor *color)
+eel_make_color_inactive (GdkRGBA *color)
{
double intensity, saturation;
- gushort t;
+ gdouble t;
saturation = 0.7;
intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
@@ -526,7 +545,7 @@ eel_make_color_inactive (GdkColor *color)
color->green = SATURATE (color->green);
color->blue = SATURATE (color->blue);
- if (intensity > G_MAXUSHORT / 2) {
+ if (intensity > 0.5) {
color->red *= 0.9;
color->green *= 0.9;
color->blue *= 0.9;
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index fedb2c22..ad94ddbd 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -114,7 +114,11 @@ guint32 eel_gdk_color_to_rgb (const GdkColor
GdkColor eel_gdk_rgb_to_color (guint32 color);
char * eel_gdk_rgb_to_color_spec (guint32 color);
+#if GTK_CHECK_VERSION(3,0,0)
+gboolean eel_gdk_rgba_is_dark (const GdkRGBA *color);
+#else
gboolean eel_gdk_color_is_dark (GdkColor *color);
+#endif
/* Wrapper for XParseGeometry */
EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string,
@@ -124,15 +128,17 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char
guint *height_return);
#if GTK_CHECK_VERSION(3,0,0)
void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+ GdkRGBA *text_color,
+ GdkRGBA *shadow_color,
#else
void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
-#endif
GdkColor *text_color,
GdkColor *shadow_color,
+#endif
int x,
int y,
PangoLayout *layout);
#if GTK_CHECK_VERSION(3,0,0)
-void eel_make_color_inactive (GdkColor *color);
+void eel_make_color_inactive (GdkRGBA *color);
#endif
#endif /* EEL_GDK_EXTENSIONS_H */