[gtk+/wip/matthiasc/gadget] Fix label rendering
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/gadget] Fix label rendering
- Date: Thu, 3 Dec 2015 23:35:26 +0000 (UTC)
commit 96bff225dd61942488e6296f1daafc40a10322dd
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 3 18:34:06 2015 -0500
Fix label rendering
With this commit, labels are mostly back to normal. There is still
some confusion about borders and padding in various places in the
code.
gtk/gtklabel.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 52f013a..45b82e2 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4271,6 +4271,10 @@ gtk_label_draw (GtkWidget *widget,
return FALSE;
}
+static void layout_to_window_coords (GtkLabel *label,
+ gint *x,
+ gint *y);
+
static gboolean
gtk_label_render (GtkCssGadget *gadget,
cairo_t *cr,
@@ -4298,9 +4302,8 @@ gtk_label_render (GtkCssGadget *gadget,
if (priv->text && (*priv->text != '\0'))
{
- get_layout_location (label, &lx, &ly);
-
- cairo_translate (cr, -x, -y);
+ lx = ly = 0;
+ layout_to_window_coords (label, &lx, &ly);
gtk_render_layout (context, cr, lx, ly, priv->layout);
@@ -4604,7 +4607,6 @@ window_to_layout_coords (GtkLabel *label,
}
}
-#if 0
static void
layout_to_window_coords (GtkLabel *label,
gint *x,
@@ -4612,25 +4614,26 @@ layout_to_window_coords (GtkLabel *label,
{
gint lx, ly;
GtkWidget *widget;
+ GtkAllocation allocation;
widget = GTK_WIDGET (label);
/* get layout location in widget->window coords */
get_layout_location (label, &lx, &ly);
-
+ gtk_widget_get_allocation (widget, &allocation);
+
if (x)
{
- *x += lx; /* go to widget->window */
- *x -= widget->allocation.x; /* go to selection window */
+ *x += lx; /* go to widget->window */
+ *x -= allocation.x; /* go to selection window */
}
if (y)
{
- *y += ly; /* go to widget->window */
- *y -= widget->allocation.y; /* go to selection window */
+ *y += ly; /* go to widget->window */
+ *y -= allocation.y; /* go to selection window */
}
}
-#endif
static gboolean
get_layout_index (GtkLabel *label,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]