summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-30 15:20:52 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-10-02 15:59:32 +0300
commite41358b39bd1b7889ebe1f6d9b9c325cc31782da (patch)
treea75b29c363abff4aa1c1eed147233f9df4d6fbdd
parent06247875a2651d59f0b70e20dec27eedaa257a8f (diff)
Main Widgets: non win main widgets need a win.
The problem occurs when a button is added to main box. This button is not inside the box but at the top left corner of the window. To solve this problem, we need to create a window that will give a reference to the children. It means that the editor has to create an inline window, the widget inside this window, take the inline object and set it as content of the frame.
-rw-r--r--src/bin/egui_gui/editor.c80
1 files changed, 44 insertions, 36 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index d089d54..66c8a71 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -398,6 +398,7 @@ _iter_widget_delete(Gui_Widget *wdg)
398{ 398{
399 Eina_List *children = NULL, *l, *l2; 399 Eina_List *children = NULL, *l, *l2;
400 Dep_Id *wid; 400 Dep_Id *wid;
401 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(_active_context_get());
401 402
402 children = wdg_children_list_get(wdg); 403 children = wdg_children_list_get(wdg);
403 EINA_LIST_FOREACH_SAFE(children, l, l2, wid) 404 EINA_LIST_FOREACH_SAFE(children, l, l2, wid)
@@ -407,7 +408,7 @@ _iter_widget_delete(Gui_Widget *wdg)
407 } 408 }
408 409
409 /* If widget is Win, look for its frame and unset content, but don't delete frame. */ 410 /* If widget is Win, look for its frame and unset content, but don't delete frame. */
410 Eo *win_inlined_image = NULL; 411 Eo *win_inlined_image = NULL, *optional_win = NULL;
411 /* Each time we iterate over widgets in order to delete them, we set window's frame invisible. 412 /* Each time we iterate over widgets in order to delete them, we set window's frame invisible.
412 * DUring creation it will be visible again. Frame deleted only when project is closed. */ 413 * DUring creation it will be visible again. Frame deleted only when project is closed. */
413 if (IS_MAIN(wdg)) 414 if (IS_MAIN(wdg))
@@ -415,6 +416,11 @@ _iter_widget_delete(Gui_Widget *wdg)
415 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO); 416 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
416 if (wi) 417 if (wi)
417 { 418 {
419 if (!IS_WIN(wdg))
420 {
421 Eo *o = session_eo_get(session, wdg);
422 optional_win = eo_do(o, eo_key_data_get("__editor_win"));
423 }
418 Eo *fr = main_wdg_info_frame_get(wi); 424 Eo *fr = main_wdg_info_frame_get(wi);
419 if (fr) 425 if (fr)
420 { 426 {
@@ -423,11 +429,12 @@ _iter_widget_delete(Gui_Widget *wdg)
423 } 429 }
424 } 430 }
425 } 431 }
426 manager_widget_delete((Gui_Session *) gui_context_editor_session_get(_active_context_get()), wdg, MODE_EDITOR, NULL); 432 manager_widget_delete(session, wdg, MODE_EDITOR, NULL);
427 433
428 /* Delete window's inline image */ 434 /* Delete window's inline image */
429 if (win_inlined_image) 435 if (win_inlined_image)
430 { 436 {
437 eo_del(optional_win);
431 eo_del(win_inlined_image); 438 eo_del(win_inlined_image);
432 } 439 }
433} 440}
@@ -848,7 +855,7 @@ _win_resize(void *data EINA_UNUSED, Eo *o, const Eo_Event_Description *desc EINA
848 /* FIXME: comment it? */ 855 /* FIXME: comment it? */
849 eo_do(inwin_img, evas_obj_size_set(ow, oh)); 856 eo_do(inwin_img, evas_obj_size_set(ow, oh));
850 } 857 }
851 eo_do(o, fr = eo_key_data_get("frame")); 858 eo_do(o, fr = eo_key_data_get("__editor_frame"));
852 859
853 intptr_t dw, dh; 860 intptr_t dw, dh;
854 eo_do(fr, dw = (intptr_t) eo_key_data_get("dw")); 861 eo_do(fr, dw = (intptr_t) eo_key_data_get("dw"));
@@ -863,18 +870,22 @@ _widget_prop_add(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widget_P
863{ 870{
864 Eina_Bool ret = _ffi_eo_do(session, wdg, prop); 871 Eina_Bool ret = _ffi_eo_do(session, wdg, prop);
865 872
866 if (IS_MAIN(wdg) && IS_WIN(wdg)) 873 if (IS_MAIN(wdg))
867 { 874 {
868 Eo *fr = NULL, *o = session_eo_get(session, wdg); 875 Eo *o = session_eo_get(session, wdg), *win = NULL, *fr = NULL;
869 eo_do(o, fr = eo_key_data_get("frame")); 876 if (!IS_WIN(wdg))
870 877 {
871 if (!strcmp(prop_name_get(prop), TITLE_SET)) 878 win = eo_do(o, eo_key_data_get("__editor_win"));
879 fr = eo_do(win, eo_key_data_get("__editor_frame"));
880 }
881 else fr = eo_do(o, eo_key_data_get("__editor_frame"));
882 if (IS_WIN(wdg) && !strcmp(prop_name_get(prop), TITLE_SET))
872 { 883 {
873 Gui_Value *v = prop_value_nth_get(wdg_prop_get(wdg, DB_DEF_WIN_CLASS, TITLE_SET), 0); 884 Gui_Value *v = prop_value_nth_get(wdg_prop_get(wdg, DB_DEF_WIN_CLASS, TITLE_SET), 0);
874 const char *title = STRING_GET(v); 885 const char *title = STRING_GET(v);
875 eo_do(fr, elm_obj_widget_part_text_set(NULL, title)); 886 eo_do(fr, elm_obj_widget_part_text_set(NULL, title));
876 } 887 }
877 else if (!strcmp(prop_name_get(prop), VISIBILITY_SET)) 888 if (!strcmp(prop_name_get(prop), VISIBILITY_SET))
878 { 889 {
879 Eina_Bool visibility; 890 Eina_Bool visibility;
880 eo_do(o, visibility = evas_obj_visibility_get()); 891 eo_do(o, visibility = evas_obj_visibility_get());
@@ -882,6 +893,7 @@ _widget_prop_add(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widget_P
882 /* Always show windows in editor. This made for the case, when eo_do call 893 /* Always show windows in editor. This made for the case, when eo_do call
883 * is going on file load*/ 894 * is going on file load*/
884 eo_do(o, evas_obj_visibility_set(EINA_TRUE)); 895 eo_do(o, evas_obj_visibility_set(EINA_TRUE));
896 if (win) eo_do(win, evas_obj_visibility_set(EINA_TRUE));
885 eo_do(fr, evas_obj_visibility_set(EINA_TRUE)); 897 eo_do(fr, evas_obj_visibility_set(EINA_TRUE));
886 } 898 }
887 } 899 }
@@ -967,10 +979,9 @@ _widget_del(Gui_Session *session, const Gui_Widget *wdg, void *data EINA_UNUSED)
967static Eina_Bool 979static Eina_Bool
968_widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data) 980_widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
969{ 981{
970 Eo *o;
971 if (!IS_MAIN(wdg)) 982 if (!IS_MAIN(wdg))
972 { 983 {
973 o = _ffi_eo_add(session, wdg, NULL); 984 Eo *o = _ffi_eo_add(session, wdg, NULL);
974 if (!o) return EINA_FALSE; 985 if (!o) return EINA_FALSE;
975 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg)); 986 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg));
976 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, wdg_context_get(wdg)); 987 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, wdg_context_get(wdg));
@@ -985,32 +996,30 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
985#endif 996#endif
986 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, NULL)); 997 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, NULL));
987 /* Add specific callbacks, related to UI. */ 998 /* Add specific callbacks, related to UI. */
999 session_eo_set(session, wdg, o);
988 } 1000 }
989 else 1001 else
990 { 1002 {
991 Eo *fr; 1003 Eo *fr;
992 Eo *parent_win = data; 1004 Eo *parent_win = data;
993 /* 1005
994 if (!parent_win) 1006 Eo *win = eo_add(ELM_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, ELM_WIN_INLINED_IMAGE));
1007 if (!win) return EINA_FALSE;
1008 if (!IS_WIN(wdg))
995 { 1009 {
996 parent_win = wdg_eo_get(wdg_parent_get(wdg)); 1010 Eo *o = _ffi_eo_add(session, wdg, win);
1011 if (!o) return EINA_FALSE;
1012 eo_do(win, elm_obj_win_resize_object_add(o));
1013 eo_do(o, eo_key_data_set("__editor_win", win, NULL));
1014 session_eo_set(session, wdg, o);
997 } 1015 }
998 */
999
1000 Eo *io = NULL;
1001 if (IS_WIN(wdg))
1002 o = eo_add(ELM_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, ELM_WIN_INLINED_IMAGE));
1003 else 1016 else
1004 o = _ffi_eo_add(session, wdg, parent_win);
1005
1006 if (!o) return EINA_FALSE;
1007
1008 if (IS_WIN(wdg))
1009 { 1017 {
1010 io = elm_win_inlined_image_object_get(o); 1018 session_eo_set(session, wdg, win);
1011 eo_do(io, evas_obj_propagate_events_set(EINA_FALSE));
1012 } 1019 }
1013 else io = o; 1020
1021 Eo *iwin = elm_win_inlined_image_object_get(win);
1022 eo_do(iwin, evas_obj_propagate_events_set(EINA_FALSE));
1014 1023
1015 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO); 1024 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
1016 1025
@@ -1038,7 +1047,7 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1038 //evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 1047 //evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1039 const char *fr_title = wdg_name_get(wdg); 1048 const char *fr_title = wdg_name_get(wdg);
1040 if (IS_WIN(wdg)) 1049 if (IS_WIN(wdg))
1041 fr_title = elm_win_title_get(o); 1050 fr_title = elm_win_title_get(win);
1042 1051
1043 elm_object_text_set(fr, fr_title); 1052 elm_object_text_set(fr, fr_title);
1044 eo_do(fr, 1053 eo_do(fr,
@@ -1051,14 +1060,14 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1051 } 1060 }
1052 fr = main_wdg_info_frame_get(wi); 1061 fr = main_wdg_info_frame_get(wi);
1053 eo_do(fr, evas_obj_visibility_set(EINA_TRUE)); 1062 eo_do(fr, evas_obj_visibility_set(EINA_TRUE));
1054 eo_do(o, eo_key_data_set("frame", fr, NULL)); 1063 eo_do(win, eo_key_data_set("__editor_frame", fr, NULL));
1055 elm_object_content_set(fr, io); 1064 elm_object_content_set(fr, iwin);
1056 1065
1057 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _win_resize, NULL)); 1066 eo_do(win, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _win_resize, NULL));
1058 /* Get size from properties of window. */ 1067 /* Get size from properties of window. */
1059 Evas_Coord ox = 150, oy = 50; 1068 Evas_Coord ox = 150, oy = 50;
1060 eo_do(fr, evas_obj_position_get(&ox, &oy)); 1069 eo_do(fr, evas_obj_position_get(&ox, &oy));
1061 eo_do(io, evas_obj_position_set(ox, oy)); 1070 eo_do(iwin, evas_obj_position_set(ox, oy));
1062 1071
1063 { 1072 {
1064 /* When set image as content to frame, image is smaller then frame. 1073 /* When set image as content to frame, image is smaller then frame.
@@ -1070,10 +1079,10 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1070 Evas_Coord im_w, im_h; 1079 Evas_Coord im_w, im_h;
1071 Evas_Coord ow = 50, oh = 50; 1080 Evas_Coord ow = 50, oh = 50;
1072 /* Set desired size.*/ 1081 /* Set desired size.*/
1073 eo_do(io, evas_obj_size_set(ow, oh)); 1082 eo_do(iwin, evas_obj_size_set(ow, oh));
1074 eo_do(fr, evas_obj_size_set(ow, oh)); 1083 eo_do(fr, evas_obj_size_set(ow, oh));
1075 /* Get size of image (which is smaller, because frame is 50, 50)*/ 1084 /* Get size of image (which is smaller, because frame is 50, 50)*/
1076 eo_do(io, evas_obj_size_get(&im_w, &im_h)); 1085 eo_do(iwin, evas_obj_size_get(&im_w, &im_h));
1077 /* Calculate deltas*/ 1086 /* Calculate deltas*/
1078 dw = ow - im_w; 1087 dw = ow - im_w;
1079 dh = oh - im_h; 1088 dh = oh - im_h;
@@ -1082,11 +1091,10 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1082 eo_do(fr, eo_key_data_set("dh", (void *) (intptr_t) dh, NULL)); 1091 eo_do(fr, eo_key_data_set("dh", (void *) (intptr_t) dh, NULL));
1083 /* Resize properly. */ 1092 /* Resize properly. */
1084 eo_do(fr, evas_obj_size_set(ow + dw, oh + dh)); 1093 eo_do(fr, evas_obj_size_set(ow + dw, oh + dh));
1085 eo_do(io, evas_obj_size_set(ow, oh)); 1094 eo_do(iwin, evas_obj_size_set(ow, oh));
1086 } 1095 }
1087 } 1096 }
1088 1097
1089 session_eo_set(session, wdg, o);
1090 return EINA_TRUE; 1098 return EINA_TRUE;
1091} 1099}
1092 1100