label: Add ink rect support to GtkLabel

This commit is contained in:
Benjamin Otte
2014-07-10 18:31:15 +02:00
parent a97901b1f7
commit 37030a7710

View File

@ -3955,12 +3955,31 @@ G_GNUC_END_IGNORE_DEPRECATIONS
*yp = y;
}
static void
gtk_label_get_ink_rect (GtkLabel *label,
GdkRectangle *rect)
{
GtkLabelPrivate *priv = label->priv;
PangoRectangle ink_rect;
int x, y;
gtk_label_ensure_layout (label);
get_layout_location (label, &x, &y);
pango_layout_get_pixel_extents (priv->layout, &ink_rect, NULL);
rect->x = x + ink_rect.x;
rect->width = ink_rect.width;
rect->y = y + ink_rect.y;
rect->height = ink_rect.height;
}
static void
gtk_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
GdkRectangle clip_rect;
GTK_WIDGET_CLASS (gtk_label_parent_class)->size_allocate (widget, allocation);
@ -3975,6 +3994,9 @@ gtk_label_size_allocate (GtkWidget *widget,
allocation->width,
allocation->height);
}
gtk_label_get_ink_rect (label, &clip_rect);
gtk_widget_set_clip (widget, &clip_rect);
}
static void