summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-12-16 15:44:34 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-12-23 18:35:58 +0200
commit0c216de14fcd3cf75f42ee69e4dd3a6ca26a2c6c (patch)
treebb748f68d05b87945718ab393c2efdae50dd9af8 /src/bin
parent049fbcc94c653e5034ab73ca08b4aa0c35134672 (diff)
Adding key bindings
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/editor.c14
-rw-r--r--src/bin/egui_gui/egui_logic.c98
2 files changed, 38 insertions, 74 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index de81c5d..9e6176d 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -566,7 +566,7 @@ _mouse_down_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_
566 566
567 drag_start(wdg_eo, NULL, EDITOR_DRAG_DATA, wdg, _drag_start_cb); 567 drag_start(wdg_eo, NULL, EDITOR_DRAG_DATA, wdg, _drag_start_cb);
568 568
569 evas_object_focus_set(wdg_eo, EINA_TRUE); 569 eo_do(wdg_eo, evas_obj_focus_set(EINA_TRUE));
570 _editor_wdg_selected_set(wdg); 570 _editor_wdg_selected_set(wdg);
571 objtree_item_selected_set(wdg); 571 objtree_item_selected_set(wdg);
572} 572}
@@ -3214,7 +3214,6 @@ editor_shutdown()
3214 free(di); 3214 free(di);
3215 drop_target_wdg_del(NULL, g->main_win->canvas_bg); 3215 drop_target_wdg_del(NULL, g->main_win->canvas_bg);
3216 3216
3217 key_bindings_shutdown();
3218 target_db_shutdown(); 3217 target_db_shutdown();
3219 proplayout_shutdown(); 3218 proplayout_shutdown();
3220 objtree_shutdown(); 3219 objtree_shutdown();
@@ -4260,7 +4259,15 @@ _key_binding_redo_cb(void *data EINA_UNUSED)
4260static void 4259static void
4261_key_binding_wdg_del_cb(void *data EINA_UNUSED) 4260_key_binding_wdg_del_cb(void *data EINA_UNUSED)
4262{ 4261{
4263 _editor_selected_wdg_del_cb(); 4262 /* If main_win is currently focused, widget can be deleted. */
4263 Eo *obj = eo_do(g->main_win->main_win, elm_obj_widget_focused_object_get());
4264 if ((obj == g->main_win->main_win) ||
4265 (eo_isa(obj, ELM_GENLIST_CLASS)) ||
4266 (eo_isa(obj, ELM_TOOLBAR_CLASS)) ||
4267 (eo_isa(obj, ELM_SCROLLER_CLASS)))
4268 {
4269 _editor_selected_wdg_del_cb();
4270 }
4264} 4271}
4265 4272
4266void 4273void
@@ -4318,7 +4325,6 @@ editor_init(GuiLogicCbs *_guilogic_cbs)
4318 _drop_target_drop, NULL 4325 _drop_target_drop, NULL
4319 ); 4326 );
4320 4327
4321 key_bindings_init();
4322 key_binding_new(_key_binding_undo_cb, NULL, "ctrl", "z", NULL); 4328 key_binding_new(_key_binding_undo_cb, NULL, "ctrl", "z", NULL);
4323 key_binding_new(_key_binding_redo_cb, NULL, "ctrl", "shift", "z", NULL); 4329 key_binding_new(_key_binding_redo_cb, NULL, "ctrl", "shift", "z", NULL);
4324 key_binding_new(_key_binding_wdg_del_cb, NULL, "delete", NULL); 4330 key_binding_new(_key_binding_wdg_del_cb, NULL, "delete", NULL);
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index f0e1e71..ed454ec 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -17,6 +17,7 @@
17#include "ffi_glue.h" 17#include "ffi_glue.h"
18#include "target.h" 18#include "target.h"
19#include "dnd.h" 19#include "dnd.h"
20#include "key_bindings.h"
20 21
21/*FIXME: remove this include */ 22/*FIXME: remove this include */
22#include "objtree.h" 23#include "objtree.h"
@@ -321,69 +322,6 @@ _fs_mode_open(int fs_mode)
321 evas_object_smart_callback_add(fs_win->fileselector, "done", _on_fs_done, (void *)(intptr_t) fs_mode); 322 evas_object_smart_callback_add(fs_win->fileselector, "done", _on_fs_done, (void *)(intptr_t) fs_mode);
322} 323}
323 324
324#if 0
325static void
326_toggle_menu(Eo *menu)
327{
328 Elm_Transit *trans;
329 int x, y, w, h;
330
331 eo_do(menu, evas_obj_position_get(&x, &y));
332 eo_do(menu, evas_obj_size_get(&w, &h));
333 if (y == 0)
334 {
335 x = -w;
336 y = -h;
337 }
338 else if (y == -h)
339 {
340 x = w;
341 y = h;
342 }
343 else
344 return;
345
346 trans = elm_transit_add();
347 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
348 elm_transit_effect_translation_add(trans, 0, 0, 0, y);
349 elm_transit_object_add(trans, menu);
350 elm_transit_duration_set(trans, 0.5);
351 elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
352 elm_transit_go(trans);
353}
354
355static void
356_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
357{
358 _toggle_menu(g_main_wdgs->menu_box);
359}
360#endif
361
362#if 0
363static Eina_Bool
364_event(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info)
365{
366 /*FIXME: when I change focus, sometimes this event is sent twice. */
367 if (type == EVAS_CALLBACK_KEY_DOWN)
368 {
369 ERR("asdf");
370 Evas_Event_Key_Down *ev = event_info;
371 if (!strcmp(ev->key, "Delete"))
372 {
373 _editor_selected_wdg_del_cb();
374 }
375 return EINA_TRUE;
376 }
377 else if (type == EVAS_CALLBACK_MOUSE_DOWN)
378 {
379 ERR("win event");
380 return EINA_TRUE;
381 }
382 else
383 return EINA_FALSE;
384}
385#endif
386
387static void 325static void
388_factory_vertical_pack(Eina_Bool vertical_pack); 326_factory_vertical_pack(Eina_Bool vertical_pack);
389 327
@@ -889,6 +827,28 @@ _assign_image_to_button(Eo *btn, const char* path)
889 eo_do(btn, elm_obj_container_content_set("icon", ic)); 827 eo_do(btn, elm_obj_container_content_set("icon", ic));
890} 828}
891 829
830static void
831_key_binding_save_cb(void *data)
832{
833 intptr_t action = (intptr_t) data;
834 if (action == ITEM_SAVE)
835 {
836 const Gui_Context * ctx = _active_context_get();
837 const char *dir = gui_context_project_path_get(ctx);
838 const char *filename = gui_context_project_filename_get(ctx);
839 if (!dir || !filename)
840 {
841 _fs_mode_open(ITEM_SAVEAS);
842 return;
843 }
844 generator_ctx_source_generate(ctx, GENERATE_JSON);
845 }
846 else if (action == ITEM_SAVEAS)
847 {
848 _fs_mode_open(action);
849 }
850}
851
892void 852void
893egui_start() 853egui_start()
894{ 854{
@@ -915,16 +875,13 @@ egui_start()
915 evas_object_size_hint_align_set(propsview_rect, EVAS_HINT_FILL, EVAS_HINT_FILL); 875 evas_object_size_hint_align_set(propsview_rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
916 elm_table_pack(g_main_wdgs->main_win->propsview_table, propsview_rect, 0, 2, 1, 1); 876 elm_table_pack(g_main_wdgs->main_win->propsview_table, propsview_rect, 0, 2, 1, 1);
917 877
878 key_bindings_init();
918 editor_init(guilogic_cbs_get()); 879 editor_init(guilogic_cbs_get());
919 880
920 evas_object_smart_callback_add(g_main_wdgs->main_win->objtree_filter_entry, "changed,user", _entry_changed_cb, NULL); 881 key_binding_new(_key_binding_save_cb, (void *) (intptr_t) ITEM_SAVE, "ctrl", "s", NULL);
921 //elm_object_event_callback_add(g_main_wdgs->main_win->main_win, _event, NULL); 882 key_binding_new(_key_binding_save_cb, (void *) (intptr_t) ITEM_SAVEAS, "shift", "ctrl", "s", NULL);
922 883
923 /*Adding resizing to canvas frame*/ 884 evas_object_smart_callback_add(g_main_wdgs->main_win->objtree_filter_entry, "changed,user", _entry_changed_cb, NULL);
924 /*
925 evas_object_event_callback_add(g_main_wdgs->canvas_fr, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_ui, NULL);
926 eo_do(g_main_wdgs->canvas_fr, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _mouse_up_ui, NULL));
927 */
928 885
929 _idle_enterer = ecore_idle_enterer_add(_canvas_bg_show_on_idle, NULL); 886 _idle_enterer = ecore_idle_enterer_add(_canvas_bg_show_on_idle, NULL);
930 /* Toolbar */ 887 /* Toolbar */
@@ -1040,6 +997,7 @@ void
1040egui_stop() 997egui_stop()
1041{ 998{
1042 editor_shutdown(); 999 editor_shutdown();
1000 key_bindings_shutdown();
1043 ecore_idle_enterer_del(_idle_enterer); 1001 ecore_idle_enterer_del(_idle_enterer);
1044 _idle_enterer = NULL; 1002 _idle_enterer = NULL;
1045} 1003}