diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-10-03 16:20:50 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-10-03 16:20:50 -0400 |
commit | 83b8bcb63a1fcdafae1d6cd024a7f491e5654d6d (patch) | |
tree | 537c06eedc7b8a0ce9e9688f932c72c15865e13f /gtk/gtkswitch.c | |
parent | c0e3b6ce71015741b154b44db08d0c473aa4f163 (diff) | |
download | gtk+-83b8bcb63a1fcdafae1d6cd024a7f491e5654d6d.tar.gz |
switch: Unclip the slider shadow
This commit arranges things so the shadow of the slider can
extend outside the widget, even if the switch itself has no
shadow.
https://bugzilla.gnome.org/show_bug.cgi?id=755791
Diffstat (limited to 'gtk/gtkswitch.c')
-rw-r--r-- | gtk/gtkswitch.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index 3a2f8e9b9b..103382db56 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -52,6 +52,8 @@ #include "a11y/gtkswitchaccessible.h" #include "gtkactionhelper.h" #include "gtkwidgetprivate.h" +#include "gtkcssshadowsvalueprivate.h" +#include "gtkstylecontextprivate.h" #include "fallback-c89.c" @@ -447,6 +449,9 @@ gtk_switch_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; + GtkStyleContext *context; + GtkBorder extents; + GtkAllocation clip; gtk_widget_set_allocation (widget, allocation); @@ -457,7 +462,26 @@ gtk_switch_size_allocate (GtkWidget *widget, allocation->width, allocation->height); - _gtk_widget_set_simple_clip (widget, NULL); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + + gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); + + _gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (context, + GTK_CSS_PROPERTY_BOX_SHADOW), + &extents); + + gtk_style_context_restore (context); + + clip = *allocation; + clip.x -= extents.left; + clip.y -= extents.top; + clip.width += extents.left + extents.right; + clip.height += extents.top + extents.bottom; + + _gtk_widget_set_simple_clip (widget, &clip); } static void |