[glade/glade-3-14] Render bg in GladeDesignLayout and GladeDesignView
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade/glade-3-14] Render bg in GladeDesignLayout and GladeDesignView
- Date: Sun, 14 Oct 2012 23:55:54 +0000 (UTC)
commit c8b294bbb875a4428bd63a139c5ccb8c7e351dd5
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Mon Oct 8 17:22:17 2012 -0300
Render bg in GladeDesignLayout and GladeDesignView
gladeui/glade-design-layout.c | 55 ++++++++++++++++++++++++++++++----------
gladeui/glade-design-view.c | 18 ++++++++++---
gladeui/glade-utils.c | 6 +---
3 files changed, 56 insertions(+), 23 deletions(-)
---
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 36ab923..f6f2854 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -1448,8 +1448,22 @@ glade_design_layout_draw (GtkWidget *widget, cairo_t *cr)
{
gint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gboolean selected = FALSE;
+ gint w, h;
GList *l;
+ w = gdk_window_get_width (window);
+ h = gdk_window_get_height (window);
+
+ cairo_save (cr);
+ cairo_rectangle (cr, 0, 0, priv->child_offset, h);
+ cairo_rectangle (cr, 0, 0, w, priv->child_offset);
+ cairo_rectangle (cr, 0, priv->south_east.y, w, priv->south_east.height);
+ cairo_rectangle (cr, w-priv->child_offset, 0, priv->child_offset, h);
+ cairo_clip (cr);
+ gtk_render_background (gtk_widget_get_style_context (widget),
+ cr, 0, 0, w, h);
+ cairo_restore (cr);
+
/* draw offscreen widgets */
gdk_cairo_set_source_window (cr, priv->offscreen_window,
priv->child_offset, priv->child_offset);
@@ -1707,26 +1721,39 @@ glade_design_layout_unrealize (GtkWidget * widget)
GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unrealize (widget);
}
+void
+_glade_design_layout_get_colors (GtkStyleContext *context,
+ GdkRGBA *c1, GdkRGBA *c2,
+ GdkRGBA *c3, GdkRGBA *c4)
+{
+ gfloat off;
+
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, c1);
+ gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, c2);
+
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED, c3);
+ gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED, c4);
+
+ off = ((c1->red + c1->green + c1->blue)/3 < .5) ? .16 : -.16;
+
+ c1->red += off;
+ c1->green += off;
+ c1->blue += off;
+}
+
static void
glade_design_layout_style_updated (GtkWidget *widget)
{
GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
GtkStyleContext *context = gtk_widget_get_style_context (widget);
- gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
- &priv->fg_color);
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL,
- &priv->frame_color[0]);
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED,
- &priv->frame_color_active[0]);
- gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED,
- &priv->frame_color_active[1]);
-
- priv->frame_color[1] = priv->fg_color;
- /* Make border darker */
- priv->frame_color[0].red -= .1;
- priv->frame_color[0].green -= .1;
- priv->frame_color[0].blue -= .1;
+ _glade_design_layout_get_colors (context,
+ &priv->frame_color[0],
+ &priv->frame_color[1],
+ &priv->frame_color_active[0],
+ &priv->frame_color_active[1]);
+
+ priv->fg_color = priv->frame_color[1];
}
static void
diff --git a/gladeui/glade-design-view.c b/gladeui/glade-design-view.c
index ef68f58..eef800d 100644
--- a/gladeui/glade-design-view.c
+++ b/gladeui/glade-design-view.c
@@ -283,11 +283,21 @@ static gboolean
glade_design_view_draw (GtkWidget *widget, cairo_t *cr)
{
GladeDesignViewPrivate *priv = GLADE_DESIGN_VIEW_GET_PRIVATE (widget);
-
- GTK_WIDGET_CLASS (glade_design_view_parent_class)->draw (widget, cr);
+ GdkWindow *window = gtk_widget_get_window (widget);
- if (gtk_widget_get_visible (priv->scrolled_window) == FALSE)
- logo_draw (widget, cr);
+ if (gtk_cairo_should_draw_window (cr, window))
+ {
+ if (gtk_widget_get_visible (priv->scrolled_window) == FALSE)
+ logo_draw (widget, cr);
+ else
+ gtk_render_background (gtk_widget_get_style_context (widget),
+ cr,
+ 0, 0,
+ gdk_window_get_width (window),
+ gdk_window_get_height (window));
+ }
+
+ GTK_WIDGET_CLASS (glade_design_view_parent_class)->draw (widget, cr);
return FALSE;
}
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index aba454a..f98189a 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -1808,11 +1808,7 @@ glade_utils_pointer_mode_render_icon (GladePointerMode mode, GtkIconSize size)
gtk_widget_path_free (path);
/* Now get colors */
- gtk_style_context_get_color (ctx, GTK_STATE_FLAG_NORMAL,&fg);
- gtk_style_context_get_background_color (ctx, GTK_STATE_FLAG_NORMAL,&bg);
- gtk_style_context_get_background_color (ctx, GTK_STATE_FLAG_SELECTED,&c1);
- gtk_style_context_get_color (ctx, GTK_STATE_FLAG_SELECTED,&c2);
-
+ _glade_design_layout_get_colors (ctx, &bg, &fg, &c1, &c2);
g_object_unref (ctx);
/* Clear surface */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]