forked from enlightenment/efl
ui.box_stack: refactor layout_update
Summary: This patch remove evas_box function from Efl.Ui.Box_Stack and add unit test. Depends on D8214 Test Plan: 1. make check 2. elementary_test -to 'efl.ui.box_stack' Reviewers: zmike, Jaehyun_Cho, cedric Reviewed By: zmike, Jaehyun_Cho, cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8094
This commit is contained in:
parent
e80169a844
commit
77f2782d29
|
@ -1403,6 +1403,7 @@ bin/elementary/test_tooltip.c \
|
||||||
bin/elementary/test_transit.c \
|
bin/elementary/test_transit.c \
|
||||||
bin/elementary/test_transit_bezier.c \
|
bin/elementary/test_transit_bezier.c \
|
||||||
bin/elementary/test_ui_box.c \
|
bin/elementary/test_ui_box.c \
|
||||||
|
bin/elementary/test_ui_box_stack.c \
|
||||||
bin/elementary/test_ui_clock.c \
|
bin/elementary/test_ui_clock.c \
|
||||||
bin/elementary/test_ui_table.c \
|
bin/elementary/test_ui_table.c \
|
||||||
bin/elementary/test_ui_popup.c \
|
bin/elementary/test_ui_popup.c \
|
||||||
|
@ -1935,6 +1936,7 @@ tests_elementary_efl_ui_suite_SOURCES = \
|
||||||
tests/elementary/efl_ui_test_focus_sub.c \
|
tests/elementary/efl_ui_test_focus_sub.c \
|
||||||
tests/elementary/efl_ui_test_box.c \
|
tests/elementary/efl_ui_test_box.c \
|
||||||
tests/elementary/efl_ui_test_box_flow.c \
|
tests/elementary/efl_ui_test_box_flow.c \
|
||||||
|
tests/elementary/efl_ui_test_box_stack.c \
|
||||||
tests/elementary/efl_ui_test_table.c \
|
tests/elementary/efl_ui_test_table.c \
|
||||||
tests/elementary/efl_ui_test_relative_layout.c \
|
tests/elementary/efl_ui_test_relative_layout.c \
|
||||||
tests/elementary/efl_ui_test_grid.c \
|
tests/elementary/efl_ui_test_grid.c \
|
||||||
|
|
|
@ -134,6 +134,7 @@ elementary_test_src = [
|
||||||
'test_transit.c',
|
'test_transit.c',
|
||||||
'test_transit_bezier.c',
|
'test_transit_bezier.c',
|
||||||
'test_ui_box.c',
|
'test_ui_box.c',
|
||||||
|
'test_ui_box_stack.c',
|
||||||
'test_ui_clock.c',
|
'test_ui_clock.c',
|
||||||
'test_ui_table.c',
|
'test_ui_table.c',
|
||||||
'test_ui_popup.c',
|
'test_ui_popup.c',
|
||||||
|
|
|
@ -29,8 +29,8 @@ void test_box_horiz(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_homo(void *data, Evas_Object *obj, void *event_info);
|
void test_box_homo(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_transition(void *data, Evas_Object *obj, void *event_info);
|
void test_box_transition(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_align(void *data, Evas_Object *obj, void *event_info);
|
void test_box_align(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_box_stack(void *data, Evas_Object *obj, void *event_info);
|
|
||||||
void test_ui_box(void *data, Evas_Object *obj, void *event_info);
|
void test_ui_box(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
void test_ui_box_stack(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_button(void *data, Evas_Object *obj, void *event_info);
|
void test_button(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_ui_button(void *data, Evas_Object *obj, void *event_info);
|
void test_ui_button(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_cnp(void *data, Evas_Object *obj, void *event_info);
|
void test_cnp(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -826,7 +826,6 @@ add_tests:
|
||||||
ADD_TEST(NULL, "Containers", "Box Homogeneous", test_box_homo);
|
ADD_TEST(NULL, "Containers", "Box Homogeneous", test_box_homo);
|
||||||
ADD_TEST(NULL, "Containers", "Box Transition", test_box_transition);
|
ADD_TEST(NULL, "Containers", "Box Transition", test_box_transition);
|
||||||
ADD_TEST(NULL, "Containers", "Box Align", test_box_align);
|
ADD_TEST(NULL, "Containers", "Box Align", test_box_align);
|
||||||
ADD_TEST(NULL, "Containers", "Box Stack", test_box_stack);
|
|
||||||
ADD_TEST(NULL, "Containers", "Table", test_table);
|
ADD_TEST(NULL, "Containers", "Table", test_table);
|
||||||
ADD_TEST(NULL, "Containers", "Table Homogeneous", test_table2);
|
ADD_TEST(NULL, "Containers", "Table Homogeneous", test_table2);
|
||||||
ADD_TEST(NULL, "Containers", "Table 3", test_table3);
|
ADD_TEST(NULL, "Containers", "Table 3", test_table3);
|
||||||
|
@ -841,6 +840,7 @@ add_tests:
|
||||||
|
|
||||||
//------------------------------//
|
//------------------------------//
|
||||||
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Box", test_ui_box);
|
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Box", test_ui_box);
|
||||||
|
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Box_Stack", test_ui_box_stack);
|
||||||
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table", test_ui_table);
|
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table", test_ui_table);
|
||||||
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table (Linear API)", test_ui_table_linear);
|
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table (Linear API)", test_ui_table_linear);
|
||||||
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table_Static", test_ui_table_static);
|
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table_Static", test_ui_table_static);
|
||||||
|
|
|
@ -882,44 +882,3 @@ test_box_align(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
evas_object_resize(win, 300, 400);
|
evas_object_resize(win, 300, 400);
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
test_box_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
||||||
void *event_info EINA_UNUSED)
|
|
||||||
{
|
|
||||||
Evas_Object *win, *bx, *o;
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
|
|
||||||
win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
|
|
||||||
efl_text_set(efl_added, "Efl.Ui.Box_Stack"),
|
|
||||||
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
|
||||||
|
|
||||||
efl_gfx_color_set(efl_part(win, "background"), 24, 24, 64, 255);
|
|
||||||
|
|
||||||
/* stacked box, with items in the center-bottom. its default weight makes
|
|
||||||
* the window resizable */
|
|
||||||
bx = efl_add(EFL_UI_BOX_STACK_CLASS, win,
|
|
||||||
efl_pack_align_set(efl_added, 0.5, 1.0));
|
|
||||||
efl_content_set(win, bx);
|
|
||||||
|
|
||||||
/* stretched rectangle */
|
|
||||||
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
|
|
||||||
efl_gfx_color_set(efl_added, 0, 64, 128, 255));
|
|
||||||
efl_pack(bx, o);
|
|
||||||
|
|
||||||
/* rectangle with a max size */
|
|
||||||
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
|
|
||||||
efl_gfx_color_set(efl_added, 64, 128, 64, 255),
|
|
||||||
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(128, 20)));
|
|
||||||
efl_pack(bx, o);
|
|
||||||
|
|
||||||
/* image with a forced min size */
|
|
||||||
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
|
|
||||||
o = efl_add(EFL_UI_IMAGE_CLASS, win,
|
|
||||||
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(64, 64)),
|
|
||||||
efl_file_set(efl_added, buf),
|
|
||||||
efl_file_load(efl_added));
|
|
||||||
efl_pack(bx, o);
|
|
||||||
|
|
||||||
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 300));
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "test.h"
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "elementary_config.h"
|
||||||
|
#endif
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test_ui_box_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *win, *bx, *o;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
|
||||||
|
efl_text_set(efl_added, "Efl.Ui.Box_Stack"),
|
||||||
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
||||||
|
|
||||||
|
efl_gfx_color_set(efl_part(win, "background"), 24, 24, 64, 255);
|
||||||
|
|
||||||
|
bx = efl_add(EFL_UI_BOX_STACK_CLASS, win);
|
||||||
|
efl_content_set(win, bx);
|
||||||
|
|
||||||
|
/* stretched rectangle */
|
||||||
|
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
|
||||||
|
efl_gfx_color_set(efl_added, 0, 64, 128, 255));
|
||||||
|
efl_pack(bx, o);
|
||||||
|
|
||||||
|
/* rectangle with a max size */
|
||||||
|
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
|
||||||
|
efl_gfx_color_set(efl_added, 64, 128, 64, 255),
|
||||||
|
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(128, 20)),
|
||||||
|
efl_gfx_hint_align_set(efl_added, 0.5, 1.0));
|
||||||
|
efl_pack(bx, o);
|
||||||
|
|
||||||
|
/* image with a forced min size */
|
||||||
|
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
|
||||||
|
o = efl_add(EFL_UI_IMAGE_CLASS, win,
|
||||||
|
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(64, 64)),
|
||||||
|
efl_file_set(efl_added, buf),
|
||||||
|
efl_file_load(efl_added));
|
||||||
|
efl_pack(bx, o);
|
||||||
|
|
||||||
|
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 300));
|
||||||
|
}
|
|
@ -1,35 +1,102 @@
|
||||||
#define EFL_GFX_HINT_PROTECTED
|
#define EFL_GFX_HINT_PROTECTED
|
||||||
|
|
||||||
#include "efl_ui_box_private.h"
|
#include "efl_ui_box_private.h"
|
||||||
|
#include "efl_ui_container_layout.h"
|
||||||
|
|
||||||
#define MY_CLASS EFL_UI_BOX_STACK_CLASS
|
#define MY_CLASS EFL_UI_BOX_STACK_CLASS
|
||||||
|
|
||||||
|
typedef struct _Item_Calc Item_Calc;
|
||||||
|
|
||||||
|
struct _Item_Calc
|
||||||
|
{
|
||||||
|
Evas_Object *obj;
|
||||||
|
Efl_Ui_Container_Item_Hints hints[2]; /* 0 is x-axis, 1 is y-axis */
|
||||||
|
};
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED)
|
_efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Object_Box_Option *opt;
|
Evas_Object_Box_Option *opt;
|
||||||
Evas_Object_Box_Data *bd;
|
Evas_Object_Box_Data *bd;
|
||||||
Eina_Size2D min = { 0, 0 }, cmin;
|
Efl_Ui_Container_Layout_Calc box_calc[2];
|
||||||
|
Efl_Ui_Container_Item_Hints *hints;
|
||||||
|
Item_Calc *items, *item;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
Eina_Size2D want = { 0, 0 };
|
||||||
|
Evas_Object *old_child = NULL;
|
||||||
|
int i = 0, count;
|
||||||
|
|
||||||
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS));
|
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS));
|
||||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS);
|
bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS);
|
||||||
|
|
||||||
evas_object_box_layout_stack(wd->resize_obj, bd, NULL);
|
count = eina_list_count(bd->children);
|
||||||
|
if (!count)
|
||||||
|
{
|
||||||
|
efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(0, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_efl_ui_container_layout_init(obj, box_calc);
|
||||||
|
|
||||||
|
items = alloca(count * sizeof(*items));
|
||||||
|
#ifdef DEBUG
|
||||||
|
memset(items, 0, count * sizeof(*items));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Note: legacy evas_object_box_layout_stack sets the box min size to be
|
|
||||||
* the MAX() of the children's sizes, rather than their min sizes. By fixing
|
|
||||||
* that, we can implement elm_win_resize_object_add() with a Efl.Ui.Box. */
|
|
||||||
EINA_LIST_FOREACH(bd->children, l, opt)
|
EINA_LIST_FOREACH(bd->children, l, opt)
|
||||||
{
|
{
|
||||||
Evas_Object *child = opt->obj;
|
item = &items[i++];
|
||||||
|
item->obj = opt->obj;
|
||||||
|
hints = item->hints;
|
||||||
|
|
||||||
cmin = efl_gfx_hint_size_combined_min_get(child);
|
_efl_ui_container_layout_item_init(opt->obj, hints);
|
||||||
if (cmin.w > min.w) min.w = cmin.w;
|
|
||||||
if (cmin.h > min.h) min.h = cmin.h;
|
if (want.w < hints[0].space)
|
||||||
|
want.w = hints[0].space;
|
||||||
|
if (want.h < hints[1].space)
|
||||||
|
want.h = hints[1].space;
|
||||||
}
|
}
|
||||||
efl_gfx_hint_size_restricted_min_set(obj, min);
|
|
||||||
|
if (box_calc[0].size < want.w)
|
||||||
|
box_calc[0].size = want.w;
|
||||||
|
if (box_calc[1].size < want.h)
|
||||||
|
box_calc[1].size = want.h;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
hints = items[i].hints;
|
||||||
|
Eina_Rect item_geom;
|
||||||
|
|
||||||
|
hints[0].space = box_calc[0].size -
|
||||||
|
(hints[0].margin[0] + hints[0].margin[1]);
|
||||||
|
hints[1].space = box_calc[1].size -
|
||||||
|
(hints[1].margin[0] + hints[1].margin[1]);
|
||||||
|
|
||||||
|
item_geom.w = ((hints[0].weight > 0) && hints[0].fill) ? hints[0].space : 0;
|
||||||
|
item_geom.h = ((hints[1].weight > 0) && hints[1].fill) ? hints[1].space : 0;
|
||||||
|
|
||||||
|
_efl_ui_container_layout_min_max_calc(hints, &item_geom.w, &item_geom.h,
|
||||||
|
(hints[0].aspect > 0) && (hints[1].aspect > 0));
|
||||||
|
|
||||||
|
item_geom.x = box_calc[0].pos + hints[0].margin[0] +
|
||||||
|
(hints[0].space - item_geom.w) * hints[0].align;
|
||||||
|
item_geom.y = box_calc[1].pos + hints[1].margin[0] +
|
||||||
|
(hints[1].space - item_geom.h) * hints[1].align;
|
||||||
|
|
||||||
|
efl_gfx_entity_geometry_set(items[i].obj, item_geom);
|
||||||
|
|
||||||
|
if (old_child)
|
||||||
|
efl_gfx_stack_above(items[i].obj, old_child);
|
||||||
|
old_child = items[i].obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
want.w += (box_calc[0].margin[0] + box_calc[0].margin[1]);
|
||||||
|
want.h += (box_calc[1].margin[0] + box_calc[1].margin[1]);
|
||||||
|
|
||||||
|
efl_gfx_hint_size_restricted_min_set(obj, want);
|
||||||
|
|
||||||
|
efl_event_callback_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "efl_ui_box_stack.eo.c"
|
#include "efl_ui_box_stack.eo.c"
|
||||||
|
|
|
@ -14,6 +14,7 @@ static const Efl_Test_Case etc[] = {
|
||||||
{ "efl_ui_focus_sub", efl_ui_test_focus_sub},
|
{ "efl_ui_focus_sub", efl_ui_test_focus_sub},
|
||||||
{ "efl_ui_box", efl_ui_test_box},
|
{ "efl_ui_box", efl_ui_test_box},
|
||||||
{ "efl_ui_box_flow", efl_ui_test_box_flow},
|
{ "efl_ui_box_flow", efl_ui_test_box_flow},
|
||||||
|
{ "efl_ui_box_stack", efl_ui_test_box_stack},
|
||||||
{ "efl_ui_table", efl_ui_test_table},
|
{ "efl_ui_table", efl_ui_test_table},
|
||||||
{ "efl_ui_grid", efl_ui_test_grid},
|
{ "efl_ui_grid", efl_ui_test_grid},
|
||||||
{ "efl_ui_relative_layout", efl_ui_test_relative_layout},
|
{ "efl_ui_relative_layout", efl_ui_test_relative_layout},
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
void efl_ui_test_box(TCase *tc);
|
void efl_ui_test_box(TCase *tc);
|
||||||
void efl_ui_test_box_flow(TCase *tc);
|
void efl_ui_test_box_flow(TCase *tc);
|
||||||
|
void efl_ui_test_box_stack(TCase *tc);
|
||||||
void efl_ui_test_table(TCase *tc);
|
void efl_ui_test_table(TCase *tc);
|
||||||
void efl_ui_test_grid(TCase *tc);
|
void efl_ui_test_grid(TCase *tc);
|
||||||
void efl_ui_test_relative_layout(TCase *tc);
|
void efl_ui_test_relative_layout(TCase *tc);
|
||||||
|
|
|
@ -0,0 +1,244 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "elementary_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Efl_Ui.h>
|
||||||
|
#include "elm_suite.h"
|
||||||
|
|
||||||
|
#define COORD_EQ(a, b) (!!(abs(a - b) < 2))
|
||||||
|
#define GEOMETRY_EQ(a, b) (COORD_EQ(a.x, b.x) && COORD_EQ(a.y, b.y) && \
|
||||||
|
COORD_EQ(a.w, b.w) && COORD_EQ(a.h, b.h))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Eina_Size2D max;
|
||||||
|
Eina_Size2D min;
|
||||||
|
double weightx;
|
||||||
|
double weighty;
|
||||||
|
double alignx;
|
||||||
|
double aligny;
|
||||||
|
int marginl;
|
||||||
|
int marginr;
|
||||||
|
int margint;
|
||||||
|
int marginb;
|
||||||
|
Efl_Gfx_Hint_Aspect mode;
|
||||||
|
Eina_Size2D aspect;
|
||||||
|
Eina_Bool fillx;
|
||||||
|
Eina_Bool filly;
|
||||||
|
Eina_Size2D layout_size;
|
||||||
|
Eina_Size2D layout_expected;
|
||||||
|
Eina_Rect expected;
|
||||||
|
char testname[1024];
|
||||||
|
} Hint;
|
||||||
|
|
||||||
|
static Hint hints[] = {
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(0, 0), 1, 1, 0.5, 0.5, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT(0, 0, 200, 200), "[0]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.5, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT(0, 0, 200, 200), "[1]" },
|
||||||
|
{ EINA_SIZE2D(50, 150), EINA_SIZE2D(70, 70), 1, 1, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_TRUE, EINA_TRUE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, (200 - 150) * 0.7, 70, 150), "[2]" },
|
||||||
|
{ EINA_SIZE2D(150, -1), EINA_SIZE2D(70, 70), 0, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[3]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[4]" },
|
||||||
|
{ EINA_SIZE2D(150, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_NONE, EINA_SIZE2D(0, 0), EINA_FALSE, EINA_TRUE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 200),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, (200 - 70) * 0.7, 70, 70), "[5]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[6]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
|
||||||
|
EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[7]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[8]" },
|
||||||
|
{ EINA_SIZE2D(-1, -1), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
|
||||||
|
EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[9]" },
|
||||||
|
{ EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[10]" },
|
||||||
|
{ EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 0, 1, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
|
||||||
|
EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[11]" },
|
||||||
|
{ EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(200, 200), EINA_SIZE2D(200, 210),
|
||||||
|
EINA_RECT((200 - 70) * 0.3, 0, 70, 70 * 3), "[12]" },
|
||||||
|
{ EINA_SIZE2D(-1, 150), EINA_SIZE2D(70, 70), 1, 0, 0.3, 0.7, 0, 0, 0, 0,
|
||||||
|
EFL_GFX_HINT_ASPECT_BOTH, EINA_SIZE2D(1, 3), EINA_TRUE, EINA_FALSE,
|
||||||
|
EINA_SIZE2D(300, 300), EINA_SIZE2D(300, 300),
|
||||||
|
EINA_RECT((300 - 70) * 0.3, (300 - 70 * 3) * 0.7, 70, 70 * 3), "[13]" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static Eo *win, *layout;
|
||||||
|
|
||||||
|
static void
|
||||||
|
btn_hint_set(Eo *btn, Hint *hint)
|
||||||
|
{
|
||||||
|
efl_gfx_entity_size_set(layout, hint->layout_size);
|
||||||
|
efl_gfx_hint_size_max_set(btn, hint->max);
|
||||||
|
efl_gfx_hint_size_min_set(btn, hint->min);
|
||||||
|
efl_gfx_hint_margin_set(btn, hint->marginl, hint->marginr, hint->margint,
|
||||||
|
hint->marginb);
|
||||||
|
efl_gfx_hint_weight_set(btn, hint->weightx, hint->weighty);
|
||||||
|
efl_gfx_hint_align_set(btn, hint->alignx, hint->aligny);
|
||||||
|
efl_gfx_hint_fill_set(btn, hint->fillx, hint->filly);
|
||||||
|
efl_gfx_hint_aspect_set(btn, hint->mode, hint->aspect);
|
||||||
|
efl_canvas_group_calculate(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
|
||||||
|
{
|
||||||
|
Eina_Size2D layout_size, layout_min;
|
||||||
|
|
||||||
|
layout_size = efl_gfx_entity_size_get(layout);
|
||||||
|
layout_min = efl_gfx_hint_size_combined_min_get(layout);
|
||||||
|
layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
|
||||||
|
layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
|
||||||
|
|
||||||
|
ck_assert_msg(GEOMETRY_EQ(btn_geom, hint->expected),
|
||||||
|
"Case %s failed... button geometry: (%d, %d, %d, %d) expected geometry: (%d, %d, %d, %d)",
|
||||||
|
hint->testname, btn_geom.x, btn_geom.y, btn_geom.w, btn_geom.h,
|
||||||
|
hint->expected.x, hint->expected.y, hint->expected.w, hint->expected.h);
|
||||||
|
ck_assert_msg(COORD_EQ(layout_size.w, hint->layout_expected.w) &&
|
||||||
|
COORD_EQ(layout_size.h, hint->layout_expected.h),
|
||||||
|
"Case %s failed... layout size: (%d, %d) expected size: (%d, %d)",
|
||||||
|
hint->testname, layout_size.w, layout_size.h,
|
||||||
|
hint->layout_expected.w, hint->layout_expected.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
layout_setup()
|
||||||
|
{
|
||||||
|
win = win_add();
|
||||||
|
|
||||||
|
layout = efl_add(EFL_UI_BOX_STACK_CLASS, win,
|
||||||
|
efl_pack_align_set(efl_added, 0.8, 0.2),
|
||||||
|
efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
layout_teardown()
|
||||||
|
{
|
||||||
|
if (win)
|
||||||
|
{
|
||||||
|
efl_del(win);
|
||||||
|
win = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EFL_START_TEST (efl_ui_box_stack_class_check)
|
||||||
|
{
|
||||||
|
const char *class;
|
||||||
|
|
||||||
|
class = efl_class_name_get(layout);
|
||||||
|
|
||||||
|
ck_assert(class != NULL);
|
||||||
|
ck_assert(!strcmp(class, "Efl.Ui.Box_Stack"));
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
|
EFL_START_TEST (efl_ui_box_stack_layout_update)
|
||||||
|
{
|
||||||
|
int i, max_index = (sizeof(hints) / sizeof(Hint));
|
||||||
|
|
||||||
|
Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||||
|
efl_pack_end(layout, efl_added));
|
||||||
|
|
||||||
|
for (i = 0; i < max_index; i++)
|
||||||
|
{
|
||||||
|
btn_hint_set(btn, &hints[i]);
|
||||||
|
btn_geom_assert(&hints[i], efl_gfx_entity_geometry_get(btn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
|
EFL_START_TEST (efl_ui_box_stack_size)
|
||||||
|
{
|
||||||
|
#define USERMIN_CHECK(a, b) \
|
||||||
|
efl_canvas_group_calculate(layout); \
|
||||||
|
user_min = efl_gfx_hint_size_min_get(layout); \
|
||||||
|
ck_assert_msg(COORD_EQ(user_min.w, (a)) && COORD_EQ(user_min.h, (b)), \
|
||||||
|
"Case box_size failed... user_min: (%d, %d) expected user_min: (%d, %d)", \
|
||||||
|
user_min.w, user_min.h, (a), (b));
|
||||||
|
|
||||||
|
#define MIN_CHECK(a, b) \
|
||||||
|
efl_canvas_group_calculate(layout); \
|
||||||
|
min = efl_gfx_hint_size_combined_min_get(layout); \
|
||||||
|
ck_assert_msg(COORD_EQ(min.w, (a)) && COORD_EQ(min.h, (b)), \
|
||||||
|
"Case box_size failed... min: (%d, %d) expected min: (%d, %d)", \
|
||||||
|
min.w, min.h, (a), (b));
|
||||||
|
|
||||||
|
Eo *btn, *btn2, *btn3;
|
||||||
|
Eina_Size2D min, user_min;
|
||||||
|
|
||||||
|
btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||||
|
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
|
||||||
|
efl_pack_end(layout, efl_added));
|
||||||
|
|
||||||
|
USERMIN_CHECK(0, 0);
|
||||||
|
MIN_CHECK(100, 100);
|
||||||
|
|
||||||
|
btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||||
|
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(300, 300)),
|
||||||
|
efl_pack_end(layout, efl_added));
|
||||||
|
btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||||
|
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(200, 200)),
|
||||||
|
efl_pack_end(layout, efl_added));
|
||||||
|
USERMIN_CHECK(0, 0);
|
||||||
|
MIN_CHECK(300, 300);
|
||||||
|
|
||||||
|
efl_pack_unpack(layout, btn2);
|
||||||
|
USERMIN_CHECK(0, 0);
|
||||||
|
MIN_CHECK(200, 200);
|
||||||
|
|
||||||
|
efl_pack_unpack(layout, btn3);
|
||||||
|
USERMIN_CHECK(0, 0);
|
||||||
|
MIN_CHECK(100, 100);
|
||||||
|
|
||||||
|
efl_pack_unpack(layout, btn);
|
||||||
|
USERMIN_CHECK(0, 0);
|
||||||
|
MIN_CHECK(0, 0);
|
||||||
|
|
||||||
|
efl_pack_end(layout, btn);
|
||||||
|
efl_gfx_hint_size_min_set(layout, EINA_SIZE2D(200, 200));
|
||||||
|
USERMIN_CHECK(200, 200);
|
||||||
|
MIN_CHECK(200, 200);
|
||||||
|
|
||||||
|
efl_pack_end(layout, btn2);
|
||||||
|
efl_pack_end(layout, btn3);
|
||||||
|
USERMIN_CHECK(200, 200);
|
||||||
|
MIN_CHECK(300, 300);
|
||||||
|
|
||||||
|
#undef USERMIN_ASSERT
|
||||||
|
#undef MIN_ASSERT
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
|
void efl_ui_test_box_stack(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
|
||||||
|
tcase_add_test(tc, efl_ui_box_stack_class_check);
|
||||||
|
tcase_add_test(tc, efl_ui_box_stack_layout_update);
|
||||||
|
tcase_add_test(tc, efl_ui_box_stack_size);
|
||||||
|
}
|
|
@ -126,6 +126,7 @@ efl_ui_suite_src = [
|
||||||
'efl_ui_test_focus_sub.c',
|
'efl_ui_test_focus_sub.c',
|
||||||
'efl_ui_test_box.c',
|
'efl_ui_test_box.c',
|
||||||
'efl_ui_test_box_flow.c',
|
'efl_ui_test_box_flow.c',
|
||||||
|
'efl_ui_test_box_stack.c',
|
||||||
'efl_ui_test_table.c',
|
'efl_ui_test_table.c',
|
||||||
'efl_ui_test_grid.c',
|
'efl_ui_test_grid.c',
|
||||||
'efl_ui_test_relative_layout.c',
|
'efl_ui_test_relative_layout.c',
|
||||||
|
|
Loading…
Reference in New Issue