From ef7455d9814b76b1f0f23a714e02e65c97bba49e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 20 Sep 2004 14:43:18 +0000 Subject: [PATCH] Add a boolean ::displace-focus style property and apply child displacement 2004-09-20 Matthias Clasen * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus style property and apply child displacement to the focus rectangle if it is TRUE. (#141170, Soeren Sandmann) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gtk/gtkbutton.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+) diff --git a/ChangeLog b/ChangeLog index d23d7ae0c9..8f40d4897e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-09-20 Matthias Clasen + + * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus + style property and apply child displacement to the focus rectangle + if it is TRUE. (#141170, Soeren Sandmann) + Sun Sep 19 23:56:18 2004 Søren Sandmann * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d23d7ae0c9..8f40d4897e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2004-09-20 Matthias Clasen + + * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus + style property and apply child displacement to the focus rectangle + if it is TRUE. (#141170, Soeren Sandmann) + Sun Sep 19 23:56:18 2004 Søren Sandmann * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d23d7ae0c9..8f40d4897e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2004-09-20 Matthias Clasen + + * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus + style property and apply child displacement to the focus rectangle + if it is TRUE. (#141170, Soeren Sandmann) + Sun Sep 19 23:56:18 2004 Søren Sandmann * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d23d7ae0c9..8f40d4897e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2004-09-20 Matthias Clasen + + * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus + style property and apply child displacement to the focus rectangle + if it is TRUE. (#141170, Soeren Sandmann) + Sun Sep 19 23:56:18 2004 Søren Sandmann * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index d2ed601250..bcce751349 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -376,6 +376,21 @@ gtk_button_class_init (GtkButtonClass *klass) 0, G_PARAM_READABLE)); + /** + * GtkButton:displace-focus: + * + * Whether the child_displacement_x/child_displacement_y properties should also + * affect the focus rectangle. + * + * Since: 2.6 + */ + gtk_widget_class_install_style_property (widget_class, + g_param_spec_boolean ("displace-focus", + P_("Displace focus"), + P_("Whether the child_displacement_x/_y properties should also affect the focus rectangle"), + FALSE, + G_PARAM_READABLE)); + gtk_settings_install_property (g_param_spec_boolean ("gtk-button-images", P_("Show button images"), P_("Whether stock icons should be shown in buttons"), @@ -1064,6 +1079,16 @@ _gtk_button_paint (GtkButton *button, if (GTK_WIDGET_HAS_FOCUS (widget)) { + gint child_displacement_x; + gint child_displacement_y; + gboolean displace_focus; + + gtk_widget_style_get (GTK_WIDGET (widget), + "child_displacement_y", &child_displacement_y, + "child_displacement_x", &child_displacement_x, + "displace_focus", &displace_focus, + NULL); + if (interior_focus) { x += widget->style->xthickness + focus_pad; @@ -1079,6 +1104,12 @@ _gtk_button_paint (GtkButton *button, height += 2 * (focus_width + focus_pad); } + if (button->depressed && displace_focus) + { + x += child_displacement_x; + y += child_displacement_y; + } + gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), area, widget, "button", x, y, width, height);