summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/egui_gui/editor.c71
-rw-r--r--src/bin/egui_gui/egui_layout.json35
-rw-r--r--src/bin/egui_gui/egui_logic.c19
-rw-r--r--src/lib/gui_widget.c13
-rw-r--r--src/lib/gui_widget.h3
5 files changed, 131 insertions, 10 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index dadc288..91be943 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -2623,6 +2623,42 @@ _widget_selected_from_objtree(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
2623} 2623}
2624 2624
2625static void 2625static void
2626_context_main_widgets_visibility_set(Gui_Context *ctx, Eina_Bool visible)
2627{
2628 Eina_List *widgets = gui_context_main_widgets_get(ctx);
2629 Eina_List *l = NULL;
2630 Dep_Id *wdg_id;
2631
2632 EINA_LIST_FOREACH(widgets, l, wdg_id)
2633 {
2634 Gui_Widget *wdg = wdg_get(wdg_id);
2635 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2636 Eo *fr = main_wdg_info_frame_get(wi);
2637 eo_do(fr, evas_obj_visibility_set(visible));
2638 }
2639}
2640
2641static void
2642_switch_to_context(Gui_Context *ctx)
2643{
2644 Gui_Context *prev_ctx = _active_context_get();
2645 if (prev_ctx)
2646 {
2647 _context_main_widgets_visibility_set(prev_ctx, EINA_FALSE);
2648 }
2649
2650 _context_main_widgets_visibility_set(ctx, EINA_TRUE);
2651
2652 _active_context_set(ctx);
2653 objtree_context_set(ctx);
2654 seqview_fill(ctx);
2655
2656 Gui_Widget *wdg = gui_context_data_get(ctx, SELECTED_WDG);
2657 _editor_wdg_selected_set(wdg);
2658 objtree_item_selected_set(wdg);
2659}
2660
2661static void
2626_project_close(const Gui_Context *ctx) 2662_project_close(const Gui_Context *ctx)
2627{ 2663{
2628 /* Clear lists. */ 2664 /* Clear lists. */
@@ -2670,6 +2706,22 @@ _project_close(const Gui_Context *ctx)
2670 } 2706 }
2671 } 2707 }
2672 2708
2709 Elm_Object_Item *glit = elm_toolbar_first_item_get(g->main_win->context_toolbar);
2710 for ( ; glit; glit = elm_toolbar_item_next_get(glit))
2711 if (elm_object_item_data_get(glit) == ctx) break;
2712
2713 if (glit)
2714 {
2715 Elm_Object_Item *itnext = elm_toolbar_item_prev_get(glit);
2716 itnext = (itnext) ? itnext : elm_toolbar_item_next_get(itnext);
2717 elm_object_item_del(glit);
2718
2719 if (itnext)
2720 {
2721 elm_toolbar_item_selected_set(itnext, EINA_TRUE);
2722 _switch_to_context(elm_object_item_data_get(itnext));
2723 }
2724 }
2673 session_del((Gui_Session *) gui_context_editor_session_get(ctx)); 2725 session_del((Gui_Session *) gui_context_editor_session_get(ctx));
2674 gui_context_del((Gui_Context *) ctx); 2726 gui_context_del((Gui_Context *) ctx);
2675 } 2727 }
@@ -2710,6 +2762,12 @@ _observers_init(const Gui_Context *ctx)
2710 return EINA_TRUE; 2762 return EINA_TRUE;
2711} 2763}
2712 2764
2765static void
2766_context_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2767{
2768 _switch_to_context(data);
2769}
2770
2713static Eina_Bool 2771static Eina_Bool
2714_project_new(const char *filename) 2772_project_new(const char *filename)
2715{ 2773{
@@ -2731,6 +2789,8 @@ _project_new(const char *filename)
2731 } 2789 }
2732 2790
2733 /* FIXME: handle return values */ 2791 /* FIXME: handle return values */
2792 _context_main_widgets_visibility_set(_active_context_get(), EINA_FALSE);
2793
2734 _active_context_set(ctx); 2794 _active_context_set(ctx);
2735 objtree_context_set(ctx); 2795 objtree_context_set(ctx);
2736 seqview_fill(ctx); 2796 seqview_fill(ctx);
@@ -2741,6 +2801,12 @@ _project_new(const char *filename)
2741 _editor_ctx_call(ctx); 2801 _editor_ctx_call(ctx);
2742 2802
2743 _observers_init(ctx); 2803 _observers_init(ctx);
2804
2805 const char *projname = gui_context_project_filename_get(ctx);
2806 Elm_Object_Item *glit = elm_toolbar_item_append(g->main_win->context_toolbar, NULL, projname, _context_toolbar_clicked, ctx);
2807 elm_object_item_data_set(glit, ctx);
2808 elm_toolbar_item_selected_set(glit, EINA_TRUE);
2809
2744 return EINA_TRUE; 2810 return EINA_TRUE;
2745} 2811}
2746 2812
@@ -2795,6 +2861,11 @@ editor_init(GuiLogicCbs *_guilogic_cbs)
2795 _guilogic_cbs->_project_close = _project_close; 2861 _guilogic_cbs->_project_close = _project_close;
2796 _guilogic_cbs->_project_new = _project_new; 2862 _guilogic_cbs->_project_new = _project_new;
2797 2863
2864 //TODO renoce
2865 //elm_toolbar_item_append(g->main_win->context_toolbar, NULL, "Hello", _context_toolbar_clicked, NULL);
2866 //Elm_Object_Item *glit = elm_toolbar_item_append(g->main_win->context_toolbar, NULL, "You", _context_toolbar_clicked, NULL);
2867 //elm_toolbar_item_selected_set(glit, EINA_TRUE);
2868
2798 objtree_init(); 2869 objtree_init();
2799 proplayout_init(); 2870 proplayout_init();
2800 seqview_init(g->main_win->seq_list); 2871 seqview_init(g->main_win->seq_list);
diff --git a/src/bin/egui_gui/egui_layout.json b/src/bin/egui_gui/egui_layout.json
index fcdefd7..65a23c0 100644
--- a/src/bin/egui_gui/egui_layout.json
+++ b/src/bin/egui_gui/egui_layout.json
@@ -964,7 +964,40 @@
964 "Evas.Object.size_hint_align":[-1, -1], 964 "Evas.Object.size_hint_align":[-1, -1],
965 "Evas.Object.visibility":[true] 965 "Evas.Object.visibility":[true]
966 }, 966 },
967 "Contains":["left_panes", "right_panes"] 967 "Contains":["left_panes", "ver_box", "right_panes"]
968 },
969 "ver_box":
970 {
971 "Desc":
972 {
973 "parent":"main_win",
974 "class":"Elm_Box"
975 },
976 "Properties":
977 {
978 "Elm_Box.horizontal":[false],
979 "Evas.Object.size_hint_weight":[1, 1],
980 "Evas.Object.size_hint_align":[-1, 0],
981 "Evas.Object.visibility":[true]
982 },
983 "Contains":["context_toolbar"]
984 },
985 "context_toolbar":
986 {
987 "Desc":
988 {
989 "parent":"ver_box",
990 "class":"Elm_Toolbar",
991 "public":true
992 },
993 "Properties":
994 {
995 "Elm_Toolbar.select_mode":["ELM_OBJECT_SELECT_MODE_DEFAULT"],
996 "Elm_Toolbar.shrink_mode":["ELM_TOOLBAR_SHRINK_NONE"],
997 "Evas.Object.size_hint_weight":[1, 0],
998 "Evas.Object.size_hint_align":[-1, 0],
999 "Evas.Object.visibility":[true]
1000 }
968 }, 1001 },
969 "left_panes": 1002 "left_panes":
970 { 1003 {
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index c9ca231..5bfae77 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -157,8 +157,8 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event)
157 { 157 {
158 ctx = _active_context_get(); 158 ctx = _active_context_get();
159 _canvas_name_update(ctx); 159 _canvas_name_update(ctx);
160 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_TRUE); 160 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE);
161 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_TRUE); 161 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE);
162 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE); 162 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE);
163 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE); 163 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE);
164 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE); 164 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE);
@@ -183,8 +183,8 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event)
183 { 183 {
184 ctx = _active_context_get(); 184 ctx = _active_context_get();
185 _canvas_name_update(ctx); 185 _canvas_name_update(ctx);
186 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_TRUE); 186 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE);
187 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_TRUE); 187 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE);
188 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE); 188 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE);
189 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE); 189 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE);
190 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE); 190 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE);
@@ -478,14 +478,17 @@ _project_menu_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_
478 } 478 }
479 case ITEM_CLOSE: 479 case ITEM_CLOSE:
480 { 480 {
481 _guilogic_cbs->_project_close(_active_context_get()); 481 _guilogic_cbs->_project_close(_active_context_get());
482 _canvas_name_update(_active_context_get()); 482 _canvas_name_update(_active_context_get());
483 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE); 483 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE);
484 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE); 484 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE);
485 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_TRUE);
486 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_TRUE); 485 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_TRUE);
487 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_TRUE); 486 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_TRUE);
488 _menu_item_disabled_set(project_menu, ITEM_EXPORT, EINA_TRUE); 487 _menu_item_disabled_set(project_menu, ITEM_EXPORT, EINA_TRUE);
488
489 if (!gui_contexts_count_get())
490 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_TRUE);
491
489 break; 492 break;
490 } 493 }
491 case ITEM_SAVE: 494 case ITEM_SAVE:
@@ -1089,8 +1092,8 @@ egui_project_open(char *filename)
1089 if (_guilogic_cbs->_project_new(filename)) 1092 if (_guilogic_cbs->_project_new(filename))
1090 { 1093 {
1091 _canvas_name_update(_active_context_get()); 1094 _canvas_name_update(_active_context_get());
1092 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_TRUE); 1095 _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE);
1093 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_TRUE); 1096 _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE);
1094 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE); 1097 _menu_item_disabled_set(project_menu, ITEM_CLOSE, EINA_FALSE);
1095 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE); 1098 _menu_item_disabled_set(project_menu, ITEM_SAVE, EINA_FALSE);
1096 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE); 1099 _menu_item_disabled_set(project_menu, ITEM_SAVEAS, EINA_FALSE);
diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index bd6936c..f03d2a1 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -298,7 +298,7 @@ gui_context_new()
298{ 298{
299 unsigned int i = 0; 299 unsigned int i = 0;
300 /* Looking for free context. */ 300 /* Looking for free context. */
301 for (i = 0; i < (BITS_PER_CONTEXT); i++) 301 for (i = 0; i < (1 << BITS_PER_CONTEXT); i++)
302 { 302 {
303 if (context_array[i] == NULL) 303 if (context_array[i] == NULL)
304 break; 304 break;
@@ -334,6 +334,17 @@ gui_context_new()
334 return ctx; 334 return ctx;
335} 335}
336 336
337int
338gui_contexts_count_get()
339{
340 int i;
341 int ret = 0;
342 for (i = 0; i < (1 << BITS_PER_CONTEXT); i++)
343 if (context_array[i]) ret++;
344
345 return ret;
346}
347
337Eina_List* 348Eina_List*
338gui_context_wdg_list_get(const Gui_Context *ctx) 349gui_context_wdg_list_get(const Gui_Context *ctx)
339{ 350{
diff --git a/src/lib/gui_widget.h b/src/lib/gui_widget.h
index 66608cb..9958f05 100644
--- a/src/lib/gui_widget.h
+++ b/src/lib/gui_widget.h
@@ -115,6 +115,9 @@ egui_shutdown();
115Gui_Context* 115Gui_Context*
116gui_context_new(); 116gui_context_new();
117 117
118int
119gui_contexts_count_get();
120
118/* Get list of widgets of context */ 121/* Get list of widgets of context */
119Eina_List* 122Eina_List*
120gui_context_wdg_list_get(const Gui_Context *ctx); 123gui_context_wdg_list_get(const Gui_Context *ctx);