summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2016-03-28 15:54:28 +0300
committerYakov Goldberg <yakov.g@samsung.com>2016-03-29 14:55:52 +0300
commitdf410cd20ae858bbfb4e4b02faa8cb8790c863b2 (patch)
treedf6514c4ff2c3a82e8f3d4d84293912ef43aad83
parent9816aa90338c1d99d2b1b923fa0418ef97e4a471 (diff)
Redesing view update
The problem is: when object is re-created, rendering occurs during following iterations. Thus properties values can pe properly fetched after.
-rw-r--r--src/bin/gui/editor.c1
-rw-r--r--src/lib/updater.c279
2 files changed, 159 insertions, 121 deletions
diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 0fd29f8..7379ca7 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -3688,6 +3688,7 @@ _drop_property_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
3688 } 3688 }
3689 } 3689 }
3690 elm_obj_ctxpopup_dismiss(obj); 3690 elm_obj_ctxpopup_dismiss(obj);
3691 update_from_undo_redo = EINA_TRUE;
3691 context_memento_finalize(ctx); 3692 context_memento_finalize(ctx);
3692} 3693}
3693 3694
diff --git a/src/lib/updater.c b/src/lib/updater.c
index f60f2be..714dea7 100644
--- a/src/lib/updater.c
+++ b/src/lib/updater.c
@@ -91,6 +91,17 @@ updater_completion_callback_add(Updater_Completion_Cb cb, void *data)
91 _completion_cbs = eina_list_append(_completion_cbs, info); 91 _completion_cbs = eina_list_append(_completion_cbs, info);
92} 92}
93 93
94static Eina_Bool _resize_cb_added = EINA_FALSE;
95static Eina_Bool _resize_cb_called = EINA_FALSE;
96
97static Eina_Bool
98_resized_cb(void *data EINA_UNUSED, const Eo_Event *event)
99{
100 eo_event_callback_del(event->obj, EVAS_OBJECT_EVENT_RESIZE, _resized_cb, NULL);
101 _resize_cb_called = EINA_TRUE;
102 return EINA_TRUE;
103}
104
94static void 105static void
95_eo_add_apply(const Eina_List *sessions, Eid *eid) 106_eo_add_apply(const Eina_List *sessions, Eid *eid)
96{ 107{
@@ -101,6 +112,9 @@ _eo_add_apply(const Eina_List *sessions, Eid *eid)
101 { 112 {
102 if (session_eo_get(s, wdg)) continue; 113 if (session_eo_get(s, wdg)) continue;
103 manager_widget_create(s, wdg, NULL); 114 manager_widget_create(s, wdg, NULL);
115 _resize_cb_added = EINA_TRUE;
116 _resize_cb_called = EINA_FALSE;
117 eo_event_callback_add(session_eo_get(s, wdg), EVAS_OBJECT_EVENT_RESIZE, _resized_cb, NULL);
104 } 118 }
105} 119}
106 120
@@ -159,154 +173,177 @@ static Eina_Bool
159_update_check(void *data EINA_UNUSED) 173_update_check(void *data EINA_UNUSED)
160{ 174{
161 Gui_Context *ctx; 175 Gui_Context *ctx;
162 if (!_ctxs_to_update) return EINA_TRUE; 176 static Memento *mem_last;
163 EINA_LIST_FREE(_ctxs_to_update, ctx) 177 static Eina_Bool mem_dir_last;
178 static Eina_Bool odd_call = EINA_TRUE;
179
180 if (odd_call)
164 { 181 {
165 Eina_List *sessions = gui_context_data_get(ctx, SESSIONS_DATA_KEY); 182 if (!_ctxs_to_update) return EINA_TRUE;
166 Eina_Bool mem_dir = EINA_TRUE; 183 odd_call = EINA_FALSE;
167 Eina_List *mementos = context_memento_not_updated_list_steal(ctx, &mem_dir); 184
168 if (mementos) 185 if (eina_list_count(_ctxs_to_update) != 1)
169 { 186 {
170 Eina_List *itr2; 187 ERR("More then 1 contexts to update. Re-think design!");
171 Memento *mem; 188 }
172 Completion_Info *info; 189
173 EINA_LIST_FREE(mementos, mem) 190 EINA_LIST_FREE(_ctxs_to_update, ctx)
191 {
192 Eina_List *sessions = gui_context_data_get(ctx, SESSIONS_DATA_KEY);
193 Eina_Bool mem_dir = EINA_TRUE;
194 Eina_List *mementos = context_memento_not_updated_list_steal(ctx, &mem_dir);
195 if (mementos)
174 { 196 {
175 const Eina_List *itr, *commands; 197 Memento *mem;
176 Memento_Command *cmd; 198 EINA_LIST_FREE(mementos, mem)
199 {
200 const Eina_List *itr, *commands;
201 Memento_Command *cmd;
177 202
178 commands = memento_commands_get(mem); 203 commands = memento_commands_get(mem);
179 itr = mem_dir ? commands : eina_list_last(commands); 204 itr = mem_dir ? commands : eina_list_last(commands);
180 205
181 /* According to direction we must iterate forward/backward through commands. 206 /* According to direction we must iterate forward/backward through commands.
182 * Following for loop is opened EINA_LIST_FOREACH and EINA_LIST_REVERSE_FOREACH */ 207 * Following for loop is opened EINA_LIST_FOREACH and EINA_LIST_REVERSE_FOREACH */
183 for (cmd = eina_list_data_get(itr); 208 for (cmd = eina_list_data_get(itr);
184 itr; 209 itr;
185 itr = (mem_dir ? eina_list_next(itr) : eina_list_prev(itr)), 210 itr = (mem_dir ? eina_list_next(itr) : eina_list_prev(itr)),
186 cmd = eina_list_data_get(itr)) 211 cmd = eina_list_data_get(itr))
187 {
188 Eid *eid = memento_command_wdg_get(cmd);
189 Gui_Widget *wdg = wdg_get(eid);
190 Memento_Type type = memento_command_type_get(cmd);
191 void *from, *to;
192 if (mem_dir)
193 {
194 from = memento_command_old_pointer_get(cmd);
195 to = memento_command_new_pointer_get(cmd);
196 }
197 else
198 {
199 from = memento_command_new_pointer_get(cmd);
200 to = memento_command_old_pointer_get(cmd);
201 }
202 updater_debug("Updating %s on %s: %p -> %p",
203 memento_type_get_as_string(type),
204 eid_name_get_internal(eid), from, to);
205 switch(type)
206 { 212 {
207 case MEMENTO_WIDGET: 213 Eid *eid = memento_command_wdg_get(cmd);
208 { 214 Gui_Widget *wdg = wdg_get(eid);
209 if (from) 215 Memento_Type type = memento_command_type_get(cmd);
216 void *from, *to;
217 if (mem_dir)
218 {
219 from = memento_command_old_pointer_get(cmd);
220 to = memento_command_new_pointer_get(cmd);
221 }
222 else
223 {
224 from = memento_command_new_pointer_get(cmd);
225 to = memento_command_old_pointer_get(cmd);
226 }
227 updater_debug("Updating %s on %s: %p -> %p",
228 memento_type_get_as_string(type),
229 eid_name_get_internal(eid), from, to);
230 switch(type)
231 {
232 case MEMENTO_WIDGET:
210 { 233 {
211 eid_active_set(eid, EINA_TRUE); 234 if (from)
212 _eo_del_apply(sessions, eid); 235 {
213 eid_active_set(eid, EINA_FALSE); 236 eid_active_set(eid, EINA_TRUE);
237 _eo_del_apply(sessions, eid);
238 eid_active_set(eid, EINA_FALSE);
239 }
240 else
241 {
242 _eo_add_apply(sessions, eid);
243 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
244 if (parent_container_id) _container_update(sessions, parent_container_id);
245 }
246 break;
214 } 247 }
215 else 248 case MEMENTO_PROPERTY:
216 { 249 {
217 _eo_add_apply(sessions, eid); 250 /* When setting File property for layout, need to re-create object and reconfigure.
218 Eid *parent_container_id = wdg_parent_container_eid_get(wdg); 251 * Because dummy objects probably were not created. */
219 if (parent_container_id) _container_update(sessions, parent_container_id); 252 if (IS_LAYOUT(wdg) && !strcmp(prop_name_get(to ? to : from), FILE_SET))
253 {
254 _eo_del_apply(sessions, eid);
255 _eo_add_apply(sessions, eid);
256 /* Here separate algorithm for each kind of container can be implemented. */
257 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
258 if (parent_container_id) _container_update(sessions, parent_container_id);
259 }
260 else if (to)
261 {
262 _eo_prop_apply(sessions, eid, to);
263 }
264 else
265 {
266 _eo_del_apply(sessions, eid);
267 _eo_add_apply(sessions, eid);
268 /* Here separate algorithm for each kind of container can be implemented. */
269 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
270 if (parent_container_id) _container_update(sessions, parent_container_id);
271 }
272 break;
220 } 273 }
221 break; 274 case MEMENTO_OBJ_CONTAINER:
222 }
223 case MEMENTO_PROPERTY:
224 {
225 /* When setting File property for layout, need to re-create object and reconfigure.
226 * Because dummy objects probably were not created. */
227 if (IS_LAYOUT(wdg) && !strcmp(prop_name_get(to ? to : from), FILE_SET))
228 {
229 _eo_del_apply(sessions, eid);
230 _eo_add_apply(sessions, eid);
231 /* Here separate algorithm for each kind of container can be implemented. */
232 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
233 if (parent_container_id) _container_update(sessions, parent_container_id);
234 }
235 else if (to)
236 { 275 {
237 _eo_prop_apply(sessions, eid, to); 276 _container_update(sessions, eid);
277 break;
238 } 278 }
239 else 279 case MEMENTO_WIDGET_PARENT:
240 { 280 {
241 _eo_del_apply(sessions, eid); 281 _eo_del_apply(sessions, eid);
242 _eo_add_apply(sessions, eid); 282 _eo_add_apply(sessions, eid);
243 /* Here separate algorithm for each kind of container can be implemented. */ 283 break;
244 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
245 if (parent_container_id) _container_update(sessions, parent_container_id);
246 }
247 break;
248 }
249 case MEMENTO_OBJ_CONTAINER:
250 {
251 _container_update(sessions, eid);
252 break;
253 }
254 case MEMENTO_WIDGET_PARENT:
255 {
256 _eo_del_apply(sessions, eid);
257 _eo_add_apply(sessions, eid);
258 break;
259 }
260 case MEMENTO_ITEM_CONTAINER_ITEM:
261 {
262 if (strstr(wdg_name_get(wdg), "main_menu"))
263 {
264 Eid *parent_eid = wdg_parent_id_get(wdg);
265 _eo_del_apply(sessions, parent_eid);
266 _eo_add_apply(sessions, parent_eid);
267 } 284 }
268 else 285 case MEMENTO_ITEM_CONTAINER_ITEM:
269 { 286 {
270 _eo_del_apply(sessions, eid); 287 if (strstr(wdg_name_get(wdg), "main_menu"))
271 _eo_add_apply(sessions, eid); 288 {
272 /* Here separate algorithm for each kind of container can be implemented. */ 289 Eid *parent_eid = wdg_parent_id_get(wdg);
273 Eid *parent_container_id = wdg_parent_container_eid_get(wdg); 290 _eo_del_apply(sessions, parent_eid);
274 if (parent_container_id) _container_update(sessions, parent_container_id); 291 _eo_add_apply(sessions, parent_eid);
292 }
293 else
294 {
295 _eo_del_apply(sessions, eid);
296 _eo_add_apply(sessions, eid);
297 /* Here separate algorithm for each kind of container can be implemented. */
298 Eid *parent_container_id = wdg_parent_container_eid_get(wdg);
299 if (parent_container_id) _container_update(sessions, parent_container_id);
300 }
301 break;
275 } 302 }
303 case MEMENTO_ACTION:
304 case MEMENTO_CALLBACK:
305 case MEMENTO_CALLBACK_ADD_DEL:
306 case MEMENTO_WIDGET_NAME:
307 case MEMENTO_WIDGET_PUBLIC:
308 default:
309 printf("%s - Apply %d\n", __FUNCTION__, type);
276 break; 310 break;
277 } 311 }
278 case MEMENTO_ACTION:
279 case MEMENTO_CALLBACK:
280 case MEMENTO_CALLBACK_ADD_DEL:
281 case MEMENTO_WIDGET_NAME:
282 case MEMENTO_WIDGET_PUBLIC:
283 default:
284 printf("%s - Apply %d\n", __FUNCTION__, type);
285 break;
286 } 312 }
313 mem_last = mem;
314 mem_dir_last = mem_dir;
287 } 315 }
288 EINA_LIST_FOREACH(_completion_cbs, itr2, info) 316 }
317 Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, CONTEXT_FORCE_WDGS_KEY);
318 Force_Info *info;
319 EINA_LIST_FREE(forced_wdgs_infos, info)
320 {
321 switch(info->type)
289 { 322 {
290 info->cb(info->data, mem, mem_dir); 323 case UPDATER_PROPERTIES_FORCE:
324 {
325 _container_update(sessions, info->eid);
326 break;
327 }
328 default: break;
291 } 329 }
330 free(info);
292 } 331 }
332 gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, NULL);
293 } 333 }
294 Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, CONTEXT_FORCE_WDGS_KEY); 334 }
295 Force_Info *info; 335 else
296 EINA_LIST_FREE(forced_wdgs_infos, info) 336 {
337 if (!_resize_cb_added || (_resize_cb_added && _resize_cb_called) )
297 { 338 {
298 switch(info->type) 339 Eina_List *itr2;
340 Completion_Info *info;
341 EINA_LIST_FOREACH(_completion_cbs, itr2, info)
299 { 342 {
300 case UPDATER_PROPERTIES_FORCE: 343 info->cb(info->data, mem_last, mem_dir_last);
301 {
302 _container_update(sessions, info->eid);
303 break;
304 }
305 default: break;
306 } 344 }
307 free(info); 345 odd_call = EINA_TRUE;
308 } 346 }
309 gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, NULL);
310 } 347 }
311 return EINA_TRUE; 348 return EINA_TRUE;
312} 349}
@@ -315,7 +352,7 @@ Eina_Bool
315updater_init() 352updater_init()
316{ 353{
317 if (_init_counter++) return EINA_TRUE; 354 if (_init_counter++) return EINA_TRUE;
318 _idler = ecore_idle_exiter_add(_update_check, NULL); 355 _idler = ecore_idle_enterer_add(_update_check, NULL);
319 return EINA_TRUE; 356 return EINA_TRUE;
320} 357}
321 358
@@ -324,7 +361,7 @@ updater_shutdown()
324{ 361{
325 if (--_init_counter) 362 if (--_init_counter)
326 { 363 {
327 ecore_idle_exiter_del(_idler); 364 ecore_idle_enterer_del(_idler);
328 _idler = NULL; 365 _idler = NULL;
329 } 366 }
330} 367}