[gtk/matthiasc/for-master: 7/7] fixed: Change coordinate apis to doubles
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 7/7] fixed: Change coordinate apis to doubles
- Date: Fri, 22 May 2020 21:27:20 +0000 (UTC)
commit 33b836af7fc153fe1162b9a2ed5af4d132899ccf
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 22 17:19:35 2020 -0400
fixed: Change coordinate apis to doubles
We are using floating point for coordinates
everywhere now, so be consistent here.
This commit also changes the implementation of
gtk_fixed_get_child_position to work with
non-translation child transforms.
docs/reference/gtk/migrating-3to4.xml | 11 +++++++++++
gtk/gtkfixed.c | 24 +++++++-----------------
gtk/gtkfixed.h | 12 ++++++------
3 files changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/docs/reference/gtk/migrating-3to4.xml b/docs/reference/gtk/migrating-3to4.xml
index e65d19befe..e9c8cbc829 100644
--- a/docs/reference/gtk/migrating-3to4.xml
+++ b/docs/reference/gtk/migrating-3to4.xml
@@ -695,6 +695,17 @@
</para>
</section>
+ <section>
+ <title>Adapt to coordinate API changes</title>
+ <para>
+ A number of APIs that are accepting or returning coordinates have
+ been changed from ints to doubles: gtk_widget_translate_coordinates(),
+ gtk_fixed_put(), gtk_fixed_move(). This change is mostly transparent,
+ except for cases where out parameters are involved: you need to
+ pass double* now, instead of int*.
+ </para>
+ </section>
+
<section>
<title>Adapt to GtkStyleContext API changes</title>
<para>
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index ece7814a63..68973717e8 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -226,8 +226,8 @@ gtk_fixed_new (void)
void
gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget,
- gint x,
- gint y)
+ double x,
+ double y)
{
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
GtkFixedLayoutChild *child_info;
@@ -261,26 +261,16 @@ gtk_fixed_put (GtkFixed *fixed,
void
gtk_fixed_get_child_position (GtkFixed *fixed,
GtkWidget *widget,
- int *x,
- int *y)
+ double *x,
+ double *y)
{
- GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
- GtkFixedLayoutChild *child_info;
- float pos_x = 0.f, pos_y = 0.f;
- GskTransform *transform;
-
g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (x != NULL);
g_return_if_fail (y != NULL);
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
- child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
- transform = gtk_fixed_layout_child_get_transform (child_info);
- gsk_transform_to_translate (transform, &pos_x, &pos_y);
-
- *x = floorf (pos_x);
- *y = floorf (pos_y);
+ gtk_widget_translate_coordinates (widget, GTK_WIDGET (fixed), 0, 0, x, y);
}
/**
@@ -350,8 +340,8 @@ gtk_fixed_get_child_transform (GtkFixed *fixed,
void
gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget,
- gint x,
- gint y)
+ double x,
+ double y)
{
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
GtkFixedLayoutChild *child_info;
diff --git a/gtk/gtkfixed.h b/gtk/gtkfixed.h
index e16827dbb6..e1173fdf13 100644
--- a/gtk/gtkfixed.h
+++ b/gtk/gtkfixed.h
@@ -67,21 +67,21 @@ GtkWidget * gtk_fixed_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget,
- gint x,
- gint y);
+ double x,
+ double y);
GDK_AVAILABLE_IN_ALL
void gtk_fixed_remove (GtkFixed *fixed,
GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget,
- gint x,
- gint y);
+ double x,
+ double y);
GDK_AVAILABLE_IN_ALL
void gtk_fixed_get_child_position (GtkFixed *fixed,
GtkWidget *widget,
- gint *x,
- gint *y);
+ double *x,
+ double *y);
GDK_AVAILABLE_IN_ALL
void gtk_fixed_set_child_transform (GtkFixed *fixed,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]