mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
scrolledwindow: fix wrong allocation of padding and borders
When positioning the scrollbar we were doing several miscalculations when accounting for CSS paddings and borders. This also fixes a number of problems with RTL and when scrollbars-within-bevel is FALSE. https://bugzilla.gnome.org/show_bug.cgi?id=685449
This commit is contained in:
parent
dd9392a58c
commit
1a1361c4b3
@ -1750,10 +1750,14 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
|
|||||||
gtk_widget_get_preferred_height (priv->hscrollbar, &sb_height, NULL);
|
gtk_widget_get_preferred_height (priv->hscrollbar, &sb_height, NULL);
|
||||||
gtk_widget_get_preferred_width (priv->vscrollbar, &sb_width, NULL);
|
gtk_widget_get_preferred_width (priv->vscrollbar, &sb_width, NULL);
|
||||||
|
|
||||||
/* Subtract some things from our available allocation size */
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||||
|
|
||||||
allocation->x = 0;
|
allocation->x = 0;
|
||||||
allocation->y = 0;
|
allocation->y = 0;
|
||||||
|
allocation->width = widget_allocation.width;
|
||||||
|
allocation->height = widget_allocation.height;
|
||||||
|
|
||||||
|
/* Subtract some things from our available allocation size */
|
||||||
if (priv->shadow_type != GTK_SHADOW_NONE)
|
if (priv->shadow_type != GTK_SHADOW_NONE)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
@ -1771,14 +1775,12 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
|
|||||||
|
|
||||||
allocation->x += padding.left + border.left;
|
allocation->x += padding.left + border.left;
|
||||||
allocation->y += padding.top + border.top;
|
allocation->y += padding.top + border.top;
|
||||||
|
allocation->width = MAX (1, allocation->width - (padding.left + border.left + padding.right + border.right));
|
||||||
|
allocation->height = MAX (1, allocation->height - (padding.top + border.top + padding.bottom + border.bottom));
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
|
||||||
allocation->width = MAX (1, (gint) widget_allocation.width - allocation->x * 2);
|
|
||||||
allocation->height = MAX (1, (gint) widget_allocation.height - allocation->y * 2);
|
|
||||||
|
|
||||||
if (priv->vscrollbar_visible)
|
if (priv->vscrollbar_visible)
|
||||||
{
|
{
|
||||||
gboolean is_rtl;
|
gboolean is_rtl;
|
||||||
@ -2172,11 +2174,9 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
|
|||||||
priv->real_window_placement == GTK_CORNER_TOP_RIGHT)
|
priv->real_window_placement == GTK_CORNER_TOP_RIGHT)
|
||||||
child_allocation.y = (relative_allocation.y +
|
child_allocation.y = (relative_allocation.y +
|
||||||
relative_allocation.height +
|
relative_allocation.height +
|
||||||
sb_spacing +
|
sb_spacing);
|
||||||
(priv->shadow_type == GTK_SHADOW_NONE ?
|
|
||||||
0 : padding.top + border.top));
|
|
||||||
else
|
else
|
||||||
child_allocation.y = 0;
|
child_allocation.y = relative_allocation.y - sb_spacing - sb_height;
|
||||||
|
|
||||||
child_allocation.width = relative_allocation.width;
|
child_allocation.width = relative_allocation.width;
|
||||||
child_allocation.height = sb_height;
|
child_allocation.height = sb_height;
|
||||||
@ -2189,15 +2189,12 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
child_allocation.x -= padding.left + border.left;
|
child_allocation.x -= padding.left + border.left;
|
||||||
child_allocation.width += padding.left + padding.right + border.left + border.right;
|
child_allocation.width += padding.left + padding.right + border.left + border.right;
|
||||||
}
|
|
||||||
else if (GTK_CORNER_TOP_RIGHT == priv->real_window_placement ||
|
if (priv->real_window_placement == GTK_CORNER_TOP_LEFT ||
|
||||||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
|
priv->real_window_placement == GTK_CORNER_TOP_RIGHT)
|
||||||
{
|
child_allocation.y += padding.bottom + border.bottom;
|
||||||
child_allocation.y -= padding.top + border.top;
|
else
|
||||||
}
|
child_allocation.y -= padding.top + border.top;
|
||||||
else
|
|
||||||
{
|
|
||||||
child_allocation.y += padding.top + border.top;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2219,11 +2216,9 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
|
|||||||
priv->real_window_placement == GTK_CORNER_BOTTOM_LEFT)))
|
priv->real_window_placement == GTK_CORNER_BOTTOM_LEFT)))
|
||||||
child_allocation.x = (relative_allocation.x +
|
child_allocation.x = (relative_allocation.x +
|
||||||
relative_allocation.width +
|
relative_allocation.width +
|
||||||
sb_spacing +
|
sb_spacing);
|
||||||
(priv->shadow_type == GTK_SHADOW_NONE ?
|
|
||||||
0 : padding.left + border.left));
|
|
||||||
else
|
else
|
||||||
child_allocation.x = 0;
|
child_allocation.x = relative_allocation.x - sb_spacing - sb_width;
|
||||||
|
|
||||||
child_allocation.y = relative_allocation.y;
|
child_allocation.y = relative_allocation.y;
|
||||||
child_allocation.width = sb_width;
|
child_allocation.width = sb_width;
|
||||||
@ -2237,17 +2232,18 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
child_allocation.y -= padding.top + border.top;
|
child_allocation.y -= padding.top + border.top;
|
||||||
child_allocation.height += padding.top + padding.bottom + border.top + border.bottom;
|
child_allocation.height += padding.top + padding.bottom + border.top + border.bottom;
|
||||||
|
|
||||||
|
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL &&
|
||||||
|
(priv->real_window_placement == GTK_CORNER_TOP_RIGHT ||
|
||||||
|
priv->real_window_placement == GTK_CORNER_BOTTOM_RIGHT)) ||
|
||||||
|
(gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR &&
|
||||||
|
(priv->real_window_placement == GTK_CORNER_TOP_LEFT ||
|
||||||
|
priv->real_window_placement == GTK_CORNER_BOTTOM_LEFT)))
|
||||||
|
child_allocation.x += padding.right + border.right;
|
||||||
|
else
|
||||||
|
child_allocation.x -= padding.left + border.left;
|
||||||
}
|
}
|
||||||
else if (GTK_CORNER_BOTTOM_LEFT == priv->real_window_placement ||
|
}
|
||||||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
|
|
||||||
{
|
|
||||||
child_allocation.x -= padding.left + border.left;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
child_allocation.x += padding.left + border.left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_size_allocate (priv->vscrollbar, &child_allocation);
|
gtk_widget_size_allocate (priv->vscrollbar, &child_allocation);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user