forked from AuroraMiddleware/gtk
Fix up GtkLabel and GtkImage sizing
When GtkMisc was removed, I forgot to apply the style context padding. This caused the info-bar-message-types reftest to fail.
This commit is contained in:
parent
2488b954f2
commit
3b30cfa344
@ -1513,6 +1513,25 @@ get_animation_frame (GtkImage *image)
|
|||||||
return g_object_ref (gdk_pixbuf_animation_iter_get_pixbuf (priv->animation_iter));
|
return g_object_ref (gdk_pixbuf_animation_iter_get_pixbuf (priv->animation_iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_image_get_padding_and_border (GtkImage *image,
|
||||||
|
GtkBorder *border)
|
||||||
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkStateFlags state;
|
||||||
|
GtkBorder tmp;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (image));
|
||||||
|
state = gtk_widget_get_state_flags (GTK_WIDGET (image));
|
||||||
|
|
||||||
|
gtk_style_context_get_padding (context, state, border);
|
||||||
|
gtk_style_context_get_border (context, state, &tmp);
|
||||||
|
border->top += tmp.top;
|
||||||
|
border->right += tmp.right;
|
||||||
|
border->bottom += tmp.bottom;
|
||||||
|
border->left += tmp.left;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_get_preferred_size (GtkImage *image,
|
gtk_image_get_preferred_size (GtkImage *image,
|
||||||
gint *width_out,
|
gint *width_out,
|
||||||
@ -1522,11 +1541,9 @@ gtk_image_get_preferred_size (GtkImage *image,
|
|||||||
gint width, height;
|
gint width, height;
|
||||||
GtkBorder border;
|
GtkBorder border;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (image));
|
context = gtk_widget_get_style_context (GTK_WIDGET (image));
|
||||||
state = gtk_widget_get_state_flags (GTK_WIDGET (image));
|
gtk_image_get_padding_and_border (image, &border);
|
||||||
gtk_style_context_get_border (context, state, &border);
|
|
||||||
_gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
|
_gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
|
||||||
|
|
||||||
width += border.left + border.right;
|
width += border.left + border.right;
|
||||||
|
@ -3220,14 +3220,22 @@ gtk_label_get_measuring_layout (GtkLabel * label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_label_get_border (GtkLabel *label, GtkBorder *border)
|
gtk_label_get_padding_and_border (GtkLabel *label,
|
||||||
|
GtkBorder *border)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state;
|
GtkStateFlags state;
|
||||||
|
GtkBorder tmp;
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (label));
|
context = gtk_widget_get_style_context (GTK_WIDGET (label));
|
||||||
state = gtk_widget_get_state_flags (GTK_WIDGET (label));
|
state = gtk_widget_get_state_flags (GTK_WIDGET (label));
|
||||||
gtk_style_context_get_border (context, state, border);
|
|
||||||
|
gtk_style_context_get_padding (context, state, border);
|
||||||
|
gtk_style_context_get_border (context, state, &tmp);
|
||||||
|
border->top += tmp.top;
|
||||||
|
border->right += tmp.right;
|
||||||
|
border->bottom += tmp.bottom;
|
||||||
|
border->left += tmp.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3244,7 +3252,7 @@ gtk_label_update_layout_width (GtkLabel *label)
|
|||||||
PangoRectangle logical;
|
PangoRectangle logical;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
gtk_label_get_border (label, &border);
|
gtk_label_get_padding_and_border (label, &border);
|
||||||
|
|
||||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (label)) - border.left - border.right;
|
width = gtk_widget_get_allocated_width (GTK_WIDGET (label)) - border.left - border.right;
|
||||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (label)) - border.top - border.bottom;
|
height = gtk_widget_get_allocated_height (GTK_WIDGET (label)) - border.top - border.bottom;
|
||||||
@ -3661,7 +3669,7 @@ gtk_label_get_preferred_size (GtkWidget *widget,
|
|||||||
smallest_rect.width = PANGO_PIXELS_CEIL (smallest_rect.width);
|
smallest_rect.width = PANGO_PIXELS_CEIL (smallest_rect.width);
|
||||||
smallest_rect.height = PANGO_PIXELS_CEIL (smallest_rect.height);
|
smallest_rect.height = PANGO_PIXELS_CEIL (smallest_rect.height);
|
||||||
|
|
||||||
gtk_label_get_border (label, &border);
|
gtk_label_get_padding_and_border (label, &border);
|
||||||
|
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
@ -3765,7 +3773,7 @@ gtk_label_get_preferred_width_for_height (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkBorder border;
|
GtkBorder border;
|
||||||
|
|
||||||
gtk_label_get_border (label, &border);
|
gtk_label_get_padding_and_border (label, &border);
|
||||||
|
|
||||||
if (priv->wrap)
|
if (priv->wrap)
|
||||||
gtk_label_clear_layout (label);
|
gtk_label_clear_layout (label);
|
||||||
@ -3800,7 +3808,7 @@ gtk_label_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkBorder border;
|
GtkBorder border;
|
||||||
|
|
||||||
gtk_label_get_border (label, &border);
|
gtk_label_get_padding_and_border (label, &border);
|
||||||
|
|
||||||
if (priv->wrap)
|
if (priv->wrap)
|
||||||
gtk_label_clear_layout (label);
|
gtk_label_clear_layout (label);
|
||||||
@ -3998,7 +4006,7 @@ get_layout_location (GtkLabel *label,
|
|||||||
widget = GTK_WIDGET (label);
|
widget = GTK_WIDGET (label);
|
||||||
priv = label->priv;
|
priv = label->priv;
|
||||||
|
|
||||||
gtk_label_get_border (label, &border);
|
gtk_label_get_padding_and_border (label, &border);
|
||||||
|
|
||||||
xalign = halign_to_float (widget);
|
xalign = halign_to_float (widget);
|
||||||
yalign = valign_to_float (widget);
|
yalign = valign_to_float (widget);
|
||||||
|
Loading…
Reference in New Issue
Block a user