summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-03 10:21:28 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-10 10:08:09 +0200
commit750dd34ae89fced237daf5ecb8ad8aa62a6b3f65 (patch)
treefb691f10561331df0183a7c1b568f8b7ee428b19
parent18d86cd803558831b419a00cac6c2de7584e1470 (diff)
random list fixes
-rw-r--r--src/lib/elementary/efl_ui_position_manager_list.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/elementary/efl_ui_position_manager_list.c b/src/lib/elementary/efl_ui_position_manager_list.c
index 5a159f308c..5d82cb9a1e 100644
--- a/src/lib/elementary/efl_ui_position_manager_list.c
+++ b/src/lib/elementary/efl_ui_position_manager_list.c
@@ -37,6 +37,14 @@ typedef struct {
37 */ 37 */
38 38
39static void 39static void
40cache_invalidate(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd)
41{
42 if (pd->size_cache)
43 free(pd->size_cache);
44 pd->size_cache = NULL;
45}
46
47static void
40cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd) 48cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd)
41{ 49{
42 unsigned int i; 50 unsigned int i;
@@ -82,19 +90,15 @@ cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd)
82 } 90 }
83 pd->size_cache[i + 1] = pd->size_cache[i] + step; 91 pd->size_cache[i + 1] = pd->size_cache[i] + step;
84 pd->maximum_min_size = MAX(pd->maximum_min_size, min); 92 pd->maximum_min_size = MAX(pd->maximum_min_size, min);
93 /* no point iterating further if size calc can't be done yet */
94 //if ((!i) && (!pd->maximum_min_size)) break;
85 } 95 }
86 pd->average_item_size = pd->size_cache[pd->size]/pd->size; 96 pd->average_item_size = pd->size_cache[pd->size]/pd->size;
97 if ((!pd->average_item_size) && (!pd->maximum_min_size))
98 cache_invalidate(obj, pd);
87} 99}
88 100
89static void 101static int
90cache_invalidate(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd)
91{
92 if (pd->size_cache)
93 free(pd->size_cache);
94 pd->size_cache = NULL;
95}
96
97static inline int
98cache_access(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int idx) 102cache_access(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int idx)
99{ 103{
100 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx <= pd->size, 0); 104 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx <= pd->size, 0);
@@ -105,7 +109,12 @@ static void
105recalc_absolut_size(Eo *obj, Efl_Ui_Position_Manager_List_Data *pd) 109recalc_absolut_size(Eo *obj, Efl_Ui_Position_Manager_List_Data *pd)
106{ 110{
107 Eina_Size2D min_size = EINA_SIZE2D(-1, -1); 111 Eina_Size2D min_size = EINA_SIZE2D(-1, -1);
112 Eina_Size2D pabs_size = pd->abs_size;
113 int pmin_size = pd->maximum_min_size;
114
108 cache_require(obj, pd); 115 cache_require(obj, pd);
116 /* deferred */
117 if (!pd->size_cache) return;
109 118
110 pd->abs_size = pd->viewport.size; 119 pd->abs_size = pd->viewport.size;
111 120
@@ -116,8 +125,8 @@ recalc_absolut_size(Eo *obj, Efl_Ui_Position_Manager_List_Data *pd)
116 else 125 else
117 pd->abs_size.w = MAX(cache_access(obj, pd, pd->size), pd->abs_size.w); 126 pd->abs_size.w = MAX(cache_access(obj, pd, pd->size), pd->abs_size.w);
118 } 127 }
119 128 if ((pabs_size.w != pd->abs_size.w) || (pabs_size.h != pd->abs_size.h))
120 efl_event_callback_call(obj, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_CONTENT_SIZE_CHANGED, &pd->abs_size); 129 efl_event_callback_call(obj, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_CONTENT_SIZE_CHANGED, &pd->abs_size);
121 130
122 if (pd->dir == EFL_UI_LAYOUT_ORIENTATION_VERTICAL) 131 if (pd->dir == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
123 { 132 {
@@ -127,8 +136,8 @@ recalc_absolut_size(Eo *obj, Efl_Ui_Position_Manager_List_Data *pd)
127 { 136 {
128 min_size.h = pd->maximum_min_size; 137 min_size.h = pd->maximum_min_size;
129 } 138 }
130 139 if ((pd->maximum_min_size > 0) && (pmin_size > 0) && (pd->maximum_min_size != pmin_size))
131 efl_event_callback_call(obj, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_CONTENT_MIN_SIZE_CHANGED, &min_size); 140 efl_event_callback_call(obj, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_CONTENT_MIN_SIZE_CHANGED, &min_size);
132} 141}
133 142
134static inline Vis_Segment 143static inline Vis_Segment