[gnome-photos/wip/rishi/zoom: 6/7] image-view, tool-crop: Use double instead of float in the public API



commit 238b440be1119ceb80ed7dc27db6625fa7ecaba1
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Mar 30 10:18:01 2017 +0200

    image-view, tool-crop: Use double instead of float in the public API
    
    Even though we don't need the extra accuracy of double-precision
    floating-point numbers, it doesn't cost us that much either because we
    are not going to have hundreds of PhotosImageView instances. On the
    other hand it does give us consistency with the Cairo and GVariant
    APIs, and the future GtkImageView API that's in the works.

 src/photos-image-view.c |   60 +++++++++++++++++++++++-----------------------
 src/photos-image-view.h |    6 ++--
 src/photos-tool-crop.c  |   22 ++++++++--------
 3 files changed, 44 insertions(+), 44 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index 2e26d09..2e12039 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -335,15 +335,15 @@ photos_image_view_get_property (GObject *object, guint prop_id, GValue *value, G
       break;
 
     case PROP_X:
-      g_value_set_float (value, (gfloat) self->x);
+      g_value_set_double (value, self->x);
       break;
 
     case PROP_Y:
-      g_value_set_float (value, (gfloat) self->y);
+      g_value_set_double (value, self->y);
       break;
 
     case PROP_ZOOM:
-      g_value_set_float (value, (gfloat) self->zoom);
+      g_value_set_double (value, self->zoom);
       break;
 
     default:
@@ -415,33 +415,33 @@ photos_image_view_class_init (PhotosImageViewClass *class)
 
   g_object_class_install_property (object_class,
                                    PROP_X,
-                                   g_param_spec_float ("x",
-                                                       "X",
-                                                       "X origin",
-                                                       -G_MAXFLOAT,
-                                                       G_MAXFLOAT,
-                                                       0.0,
-                                                       G_PARAM_READABLE));
+                                   g_param_spec_double ("x",
+                                                        "X",
+                                                        "X origin",
+                                                        -G_MAXDOUBLE,
+                                                        G_MAXDOUBLE,
+                                                        0.0,
+                                                        G_PARAM_READABLE));
 
   g_object_class_install_property (object_class,
                                    PROP_Y,
-                                   g_param_spec_float ("y",
-                                                       "Y",
-                                                       "Y origin",
-                                                       -G_MAXFLOAT,
-                                                       G_MAXFLOAT,
-                                                       0.0,
-                                                       G_PARAM_READABLE));
+                                   g_param_spec_double ("y",
+                                                        "Y",
+                                                        "Y origin",
+                                                        -G_MAXDOUBLE,
+                                                        G_MAXDOUBLE,
+                                                        0.0,
+                                                        G_PARAM_READABLE));
 
   g_object_class_install_property (object_class,
                                    PROP_ZOOM,
-                                   g_param_spec_float ("zoom",
-                                                       "Zoom",
-                                                       "Zoom factor",
-                                                       0.0f,
-                                                       100.0f,
-                                                       1.0f,
-                                                       G_PARAM_READABLE));
+                                   g_param_spec_double ("zoom",
+                                                        "Zoom",
+                                                        "Zoom factor",
+                                                        0.0,
+                                                        100.0,
+                                                        1.0,
+                                                        G_PARAM_READABLE));
 
   signals[DRAW_BACKGROUND] = g_signal_new ("draw-background",
                                            G_TYPE_FROM_CLASS (class),
@@ -492,27 +492,27 @@ photos_image_view_get_node (PhotosImageView *self)
 }
 
 
-gfloat
+gdouble
 photos_image_view_get_x (PhotosImageView *self)
 {
   g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
-  return (gfloat) self->x;
+  return self->x;
 }
 
 
-gfloat
+gdouble
 photos_image_view_get_y (PhotosImageView *self)
 {
   g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
-  return (gfloat) self->y;
+  return self->y;
 }
 
 
-gfloat
+gdouble
 photos_image_view_get_zoom (PhotosImageView *self)
 {
   g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
-  return (gfloat) self->zoom;
+  return self->zoom;
 }
 
 
