[gtk+/client-side-decorations: 22/92] Move drawing to gtkstyle.c, use colors from style
- From: Cody Russell <bratsche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/client-side-decorations: 22/92] Move drawing to gtkstyle.c, use colors from style
- Date: Fri, 16 Apr 2010 19:28:57 +0000 (UTC)
commit e7a8c9da4155fadfde4e88601a5c050d530a5fbd
Author: Kristian Høgsberg <krh redhat com>
Date: Thu May 21 13:56:56 2009 -0400
Move drawing to gtkstyle.c, use colors from style
gtk/gtkstyle.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
gtk/gtkwindow.c | 59 +--------------------------------------------
2 files changed, 71 insertions(+), 59 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index f18d76a..557f001 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -3491,6 +3491,69 @@ option_menu_get_props (GtkWidget *widget,
*indicator_spacing = default_option_indicator_spacing;
}
+static void
+paint_decorated_window (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ cairo_pattern_t *gradient;
+ cairo_t *cr;
+ const double hmargin = 2.5, vmargin = 2.5, radius = 5;
+ GdkColor *color;
+
+ if (width == -1)
+ width = widget->allocation.width;
+ if (height == -1)
+ height = widget->allocation.height;
+
+ cr = gdk_cairo_create (window);
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint (cr);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_arc (cr, hmargin + radius, vmargin + radius,
+ radius, M_PI, 3 * M_PI / 2);
+ cairo_line_to (cr, width - hmargin - radius, vmargin);
+ cairo_arc (cr, width - hmargin - radius, vmargin + radius,
+ radius, 3 * M_PI / 2, 2 * M_PI);
+ cairo_line_to (cr, width - hmargin, height - vmargin - radius);
+ cairo_arc (cr, width - hmargin - radius, height - vmargin - radius,
+ radius, 0, M_PI / 2);
+ cairo_line_to (cr, hmargin + radius, height - vmargin);
+ cairo_arc (cr, hmargin + radius, height - vmargin - radius,
+ radius, M_PI / 2, M_PI);
+ cairo_close_path (cr);
+
+ gradient = cairo_pattern_create_linear (width / 2 - 1, vmargin,
+ width / 2 + 1, height);
+ color = &style->bg[state_type];
+ cairo_pattern_add_color_stop_rgba (gradient, 0,
+ color->red / 65535.,
+ color->green / 65535.,
+ color->blue / 65535., 0.9);
+ cairo_pattern_add_color_stop_rgba (gradient, 0.8,
+ color->red / 65535.,
+ color->green / 65535.,
+ color->blue / 65535., 1.0);
+ cairo_set_source (cr, gradient);
+ cairo_fill_preserve (cr);
+
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
+ cairo_set_line_width (cr, 1);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
+}
+
static void
gtk_default_draw_box (GtkStyle *style,
GdkWindow *window,
@@ -3589,8 +3652,12 @@ gtk_default_draw_box (GtkStyle *style,
return;
}
- gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
- x, y, width, height);
+ if (strcmp (detail, "decoration") == 0)
+ paint_decorated_window (style, window, state_type, shadow_type,
+ area, widget, detail, x, y, width, height);
+ else
+ gtk_paint_shadow (style, window, state_type, shadow_type,
+ area, widget, detail, x, y, width, height);
if (detail && strcmp (detail, "optionmenu") == 0)
{
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 38fa5a2..99d5ca1 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6830,61 +6830,6 @@ gtk_window_compute_hints (GtkWindow *window,
***********************/
static void
-paint_decorated_window (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- const GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- cairo_pattern_t *gradient;
- cairo_t *cr;
- const double hmargin = 2.5, vmargin = 2.5, radius = 5;
-
- if (width == -1)
- width = widget->allocation.width;
- if (height == -1)
- height = widget->allocation.height;
-
- cr = gdk_cairo_create (window);
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint (cr);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_arc (cr, hmargin + radius, vmargin + radius,
- radius, M_PI, 3 * M_PI / 2);
- cairo_line_to (cr, width - hmargin - radius, vmargin);
- cairo_arc (cr, width - hmargin - radius, vmargin + radius,
- radius, 3 * M_PI / 2, 2 * M_PI);
- cairo_line_to (cr, width - hmargin, height - vmargin - radius);
- cairo_arc (cr, width - hmargin - radius, height - vmargin - radius,
- radius, 0, M_PI / 2);
- cairo_line_to (cr, hmargin + radius, height - vmargin);
- cairo_arc (cr, hmargin + radius, height - vmargin - radius,
- radius, M_PI / 2, M_PI);
- cairo_close_path (cr);
-
- gradient = cairo_pattern_create_linear (width / 2 - 1, vmargin,
- width / 2 + 1, height);
- cairo_pattern_add_color_stop_rgba (gradient, 0, 0.8, 0.8, 0.8, 0.9);
- cairo_pattern_add_color_stop_rgba (gradient, 0.8, 0.8, 0.8, 0.8, 1.0);
- cairo_set_source (cr, gradient);
- cairo_fill_preserve (cr);
-
- cairo_set_source_rgba (cr, 0, 0, 0, 2);
- cairo_set_line_width (cr, 1);
- cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
- cairo_stroke (cr);
-
- cairo_destroy (cr);
-}
-
-static void
gtk_window_paint (GtkWidget *widget,
GdkRectangle *area)
{
@@ -6892,8 +6837,8 @@ gtk_window_paint (GtkWidget *widget,
if (priv->client_side_decorated)
{
- paint_decorated_window (widget->style, widget->window, GTK_STATE_NORMAL,
- GTK_SHADOW_NONE, area, widget, "base", 0, 0, -1, -1);
+ gtk_paint_box (widget->style, widget->window, GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT, area, widget, "decoration", 0, 0, -1, -1);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]