summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-03 10:52:04 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-03 18:36:24 +0200
commit36eff7ed82a6d5dc1944dc6b03278c5bb9a7796d (patch)
tree6cc748d02f0630e7af96c42c69466e449e0b9e0d
parentd73190a0bfa1081927c0deef955d6d23b374a1ac (diff)
efl_ui_grid_position_manager: recalculate max min size correctly
we are walking all the items anyways, so we can recalc the minsize here anyways. Additionally, this pm was never tested with code that just passes a set of items at data-access init time, without calling item_added for each item. (Which is perfectly fine). With this commit this is now perfectly possible, Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9826
-rw-r--r--src/lib/elementary/efl_ui_position_manager_grid.c33
-rw-r--r--src/lib/elementary/efl_ui_position_manager_grid.eo1
2 files changed, 27 insertions, 7 deletions
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c b/src/lib/elementary/efl_ui_position_manager_grid.c
index cc628b6bec..92d495efc4 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.c
+++ b/src/lib/elementary/efl_ui_position_manager_grid.c
@@ -38,6 +38,13 @@ typedef struct {
38 int items; 38 int items;
39} Group_Cache_Line; 39} Group_Cache_Line;
40 40
41static inline void
42_update_min_size(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, int added_index EINA_UNUSED, Eina_Size2D min_size)
43{
44 pd->max_min_size.w = MAX(pd->max_min_size.w, min_size.w);
45 pd->max_min_size.h = MAX(pd->max_min_size.h, min_size.h);
46}
47
41static void 48static void
42_group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd) 49_group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
43{ 50{
@@ -50,6 +57,8 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
50 if (!pd->group_cache_dirty) 57 if (!pd->group_cache_dirty)
51 return; 58 return;
52 59
60 pd->max_min_size = EINA_SIZE2D(0, 0);
61
53 pd->group_cache_dirty = EINA_FALSE; 62 pd->group_cache_dirty = EINA_FALSE;
54 if (pd->group_cache) 63 if (pd->group_cache)
55 eina_inarray_free(pd->group_cache); 64 eina_inarray_free(pd->group_cache);
@@ -83,6 +92,7 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
83 line.group_header_size = EINA_SIZE2D(0, 0); 92 line.group_header_size = EINA_SIZE2D(0, 0);
84 line.items = 0; 93 line.items = 0;
85 } 94 }
95 _update_min_size(obj, pd, i, size_buffer[buffer_id].size);
86 } 96 }
87 eina_inarray_push(pd->group_cache, &line); 97 eina_inarray_push(pd->group_cache, &line);
88} 98}
@@ -509,13 +519,6 @@ _flush_abs_size(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd)
509} 519}
510 520
511static inline void 521static inline void
512_update_min_size(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, int added_index EINA_UNUSED, Eina_Size2D min_size)
513{
514 pd->max_min_size.w = MAX(pd->max_min_size.w, min_size.w);
515 pd->max_min_size.h = MAX(pd->max_min_size.h, min_size.h);
516}
517
518static inline void
519_flush_min_size(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd) 522_flush_min_size(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd)
520{ 523{
521 Eina_Size2D min_size = pd->max_min_size; 524 Eina_Size2D min_size = pd->max_min_size;
@@ -762,6 +765,22 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_data_access_v1_data_access
762 pd->callbacks.size.access = size_access; 765 pd->callbacks.size.access = size_access;
763 pd->callbacks.size.free_cb = size_access_free_cb; 766 pd->callbacks.size.free_cb = size_access_free_cb;
764 pd->size = size; 767 pd->size = size;
768 _group_cache_require(obj, pd);
769 _schedule_recalc_abs_size(obj, pd);
770
765} 771}
766 772
773EOLIAN static Efl_Object*
774_efl_ui_position_manager_grid_efl_object_finalize(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd)
775{
776 obj = efl_finalize(efl_super(obj, MY_CLASS));
777
778 pd->group_cache_dirty = EINA_TRUE;
779 _group_cache_require(obj, pd);
780 _schedule_recalc_abs_size(obj, pd);
781
782 return obj;
783}
784
785
767#include "efl_ui_position_manager_grid.eo.c" 786#include "efl_ui_position_manager_grid.eo.c"
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.eo b/src/lib/elementary/efl_ui_position_manager_grid.eo
index f8f1aa831f..0af0270545 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.eo
+++ b/src/lib/elementary/efl_ui_position_manager_grid.eo
@@ -17,5 +17,6 @@ class @beta Efl.Ui.Position_Manager.Grid extends Efl.Object
17 Efl.Ui.Position_Manager.Entity.relative_item; 17 Efl.Ui.Position_Manager.Entity.relative_item;
18 Efl.Ui.Layout_Orientable.orientation {set; get;} 18 Efl.Ui.Layout_Orientable.orientation {set; get;}
19 Efl.Ui.Position_Manager.Data_Access_V1.data_access {set;} 19 Efl.Ui.Position_Manager.Data_Access_V1.data_access {set;}
20 Efl.Object.finalize;
20 } 21 }
21} 22}