#define EFL_UI_RELATIVE_LAYOUT_RELATION_SET_GET(direction, DIRECTION) \
EOLIAN static void \
- _efl_ui_relative_layout_relation_ ## direction ## _set(Eo *obj EINA_UNUSED, Efl_Ui_Relative_Layout_Data *pd, Eo *child, Eo *target, double relative) \
+ _efl_ui_relative_layout_relation_ ## direction ## _set(Eo *obj, Efl_Ui_Relative_Layout_Data *pd, Eo *child, Eo *target, double relative) \
{ \
Efl_Ui_Relative_Layout_Child *rc; \
+ if (!child) return; \
rc = _relative_child_get(pd, child); \
+ if (!rc) return; \
if (target) rc->rel[DIRECTION].to = target; \
if (relative < 0) relative = 0; \
else if (relative > 1) relative = 1; \
rc->rel[DIRECTION].relative = relative; \
+ efl_pack_layout_request(obj); \
} \
\
EOLIAN static void \
_efl_ui_relative_layout_relation_ ## direction ## _get(const Eo *obj EINA_UNUSED, Efl_Ui_Relative_Layout_Data *pd, Eo *child, Eo **target, double *relative) \
{ \
Efl_Ui_Relative_Layout_Child *rc; \
- rc = _relative_child_get(pd, child); \
- if (target) *target = rc->rel[DIRECTION].to; \
- if (relative) *relative = rc->rel[DIRECTION].relative; \
+ Eo *rel_to = NULL; \
+ double rel_relative = 0.0; \
+ rc = eina_hash_find(pd->children, &child); \
+ if (rc) \
+ { \
+ rel_to = rc->rel[DIRECTION].to; \
+ rel_relative = rc->rel[DIRECTION].relative; \
+ } \
+ else \
+ ERR("child(%p(%s)) is not registered", child, efl_class_name_get(child)); \
+ if (target) *target = rel_to; \
+ if (relative) *relative = rel_relative; \
}
#endif
}
EFL_END_TEST
+EFL_START_TEST (efl_ui_relative_layout_relation_set)
+{
+ Eo *btn;
+ Eo *target = NULL;
+ double relative;
+
+ btn = efl_add(EFL_UI_BUTTON_CLASS, layout);
+
+ // negative test
+ efl_ui_relative_layout_relation_top_get(layout, NULL, &target, &relative);
+ ck_assert_ptr_eq(target, NULL);
+ ck_assert(EINA_DBL_EQ(relative, 0.0));
+
+ efl_ui_relative_layout_relation_top_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, NULL);
+ ck_assert(EINA_DBL_EQ(relative, 0.0));
+
+ efl_ui_relative_layout_relation_top_set(layout, NULL, NULL, 0.0);
+ ck_assert_ptr_eq(target, NULL);
+ ck_assert(EINA_DBL_EQ(relative, 0.0));
+
+ // default value test
+ efl_ui_relative_layout_relation_top_set(layout, btn, layout, 0.0);
+
+ efl_ui_relative_layout_relation_top_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 0.0));
+ efl_ui_relative_layout_relation_bottom_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 1.0));
+ efl_ui_relative_layout_relation_left_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 0.0));
+ efl_ui_relative_layout_relation_right_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 1.0));
+
+ // positive test
+ efl_ui_relative_layout_relation_top_set(layout, btn, layout, 0.123);
+ efl_ui_relative_layout_relation_top_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 0.123));
+
+ efl_ui_relative_layout_relation_top_set(layout, btn, NULL, 0.456);
+ efl_ui_relative_layout_relation_top_get(layout, btn, &target, &relative);
+ ck_assert_ptr_eq(target, layout);
+ ck_assert(EINA_DBL_EQ(relative, 0.456));
+}
+EFL_END_TEST
+
void efl_ui_test_relative_layout(TCase *tc)
{
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
tcase_add_test(tc, efl_ui_relative_layout_class_check);
tcase_add_test(tc, efl_ui_relative_layout_layout_update);
tcase_add_test(tc, efl_ui_relative_layout_layout_update_chain);
+ tcase_add_test(tc, efl_ui_relative_layout_relation_set);
}