fixed: Change coordinate apis to doubles
authorMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 21:19:35 +0000 (17:19 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 21:26:08 +0000 (17:26 -0400)
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
gtk/gtkfixed.c
gtk/gtkfixed.h

index e65d19befe808724e7e91000bbfade2701382980..e9c8cbc8294231357b5008fb6fef1d7bf1fe51e6 100644 (file)
       </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>
index ece7814a637250fc63d206bfed10380c539d1d3a..68973717e8d0a548dcf26c887fd56df81c08f9e9 100644 (file)
@@ -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;
index e16827dbb67537425465e20a7dd95ff35315ea7c..e1173fdf13c02880675cd6fb6c4fbd6281c3d141 100644 (file)
@@ -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,