summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-28 17:13:07 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-12-02 18:30:23 +0100
commit842e6e9c67a65b7193190a91511912e895a04b58 (patch)
treeab4ad7a6fa49935ab7166cd130a129306c0b59ab
parent7033816554497b402cb1d48716955931592be4fa (diff)
efl_ui_spotlight_container: bring in min / max handling
the spotlight now is setting the overall correct min and max size on itself. Additionally, the page size is now clamped to the size of the container. Correct min size of the container is defined to the MAX min size of all the content. The correct max size of the container is defined to the MIN max size of all the content. ref T7991 Differential Revision: https://phab.enlightenment.org/D10766
-rw-r--r--src/bin/elementary/test_ui_spotlight.c1
-rw-r--r--src/lib/elementary/efl_ui_spotlight_container.c89
-rw-r--r--src/lib/elementary/efl_ui_spotlight_container.eo1
-rw-r--r--src/lib/elementary/efl_ui_spotlight_indicator_icon.c1
-rw-r--r--src/tests/elementary/efl_ui_test_spotlight.c42
5 files changed, 122 insertions, 12 deletions
diff --git a/src/bin/elementary/test_ui_spotlight.c b/src/bin/elementary/test_ui_spotlight.c
index 48736fe7db..281b55e510 100644
--- a/src/bin/elementary/test_ui_spotlight.c
+++ b/src/bin/elementary/test_ui_spotlight.c
@@ -92,6 +92,7 @@ view_add(View_Type p, Eo *parent)
92 snprintf(buf, sizeof(buf), "List Page - Item #%d", i); 92 snprintf(buf, sizeof(buf), "List Page - Item #%d", i);
93 elm_list_item_append(page, buf, NULL, NULL, NULL, NULL); 93 elm_list_item_append(page, buf, NULL, NULL, NULL, NULL);
94 } 94 }
95 efl_gfx_hint_size_min_set(page, EINA_SIZE2D(200, 200));
95 evas_object_size_hint_weight_set(page, EVAS_HINT_EXPAND, 96 evas_object_size_hint_weight_set(page, EVAS_HINT_EXPAND,
96 EVAS_HINT_EXPAND); 97 EVAS_HINT_EXPAND);
97 evas_object_size_hint_align_set(page, EVAS_HINT_FILL, 98 evas_object_size_hint_align_set(page, EVAS_HINT_FILL,
diff --git a/src/lib/elementary/efl_ui_spotlight_container.c b/src/lib/elementary/efl_ui_spotlight_container.c
index b812501d6b..8f38012f0d 100644
--- a/src/lib/elementary/efl_ui_spotlight_container.c
+++ b/src/lib/elementary/efl_ui_spotlight_container.c
@@ -29,6 +29,7 @@ typedef struct _Efl_Ui_Spotlight_Container_Data
29 } transition_done; 29 } transition_done;
30 Efl_Ui_Spotlight_Manager *transition; 30 Efl_Ui_Spotlight_Manager *transition;
31 Efl_Ui_Spotlight_Indicator *indicator; 31 Efl_Ui_Spotlight_Indicator *indicator;
32 Eina_Size2D min, max;
32 double position; 33 double position;
33 Eina_Bool fill_width: 1; 34 Eina_Bool fill_width: 1;
34 Eina_Bool fill_height: 1; 35 Eina_Bool fill_height: 1;
@@ -157,27 +158,32 @@ _transition_event_emission(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Container_Data
157} 158}
158 159
159static void 160static void
160_resize_cb(void *data, const Efl_Event *ev) 161_emit_page_size(Efl_Ui_Spotlight_Container *obj, Efl_Ui_Spotlight_Container_Data *pd)
161{ 162{
162 Efl_Ui_Spotlight_Container_Data *pd = data;
163 Eina_Size2D sz; 163 Eina_Size2D sz;
164 164
165 sz = efl_gfx_entity_size_get(ev->object); 165 sz = efl_gfx_entity_size_get(obj);
166
167 if (!pd->fill_width)
168 sz.w = MIN(pd->page_spec.sz.w, sz.w);
166 169
167 if (pd->fill_width) pd->page_spec.sz.w = sz.w; 170 if (!pd->fill_height)
168 if (pd->fill_height) pd->page_spec.sz.h = sz.h; 171 sz.h = MIN(pd->page_spec.sz.h, sz.h);
169 172
170 if (pd->transition) 173 if (pd->transition)
171 efl_ui_spotlight_manager_size_set(pd->transition, pd->page_spec.sz); 174 efl_ui_spotlight_manager_size_set(pd->transition, sz);
172} 175}
173 176
174static void 177static void
175_position_cb(void *data, const Efl_Event *ev EINA_UNUSED) 178_resize_cb(void *data, const Efl_Event *ev)
176{ 179{
177 Efl_Ui_Spotlight_Container_Data *pd = data; 180 _emit_page_size(ev->object, data);
181}
178 182
179 if (pd->transition) 183static void
180 efl_ui_spotlight_manager_size_set(pd->transition, pd->page_spec.sz); 184_position_cb(void *data, const Efl_Event *ev EINA_UNUSED)
185{
186 _emit_page_size(ev->object, data);
181} 187}
182 188
183EFL_CALLBACKS_ARRAY_DEFINE(spotlight_resized, 189EFL_CALLBACKS_ARRAY_DEFINE(spotlight_resized,
@@ -193,6 +199,7 @@ _efl_ui_spotlight_container_efl_object_constructor(Eo *obj,
193 199
194 obj = efl_constructor(efl_super(obj, MY_CLASS)); 200 obj = efl_constructor(efl_super(obj, MY_CLASS));
195 201
202 pd->max = EINA_SIZE2D(INT_MAX, INT_MAX);
196 pd->animation_enabled = EINA_TRUE; 203 pd->animation_enabled = EINA_TRUE;
197 pd->position = -1; 204 pd->position = -1;
198 pd->curr.page = NULL; 205 pd->curr.page = NULL;
@@ -263,9 +270,41 @@ _child_inv(void *data, const Efl_Event *ev)
263 _unpack(data, pd, ev->object, index); 270 _unpack(data, pd, ev->object, index);
264} 271}
265 272
273#define ADJUST_PRIVATE_MIN_MAX(obj, subobj, pd) \
274 do \
275 { \
276 min = efl_gfx_hint_size_combined_min_get(subobj); \
277 max = efl_gfx_hint_size_combined_max_get(subobj); \
278 pd->min.w = MAX(pd->min.w, min.w); \
279 pd->min.h = MAX(pd->min.h, min.h); \
280 pd->max.w = MIN(pd->max.w, max.w); \
281 pd->max.h = MIN(pd->max.h, max.h); \
282 } \
283 while(0)
284
285#define FLUSH_MIN_MAX(obj, pd) \
286 do \
287 { \
288 efl_gfx_hint_size_restricted_min_set(obj, pd->min); \
289 efl_gfx_hint_size_restricted_max_set(obj, pd->max); \
290 } \
291 while(0)
292
293static void
294_hints_changed_cb(void *data, const Efl_Event *ev EINA_UNUSED)
295{
296 efl_canvas_group_change(data);
297}
298
299EFL_CALLBACKS_ARRAY_DEFINE(children_evt,
300 {EFL_EVENT_INVALIDATE, _child_inv},
301 {EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, _hints_changed_cb}
302)
303
266static Eina_Bool 304static Eina_Bool
267_register_child(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Container_Data *pd, Efl_Gfx_Entity *subobj) 305_register_child(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Container_Data *pd, Efl_Gfx_Entity *subobj)
268{ 306{
307 Eina_Size2D min, max;
269 EINA_SAFETY_ON_NULL_RETURN_VAL(subobj, EINA_FALSE); 308 EINA_SAFETY_ON_NULL_RETURN_VAL(subobj, EINA_FALSE);
270 if (eina_list_data_find(pd->content_list, subobj)) 309 if (eina_list_data_find(pd->content_list, subobj))
271 { 310 {
@@ -275,7 +314,10 @@ _register_child(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Container_Data *pd, Efl_Gf
275 if (!efl_ui_widget_sub_object_add(obj, subobj)) 314 if (!efl_ui_widget_sub_object_add(obj, subobj))
276 return EINA_FALSE; 315 return EINA_FALSE;
277 316
278 efl_event_callback_add(subobj, EFL_EVENT_INVALIDATE, _child_inv, obj); 317 efl_event_callback_array_add(subobj, children_evt(), obj);
318
319 ADJUST_PRIVATE_MIN_MAX(obj, subobj, pd);
320 FLUSH_MIN_MAX(obj, pd);
279 321
280 return EINA_TRUE; 322 return EINA_TRUE;
281} 323}
@@ -543,7 +585,8 @@ _unpack(Eo *obj,
543 pd->indicator && !pd->transition) 585 pd->indicator && !pd->transition)
544 efl_ui_spotlight_indicator_position_update(pd->indicator, efl_pack_index_get(obj, pd->curr.page)); 586 efl_ui_spotlight_indicator_position_update(pd->indicator, efl_pack_index_get(obj, pd->curr.page));
545 587
546 efl_event_callback_del(subobj, EFL_EVENT_INVALIDATE, _child_inv, obj); 588 efl_event_callback_array_del(subobj, children_evt(), obj);
589 efl_canvas_group_change(obj);
547} 590}
548 591
549EOLIAN static Eina_Bool 592EOLIAN static Eina_Bool
@@ -755,6 +798,28 @@ _efl_ui_spotlight_container_animated_transition_get(const Eo *obj EINA_UNUSED, E
755 return pd->animation_enabled; 798 return pd->animation_enabled;
756} 799}
757 800
801EOLIAN static void
802_efl_ui_spotlight_container_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Container_Data *pd)
803{
804 Efl_Ui_Widget *content;
805 Eina_List *n;
806
807 efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
808
809 pd->min = EINA_SIZE2D(0,0);
810 pd->max = EINA_SIZE2D(INT_MAX, INT_MAX);
811
812 EINA_LIST_FOREACH(pd->content_list, n, content)
813 {
814 Eina_Size2D min, max;
815
816 min = efl_gfx_hint_size_combined_min_get(content);
817 max = efl_gfx_hint_size_combined_max_get(content);
818
819 ADJUST_PRIVATE_MIN_MAX(obj, content, pd);
820 }
821 FLUSH_MIN_MAX(obj, pd);
822}
758 823
759 824
760#include "efl_ui_spotlight_container.eo.c" 825#include "efl_ui_spotlight_container.eo.c"
diff --git a/src/lib/elementary/efl_ui_spotlight_container.eo b/src/lib/elementary/efl_ui_spotlight_container.eo
index 2f462f50d4..766063c8f3 100644
--- a/src/lib/elementary/efl_ui_spotlight_container.eo
+++ b/src/lib/elementary/efl_ui_spotlight_container.eo
@@ -131,5 +131,6 @@ class @beta Efl.Ui.Spotlight.Container extends Efl.Ui.Widget implements Efl.Pack
131 Efl.Pack_Linear.pack_content_get; 131 Efl.Pack_Linear.pack_content_get;
132 Efl.Pack_Linear.pack_index_get; 132 Efl.Pack_Linear.pack_index_get;
133 Efl.Pack_Linear.pack_unpack_at; 133 Efl.Pack_Linear.pack_unpack_at;
134 Efl.Canvas.Group.group_calculate;
134 } 135 }
135} 136}
diff --git a/src/lib/elementary/efl_ui_spotlight_indicator_icon.c b/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
index 5f59b513cd..4ac177580d 100644
--- a/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
+++ b/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
@@ -12,6 +12,7 @@ typedef struct {
12 Efl_Ui_Spotlight_Container *container; 12 Efl_Ui_Spotlight_Container *container;
13 Efl_Canvas_Layout *layout; 13 Efl_Canvas_Layout *layout;
14 double last_position; 14 double last_position;
15 Eina_Size2D min, max;
15} Efl_Ui_Spotlight_Indicator_Icon_Data; 16} Efl_Ui_Spotlight_Indicator_Icon_Data;
16 17
17static void 18static void
diff --git a/src/tests/elementary/efl_ui_test_spotlight.c b/src/tests/elementary/efl_ui_test_spotlight.c
index c7fd2d7d2b..8262217779 100644
--- a/src/tests/elementary/efl_ui_test_spotlight.c
+++ b/src/tests/elementary/efl_ui_test_spotlight.c
@@ -648,6 +648,47 @@ EFL_START_TEST (efl_ui_spotlight_animated_transition)
648} 648}
649EFL_END_TEST 649EFL_END_TEST
650 650
651EFL_START_TEST (efl_ui_spotlight_min_max_sizing)
652{
653 Efl_Ui_Button *btn0, *btn1;
654 Eina_Size2D min, size;
655
656 btn0 = efl_add(WIDGET_CLASS, container);
657 efl_gfx_hint_size_min_set(btn0, EINA_SIZE2D(20, 200));
658
659 btn1 = efl_add(WIDGET_CLASS, container);
660 efl_gfx_hint_size_min_set(btn1, EINA_SIZE2D(200, 20));
661
662 efl_pack_end(container, btn0);
663 efl_pack_end(container, btn1);
664 min = efl_gfx_hint_size_restricted_min_get(container);
665 ck_assert_int_eq(min.w, 200);
666 ck_assert_int_eq(min.h, 200);
667
668 efl_gfx_hint_size_min_set(btn0, EINA_SIZE2D(20, 300));
669 efl_canvas_group_calculate(container);
670
671 min = efl_gfx_hint_size_restricted_min_get(container);
672 ck_assert_int_eq(min.w, 200);
673 ck_assert_int_eq(min.h, 300);
674
675 efl_gfx_hint_size_min_set(btn0, EINA_SIZE2D(20, 20));
676 efl_canvas_group_calculate(container);
677
678 min = efl_gfx_hint_size_restricted_min_get(container);
679 ck_assert_int_eq(min.w, 200);
680 ck_assert_int_eq(min.h, 20);
681
682 efl_ui_spotlight_size_set(container, EINA_SIZE2D(2000, 2000));
683
684 efl_gfx_entity_size_set(container, EINA_SIZE2D(200, 200));
685 size = efl_gfx_entity_size_get(btn0);
686 ck_assert_int_eq(size.w, 200);
687 ck_assert_int_eq(size.h, 200);
688
689}
690EFL_END_TEST
691
651static void 692static void
652spotlight_setup() 693spotlight_setup()
653{ 694{
@@ -684,4 +725,5 @@ void efl_ui_test_spotlight(TCase *tc)
684 tcase_add_test(tc, efl_ui_spotlight_test_pop2); 725 tcase_add_test(tc, efl_ui_spotlight_test_pop2);
685 tcase_add_test(tc, efl_ui_spotlight_test_pop3); 726 tcase_add_test(tc, efl_ui_spotlight_test_pop3);
686 tcase_add_test(tc, efl_ui_spotlight_animated_transition); 727 tcase_add_test(tc, efl_ui_spotlight_animated_transition);
728 tcase_add_test(tc, efl_ui_spotlight_min_max_sizing);
687} 729}