summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-01-29 10:48:00 +0000
committerRichard Hughes <richard@hughsie.com>2013-01-29 10:48:00 +0000
commit6be98e8052cb806a28d6b71b51a6aad2c5930dab (patch)
treed55fcfd7d905912d85ff1081cad4639d22c3a86a
parentc677ce7e49f28b8800390de57cfc542773f7ed71 (diff)
downloadcolord-gtk-6be98e8052cb806a28d6b71b51a6aad2c5930dab.tar.gz
Give the sample widget slightly curved corners and a gray outline
-rw-r--r--libcolord-gtk/cd-sample-widget.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/libcolord-gtk/cd-sample-widget.c b/libcolord-gtk/cd-sample-widget.c
index b5497fa..036f26c 100644
--- a/libcolord-gtk/cd-sample-widget.c
+++ b/libcolord-gtk/cd-sample-widget.c
@@ -22,6 +22,7 @@
#include "config.h"
#include <gtk/gtk.h>
+#include <math.h>
#include <colord.h>
#include "cd-sample-widget.h"
@@ -83,6 +84,33 @@ up_sample_set_property (GObject *object, guint prop_id, const GValue *value, GPa
}
/**
+ * cd_sample_widget_draw_rounded_rectangle:
+ **/
+static void
+cd_sample_widget_draw_rounded_rectangle (cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gdouble corner_radius)
+{
+ gdouble aspect = width / height;
+ gdouble radius = corner_radius / aspect;
+ gdouble degrees = M_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, x + width - radius, y + radius,
+ radius, -90 * degrees, 0 * degrees);
+ cairo_arc (cr, x + width - radius, y + height - radius,
+ radius, 0 * degrees, 90 * degrees);
+ cairo_arc (cr, x + radius, y + height - radius,
+ radius, 90 * degrees, 180 * degrees);
+ cairo_arc (cr, x + radius, y + radius,
+ radius, 180 * degrees, 270 * degrees);
+ cairo_close_path (cr);
+}
+
+/**
* cd_sample_widget_draw:
**/
static gboolean
@@ -98,8 +126,14 @@ cd_sample_widget_draw (GtkWidget *widget, cairo_t *cr)
gtk_widget_get_allocation (widget, &allocation);
cairo_save (cr);
cairo_set_source_rgb (cr, color->R, color->G, color->B);
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
- cairo_fill (cr);
+ cd_sample_widget_draw_rounded_rectangle (cr, 0, 0,
+ allocation.width,
+ allocation.height,
+ 10.5);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 1.0);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
cairo_restore (cr);
return FALSE;
}