134 lines
5.2 KiB
Diff
134 lines
5.2 KiB
Diff
From dab2e6b44c57e14dd373adf04d4530bd5915f582 Mon Sep 17 00:00:00 2001
|
|
From: William Jon McCann <jmccann@redhat.com>
|
|
Date: Wed, 23 Sep 2009 20:23:31 -0400
|
|
Subject: [PATCH 2/3] Use a rounded instead of curved rectangle
|
|
|
|
---
|
|
plugins/media-keys/gsd-media-keys-window.c | 101 +++++++++++++---------------
|
|
1 files changed, 48 insertions(+), 53 deletions(-)
|
|
|
|
diff --git a/plugins/media-keys/gsd-media-keys-window.c b/plugins/media-keys/gsd-media-keys-window.c
|
|
index f890344..cffbe3e 100644
|
|
--- a/plugins/media-keys/gsd-media-keys-window.c
|
|
+++ b/plugins/media-keys/gsd-media-keys-window.c
|
|
@@ -260,59 +260,54 @@ gsd_media_keys_window_set_volume_level (GsdMediaKeysWindow *window,
|
|
}
|
|
|
|
static void
|
|
-curved_rectangle (cairo_t *cr,
|
|
- double x0,
|
|
- double y0,
|
|
- double width,
|
|
- double height,
|
|
- double radius)
|
|
-{
|
|
- double x1;
|
|
- double y1;
|
|
-
|
|
- x1 = x0 + width;
|
|
- y1 = y0 + height;
|
|
-
|
|
- if (!width || !height) {
|
|
- return;
|
|
- }
|
|
-
|
|
- if (width / 2 < radius) {
|
|
- if (height / 2 < radius) {
|
|
- cairo_move_to (cr, x0, (y0 + y1) / 2);
|
|
- cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1) / 2, y0);
|
|
- cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1) / 2);
|
|
- cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0) / 2, y1);
|
|
- cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1) / 2);
|
|
- } else {
|
|
- cairo_move_to (cr, x0, y0 + radius);
|
|
- cairo_curve_to (cr, x0, y0, x0, y0, (x0 + x1) / 2, y0);
|
|
- cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
|
|
- cairo_line_to (cr, x1, y1 - radius);
|
|
- cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0) / 2, y1);
|
|
- cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - radius);
|
|
- }
|
|
- } else {
|
|
- if (height / 2 < radius) {
|
|
- cairo_move_to (cr, x0, (y0 + y1) / 2);
|
|
- cairo_curve_to (cr, x0, y0, x0 , y0, x0 + radius, y0);
|
|
- cairo_line_to (cr, x1 - radius, y0);
|
|
- cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1) / 2);
|
|
- cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
|
|
- cairo_line_to (cr, x0 + radius, y1);
|
|
- cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1) / 2);
|
|
- } else {
|
|
- cairo_move_to (cr, x0, y0 + radius);
|
|
- cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
|
|
- cairo_line_to (cr, x1 - radius, y0);
|
|
- cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
|
|
- cairo_line_to (cr, x1, y1 - radius);
|
|
- cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
|
|
- cairo_line_to (cr, x0 + radius, y1);
|
|
- cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - radius);
|
|
- }
|
|
- }
|
|
-
|
|
+rounded_rectangle (cairo_t* cr,
|
|
+ gdouble aspect,
|
|
+ gdouble x,
|
|
+ gdouble y,
|
|
+ gdouble corner_radius,
|
|
+ gdouble width,
|
|
+ gdouble height)
|
|
+{
|
|
+ gdouble radius = corner_radius / aspect;
|
|
+
|
|
+ cairo_move_to (cr, x + radius, y);
|
|
+
|
|
+ cairo_line_to (cr,
|
|
+ x + width - radius,
|
|
+ y);
|
|
+ cairo_arc (cr,
|
|
+ x + width - radius,
|
|
+ y + radius,
|
|
+ radius,
|
|
+ -90.0f * G_PI / 180.0f,
|
|
+ 0.0f * G_PI / 180.0f);
|
|
+ cairo_line_to (cr,
|
|
+ x + width,
|
|
+ y + height - radius);
|
|
+ cairo_arc (cr,
|
|
+ x + width - radius,
|
|
+ y + height - radius,
|
|
+ radius,
|
|
+ 0.0f * G_PI / 180.0f,
|
|
+ 90.0f * G_PI / 180.0f);
|
|
+ cairo_line_to (cr,
|
|
+ x + radius,
|
|
+ y + height);
|
|
+ cairo_arc (cr,
|
|
+ x + radius,
|
|
+ y + height - radius,
|
|
+ radius,
|
|
+ 90.0f * G_PI / 180.0f,
|
|
+ 180.0f * G_PI / 180.0f);
|
|
+ cairo_line_to (cr,
|
|
+ x,
|
|
+ y + radius);
|
|
+ cairo_arc (cr,
|
|
+ x + radius,
|
|
+ y + radius,
|
|
+ radius,
|
|
+ 180.0f * G_PI / 180.0f,
|
|
+ 270.0f * G_PI / 180.0f);
|
|
cairo_close_path (cr);
|
|
}
|
|
|
|
@@ -799,7 +794,7 @@ on_expose_event (GtkWidget *widget,
|
|
cairo_paint (cr);
|
|
|
|
/* draw a box */
|
|
- curved_rectangle (cr, 0.5, 0.5, width-1, height-1, height / 10);
|
|
+ rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
|
|
color = GTK_WIDGET (window)->style->bg [GTK_STATE_NORMAL];
|
|
r = (float)color.red / 65535.0;
|
|
g = (float)color.green / 65535.0;
|
|
--
|
|
1.6.5.rc2
|
|
|