diff --git a/src/photos-image-view.h b/src/photos-image-view.h
index 9cd91f5..0ba8708 100644
--- a/src/photos-image-view.h
+++ b/src/photos-image-view.h
@@ -35,11 +35,11 @@ GtkWidget          *photos_image_view_new_from_node      (GeglNode *node);
 
 GeglNode           *photos_image_view_get_node           (PhotosImageView *self);
 
-gfloat              photos_image_view_get_x              (PhotosImageView *self);
+gdouble             photos_image_view_get_x              (PhotosImageView *self);
 
-gfloat              photos_image_view_get_y              (PhotosImageView *self);
+gdouble             photos_image_view_get_y              (PhotosImageView *self);
 
-gfloat              photos_image_view_get_zoom           (PhotosImageView *self);
+gdouble             photos_image_view_get_zoom           (PhotosImageView *self);
 
 void                photos_image_view_set_node           (PhotosImageView *self, GeglNode *node);
 
diff --git a/src/photos-tool-crop.c b/src/photos-tool-crop.c
index 46d7a27..a693e20 100644
--- a/src/photos-tool-crop.c
+++ b/src/photos-tool-crop.c
@@ -190,10 +190,10 @@ photos_tool_crop_redraw_damaged_area (PhotosToolCrop *self)
   gdouble x;
   gdouble y;
 
-  x = (gdouble) photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
+  x = photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
   x = -x + self->crop_x - damage_offset;
 
-  y = (gdouble) photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
+  y = photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
   y = -y + self->crop_y - damage_offset;
 
   area.height = (gint) (self->crop_height + 2 * damage_offset + 0.5) + 2;
@@ -211,7 +211,7 @@ static void
 photos_tool_crop_surface_create (PhotosToolCrop *self)
 {
   GdkWindow *window;
-  gfloat zoom;
+  gdouble zoom;
 
   g_clear_pointer (&self->surface, (GDestroyNotify) cairo_surface_destroy);
 
@@ -877,7 +877,7 @@ photos_tool_crop_process (GObject *source_object, GAsyncResult *res, gpointer us
   PhotosToolCrop *self;
   GError *error = NULL;
   PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
-  gfloat zoom;
+  gdouble zoom;
   guint active;
 
   photos_base_item_operation_remove_finish (item, res, &error);
@@ -1001,7 +1001,7 @@ photos_tool_crop_deactivate (PhotosTool *tool)
     {
       GVariantBuilder parameter;
       GVariantType *parameter_type;
-      gfloat zoom;
+      gdouble zoom;
 
       zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (self->view));
 
@@ -1043,10 +1043,10 @@ photos_tool_crop_draw (PhotosTool *tool, cairo_t *cr, GdkRectangle *rect)
   g_return_if_fail (self->activated);
   g_return_if_fail (self->view != NULL);
 
-  x = (gdouble) photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
+  x = photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
   x = -x;
 
-  y = (gdouble) photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
+  y = photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
   y = -y;
 
   cairo_save (cr);
@@ -1076,8 +1076,8 @@ photos_tool_crop_left_click_event (PhotosTool *tool, GdkEventButton *event)
 
   self->grabbed = TRUE;
 
-  x = (gdouble) photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
-  y = (gdouble) photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
+  x = photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
+  y = photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
   self->event_x_last = event->x + x;
   self->event_y_last = event->y + y;
 
@@ -1113,8 +1113,8 @@ photos_tool_crop_motion_event (PhotosTool *tool, GdkEventMotion *event)
   g_return_val_if_fail (self->activated, GDK_EVENT_PROPAGATE);
   g_return_val_if_fail (self->view != NULL, GDK_EVENT_PROPAGATE);
 
-  x = (gdouble) photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
-  y = (gdouble) photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
+  x = photos_image_view_get_x (PHOTOS_IMAGE_VIEW (self->view));
+  y = photos_image_view_get_y (PHOTOS_IMAGE_VIEW (self->view));
   event_x = event->x + x;
   event_y = event->y + y;
 


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