summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-25 20:17:53 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commita26fd313567f52d72f2418e96ae8fc8d3f0d8c4e (patch)
tree62e524e2e0d25f18957231b600388fbb63a46d1b
parentb278a69711d0b02c60f6955c33cdd1fb072115bf (diff)
elm: update list size in size_hint item
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c87
1 files changed, 50 insertions, 37 deletions
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 13aee83afd..e36e851346 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -33,12 +33,27 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Size
33 double weight_x, weight_y; 33 double weight_x, weight_y;
34} Efl_Ui_List_Precise_Layouter_Size; 34} Efl_Ui_List_Precise_Layouter_Size;
35 35
36
37typedef struct _Efl_Ui_List_Precise_Layouter_Callback_Data
38{
39 Efl_Ui_List_Precise_Layouter_Data* pd;
40 Efl_Ui_List_Precise_Layouter_Size* size;
41} Efl_Ui_List_Precise_Layouter_Callback_Data;
42
36#include "efl_ui_list_precise_layouter.eo.h" 43#include "efl_ui_list_precise_layouter.eo.h"
37 44
38 45
39static void 46static void
40_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Precise_Layouter_Size *size, Evas_Coord new_w, Evas_Coord new_h) 47_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_Ui_List_Precise_Layouter_Size *size, Eina_Size2D min)
41{ 48{
49 int pad[4];
50 efl_gfx_size_hint_margin_get(layout, &pad[0], &pad[1], &pad[2], &pad[3]);
51 efl_gfx_size_hint_weight_get(layout, &size->weight_x, &size->weight_y);
52
53 min.w += pad[0] + pad[1];
54 min.h += pad[2] + pad[3];
55
56// DBG("size information for item %d width %d height %d", i, size->min.w, size->min.h);
42// if(_horiz(pd->orient)) 57// if(_horiz(pd->orient))
43// { 58// {
44// pdp->realized.w -= item->minw; 59// pdp->realized.w -= item->minw;
@@ -63,29 +78,29 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Precise_Layout
63// else 78// else
64// { 79// {
65 80
66 pd->min.h += new_h - size->min.h; 81 pd->min.h += min.h - size->min.h;
67 82
68 if(pd->min.w <= new_w) 83 if(pd->min.w <= min.w)
69 pd->min.w = new_w; 84 pd->min.w = min.w;
70 else if (pd->min.w == size->min.w) 85 else if (pd->min.w == size->min.w)
71 { 86 {
72 pd->min.w = new_w; 87 pd->min.w = min.w;
73 /*EINA_INARRAY_FOREACH(&pd->items.array, it) //find new minimal width 88 /*EINA_INARRAY_FOREACH(&pd->items.array, it) //find new minimal width
74 { 89 {
75 litem = *it; 90 litem = *it;
76 if (!litem) continue; 91 if (!litem) continue;
77 if (pd->realized.w < litem->minw) 92 if (pd->realized.w < litem->minw)
78 pd->realized.w = litem->minw; 93 pd->realized.w = litem->minw;
79 94
80 if (litem != item && litem->minw == item->minw) 95 if (litem != item && litem->minw == item->minw)
81 break; 96 break;
82 } 97 }
83 */ 98 */
84 } 99 }
85// } 100// }
86 101
87 size->min.w = new_w; 102 size->min.w = min.w;
88 size->min.h = new_h; 103 size->min.h = min.h;
89} 104}
90 105
91static void 106static void
@@ -106,6 +121,15 @@ _count_error(void * data, Efl_Event const* event EINA_UNUSED)
106 pd->count_future = NULL; 121 pd->count_future = NULL;
107} 122}
108 123
124static void
125_on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
126 Evas_Object *obj, void *event_info EINA_UNUSED)
127{
128 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = data;
129 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(obj);
130 _item_min_calc(cb_data->pd, obj, cb_data->size, min);
131}
132
109EOLIAN static Efl_Object * 133EOLIAN static Efl_Object *
110_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd) 134_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
111{ 135{
@@ -159,7 +183,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
159 int boxl = 0, boxr = 0, boxt = 0, boxb = 0; 183 int boxl = 0, boxr = 0, boxt = 0, boxb = 0;
160 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 }; 184 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 };
161 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE }; 185 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
162 int pad[4];
163 186
164 DBG("layout_do first %d count %d", first, count); 187 DBG("layout_do first %d count %d", first, count);
165 EINA_SAFETY_ON_NULL_RETURN(items); 188 EINA_SAFETY_ON_NULL_RETURN(items);
@@ -196,25 +219,15 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
196 219
197 size = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size)); 220 size = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size));
198 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(layout_item->layout); 221 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(layout_item->layout);
199 //edje_object_size_min_calc(layout_item->layout, &size->min.w, &size->min.h); 222 if(min.w && min.h)
200 size->min.w = min.w;
201 size->min.h = min.h;
202
203 if(size->min.w && size->min.h)
204 { 223 {
205// DBG("size was calculated"); 224// DBG("size was calculated");
206 efl_gfx_size_hint_margin_get(layout_item->layout, &pad[0], &pad[1], &pad[2], &pad[3]); 225 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data));
207 efl_gfx_size_hint_weight_get(layout_item->layout, &size->weight_x, &size->weight_y); 226 _item_min_calc(pd, layout_item->layout, size, min);
208
209 size->min.w += pad[0] + pad[1];
210 size->min.h += pad[2] + pad[3];
211 pd->min.h += size->min.h;
212
213 if (pd->min.w < size->min.w)
214 pd->min.w = size->min.w;
215
216 eina_hash_add(pd->size_information, &layout_item, size); 227 eina_hash_add(pd->size_information, &layout_item, size);
217// DBG("size information for item %d width %d height %d", i, size->min.w, size->min.h); 228 cb_data->pd = pd;
229 cb_data->size = size;
230 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
218 } 231 }
219 else 232 else
220 { 233 {