[gtk+] label: Add ink rect support to GtkLabel



commit 37030a771059f43ad701700380719d19cbc7c966
Author: Benjamin Otte <otte redhat com>
Date:   Thu Jul 10 18:31:15 2014 +0200

    label: Add ink rect support to GtkLabel

 gtk/gtklabel.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 9cc6ff9..b3fd153 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3956,11 +3956,30 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]