devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f4019d3303f678b9f040d50cc98c8ba36fd4d1a9

commit f4019d3303f678b9f040d50cc98c8ba36fd4d1a9
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Tue Oct 29 14:52:58 2019 -0400

    eina: add comparison macros for Eina_Size2D and Eina_Position2D
    
    Summary:
    I'm tired of typing all this out. it's exhausting.
    
    also add a couple usages internally to verify that this works as expected
    
    @feature
    
    Reviewers: cedric, bu5hm4n, devilhorns
    
    Reviewed By: devilhorns
    
    Subscribers: devilhorns, bu5hm4n, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D10557
---
 src/lib/eina/eina_rectangle.h          | 21 +++++++++++++++++++++
 src/lib/evas/canvas/evas_object_main.c |  8 ++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/lib/eina/eina_rectangle.h b/src/lib/eina/eina_rectangle.h
index 8045bf7a45..54cf1ccb99 100644
--- a/src/lib/eina/eina_rectangle.h
+++ b/src/lib/eina/eina_rectangle.h
@@ -62,6 +62,27 @@ typedef struct _Eina_Size2D
    int w, h;
 } Eina_Size2D;
 
+
+/**
+ * @brief convenience macro for comparing two Eina_Size2D structs
+ * @param[in] a An Eina_Size2D
+ * @param[in] b An Eina_Size2D
+ * @return 1 if the structs are equal, 0 if they are not
+ * @since 1.24
+ */
+#define EINA_SIZE2D_EQ(a, b) \
+  (((a).w == (b).w) && ((a).h == (b).h))
+
+/**
+ * @brief convenience macro for comparing two Eina_Position2D structs
+ * @param[in] a An Eina_Position2D
+ * @param[in] b An Eina_Position2D
+ * @return 1 if the structs are equal, 0 if they are not
+ * @since 1.24
+ */
+#define EINA_POSITION2D_EQ(a, b) \
+  (((a).x == (b).x) && ((a).y == (b).y))
+
 /**
  * @typedef Eina_Rectangle
  * Simple rectangle structure.
diff --git a/src/lib/evas/canvas/evas_object_main.c 
b/src/lib/evas/canvas/evas_object_main.c
index b6732eb9f8..27ec6e2bfc 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -1471,7 +1471,7 @@ 
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_max_set(Eo *eo_obj, Evas_Ob
         if (!sz.w && !sz.h) return;
         _evas_object_size_hint_alloc(eo_obj, obj);
      }
-   if ((obj->size_hints->max.w == sz.w) && (obj->size_hints->max.h == sz.h)) 
return;
+   if (EINA_SIZE2D_EQ(obj->size_hints->max, sz)) return;
    obj->size_hints->max = sz;
    if ((obj->size_hints->max.w != -1) && (obj->size_hints->max.w < 
obj->size_hints->min.w))
      ERR("restricted max width hint is now smaller than restricted min width 
hint! (%d < %d)", obj->size_hints->max.w, obj->size_hints->min.w);
@@ -1502,7 +1502,7 @@ 
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_min_set(Eo *eo_obj, Evas_Ob
         if (!sz.w && !sz.h) return;
         _evas_object_size_hint_alloc(eo_obj, obj);
      }
-   if ((obj->size_hints->min.w == sz.w) && (obj->size_hints->min.h == sz.h)) 
return;
+   if (EINA_SIZE2D_EQ(obj->size_hints->min, sz)) return;
    obj->size_hints->min = sz;
    if ((obj->size_hints->max.w != -1) && (obj->size_hints->max.w < 
obj->size_hints->min.w))
      ERR("restricted max width hint is now smaller than restricted min width 
hint! (%d < %d)", obj->size_hints->max.w, obj->size_hints->min.w);
@@ -1588,7 +1588,7 @@ _efl_canvas_object_efl_gfx_hint_hint_size_max_set(Eo 
*eo_obj, Evas_Object_Protec
         if ((sz.w == -1) && (sz.h == -1)) return;
         _evas_object_size_hint_alloc(eo_obj, obj);
      }
-   if ((obj->size_hints->user_max.w == sz.w) && (obj->size_hints->user_max.h 
== sz.h)) return;
+   if (EINA_SIZE2D_EQ(obj->size_hints->user_max, sz)) return;
    obj->size_hints->user_max.w = sz.w;
    obj->size_hints->user_max.h = sz.h;
 
@@ -1652,7 +1652,7 @@ _efl_canvas_object_efl_gfx_hint_hint_size_min_set(Eo 
*eo_obj, Evas_Object_Protec
         if (!sz.w && !sz.h) return;
         _evas_object_size_hint_alloc(eo_obj, obj);
      }
-   if ((obj->size_hints->user_min.w == sz.w) && (obj->size_hints->user_min.h 
== sz.h)) return;
+   if (EINA_SIZE2D_EQ(obj->size_hints->user_min, sz)) return;
    obj->size_hints->user_min = sz;
    evas_object_inform_call_changed_size_hints(eo_obj, obj);
 }

-- 


Reply via email to