Commit 55642822 authored by Cosimo Cecchi's avatar Cosimo Cecchi

spinbutton: paint an additional slice of background

Normally, the xthickness in the style maps to the space on the sides of
the widget, to accommodate for its border - GtkEntry's text area
background width is calculated as (allocation->width - 2 * xthickness),
and the border is rendered in that area.
GtkSpinButton has an additional panel for the buttons though, which will
render the right-side (left-side for RTL) border itself, taking
xthickness into account. This results in the xthickness for that side
being applied twice, both to the spinbutton panel and to the entry's
text area.
Visually, a slice with no painted background can be seen in spinbuttons
on the right side (left side when RTL) of the text area, where the
border would be rendered by the entry, which looks bad.

This patch makes GtkSpinButton render the same background of the entry
in that slice, to compensate for the xthickness being allocated to the
button panel instead.

https://bugzilla.gnome.org/show_bug.cgi?id=683511
parent 87115e00
......@@ -766,7 +766,34 @@ gtk_spin_button_expose (GtkWidget *widget,
gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_DOWN);
}
else
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event);
{
if (event->window == widget->window)
{
gint text_x, text_y, text_width, text_height, slice_x;
/* Since we reuse xthickness for the buttons panel on one side, and GtkEntry
* always sizes its background to (allocation->width - 2 * xthickness), we
* have to manually render the missing slice of the background on the panel
* side.
*/
GTK_ENTRY_GET_CLASS (spin)->get_text_area_size (GTK_ENTRY (spin),
&text_x, &text_y,
&text_width, &text_height);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
slice_x = text_x - widget->style->xthickness;
else
slice_x = text_x + text_width;
gtk_paint_flat_box (widget->style, widget->window,
gtk_widget_get_state (widget), GTK_SHADOW_NONE,
&event->area, widget, "entry_bg",
slice_x, text_y,
widget->style->xthickness, text_height);
}
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event);
}
}
return FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment