[gtk+/wip/baedert/drawing: 238/348] label: Fix layout snapshot coordinates
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 238/348] label: Fix layout snapshot coordinates
- Date: Sat, 8 Jul 2017 10:50:49 +0000 (UTC)
commit e1758a9bc850049826d00c647775001a09dee85e
Author: Timm Bäder <mail baedert org>
Date: Thu Jun 15 17:04:42 2017 +0200
label: Fix layout snapshot coordinates
No need to convert anything to "window coordinates" anymore.
gtk/gtklabel.c | 32 ++++----------------------------
1 files changed, 4 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index bda0db7..95c82a7 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3664,7 +3664,7 @@ get_layout_location (GtkLabel *label,
baseline = gtk_widget_get_allocated_baseline (widget);
- x = floor (allocation.x + xalign * (allocation.width - req_width) - logical.x);
+ x = floor ((xalign * (allocation.width - req_width)) - logical.x);
baseline_offset = 0;
if (baseline != -1)
@@ -3688,9 +3688,9 @@ get_layout_location (GtkLabel *label,
* middle". You want to read the first line, at least, to get some context.
*/
if (pango_layout_get_line_count (priv->layout) == 1)
- y = floor (allocation.y + (allocation.height - req_height) * yalign) - logical.y + baseline_offset;
+ y = floor ((allocation.height - req_height) * yalign) + baseline_offset;
else
- y = floor (allocation.y + MAX ((allocation.height - req_height) * yalign, 0)) - logical.y +
baseline_offset;
+ y = floor (MAX ((allocation.height - req_height) * yalign, 0)) + baseline_offset;
if (xp)
*xp = x;
@@ -3894,12 +3894,8 @@ gtk_label_get_focus_link (GtkLabel *label)
return NULL;
}
-static void layout_to_window_coords (GtkLabel *label,
- gint *x,
- gint *y);
#define GRAPHENE_RECT_FROM_RECT(_r) (GRAPHENE_RECT_INIT ((_r)->x, (_r)->y, (_r)->width, (_r)->height))
-
static void
gtk_label_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
@@ -3927,8 +3923,7 @@ gtk_label_snapshot (GtkWidget *widget,
if (priv->text && (*priv->text != '\0'))
{
- lx = ly = 0;
- layout_to_window_coords (label, &lx, &ly);
+ get_layout_location (label, &lx, &ly);
gtk_snapshot_render_layout (snapshot, context, lx, ly, priv->layout);
@@ -4210,25 +4205,6 @@ window_to_layout_coords (GtkLabel *label,
*y -= ly; /* go to layout */
}
-static void
-layout_to_window_coords (GtkLabel *label,
- gint *x,
- gint *y)
-{
- gint lx, ly;
- GtkAllocation allocation;
-
- /* get layout location in widget->window coords */
- get_layout_location (label, &lx, &ly);
- _gtk_widget_get_allocation (GTK_WIDGET (label), &allocation);
-
- *x += lx; /* go to widget->window */
- *x -= allocation.x; /* go to selection window */
-
- *y += ly; /* go to widget->window */
- *y -= allocation.y; /* go to selection window */
-}
-
static gboolean
get_layout_index (GtkLabel *label,
gint x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]