return EINA_TRUE;
}
+
+EAPI Eina_Rectangle_Outside
+eina_rectangle_outside_position(Eina_Rectangle *rect1, Eina_Rectangle *rect2)
+{
+ Eina_Rectangle_Outside ret = 0;
+
+ if (rect1->y > rect2->y)
+ ret |= EINA_RECTANGLE_OUTSIDE_TOP;
+ if (rect1->x > rect2->x)
+ ret |= EINA_RECTANGLE_OUTSIDE_LEFT;
+ if (rect1->y + rect1->h < rect2->y + rect2->h)
+ ret |= EINA_RECTANGLE_OUTSIDE_BOTTOM;
+ if (rect1->x + rect1->w < rect2->x + rect2->w)
+ ret |= EINA_RECTANGLE_OUTSIDE_RIGHT;
+
+ return ret;
+}
} Eina_Rectangle_Packing;
/**
+ * @typedef Eina_Rectangle_Outside
+ * Enumeration gives the positions where a rectangle can be outside a other rectangle
+ * @since 1.19
+ */
+typedef enum {
+ EINA_RECTANGLE_OUTSIDE_TOP = 1,
+ EINA_RECTANGLE_OUTSIDE_LEFT = 2,
+ EINA_RECTANGLE_OUTSIDE_BOTTOM = 4,
+ EINA_RECTANGLE_OUTSIDE_RIGHT = 8
+} Eina_Rectangle_Outside;
+
+
+/**
* @brief Check if the given spans intersect.
*
* @param c1 The column of the first span.
*/
EAPI void eina_rectangle_pool_packing_set(Eina_Rectangle_Pool *pool,Eina_Rectangle_Packing type) EINA_ARG_NONNULL(1);
+/**
+ * @brief calculate where rect2 is outside of rect1
+ *
+ * @param rect1 the rect to use as anchor
+ * @param rect2 the rect to look for outside positions
+ *
+ * @return A or'ed map of Eina_Rectangle_Outside values
+ * @since 1.19
+ */
+EAPI Eina_Rectangle_Outside eina_rectangle_outside_position(Eina_Rectangle *rect1, Eina_Rectangle *rect2);
+
#include "eina_inline_rectangle.x"
/**
}
END_TEST
+START_TEST(eina_rectangle_position_test)
+{
+ Eina_Rectangle middle, top, down, right, left;
+ EINA_RECTANGLE_SET(&middle, -1, -1, 2.0, 2.0);
+ EINA_RECTANGLE_SET(&top, -1, -2, 2.0, 2.0);
+ EINA_RECTANGLE_SET(&right, 0, -1, 2.0, 2.0);
+ EINA_RECTANGLE_SET(&left, -2, -1, 2.0, 2.0);
+ EINA_RECTANGLE_SET(&down, -1, 0, 2.0, 2.0);
+
+ ck_assert_int_eq(eina_rectangle_outside_position(&middle, &top), EINA_RECTANGLE_OUTSIDE_TOP) ;
+ ck_assert_int_eq(eina_rectangle_outside_position(&middle, &down), EINA_RECTANGLE_OUTSIDE_BOTTOM) ;
+ ck_assert_int_eq(eina_rectangle_outside_position(&middle, &right), EINA_RECTANGLE_OUTSIDE_RIGHT) ;
+ ck_assert_int_eq(eina_rectangle_outside_position(&middle, &left), EINA_RECTANGLE_OUTSIDE_LEFT) ;
+
+}
+END_TEST
+
void
eina_test_rectangle(TCase *tc)
{
tcase_add_test(tc, eina_rectangle_pool);
tcase_add_test(tc, eina_rectangle_pool_skyline);
tcase_add_test(tc, eina_rectangle_union_intersect);
+ tcase_add_test(tc, eina_rectangle_position_test);
}