From 1977c8fca3d3687a5dc5d17918d72bb1af21b31e Mon Sep 17 00:00:00 2001 From: Daniel Juyung Seo Date: Mon, 3 Feb 2014 01:24:11 +0900 Subject: [PATCH] test_focus: Internal refactoring of focus tests. - Moved focus2, focus3 from test_focus2.c to test_focus.c - Renamed "Focus 3" to "Focus Hide/Del". - Renamed "Focus Custom" to "Focus Style" - Renamed test_focus3.c to test_focus_custom_chain.c --- data/objects/Makefile.am | 10 +- ...{test_focus_custom.edc => test_focus_style.edc} | 0 src/bin/Makefile.am | 4 +- src/bin/test.c | 12 +- src/bin/test_focus.c | 252 ++++++++++++++++++++- .../{test_focus3.c => test_focus_custom_chain.c} | 218 +----------------- src/bin/test_focus_style.c | 116 ++++++++++ 7 files changed, 382 insertions(+), 230 deletions(-) rename data/objects/{test_focus_custom.edc => test_focus_style.edc} (100%) rename src/bin/{test_focus3.c => test_focus_custom_chain.c} (52%) create mode 100644 src/bin/test_focus_style.c diff --git a/data/objects/Makefile.am b/data/objects/Makefile.am index 7fde81e..35bbf1c 100644 --- a/data/objects/Makefile.am +++ b/data/objects/Makefile.am @@ -7,7 +7,7 @@ EDJE_CC_FLAGS += -id $(top_srcdir)/data/objects -fd $(top_srcdir)/data/objects filesdir = $(datadir)/elementary/objects -files_DATA = test.edj test_external.edj multip.edj cursors.edj font_preview.edj postit_ent.edj multibuttonentry.edj test_prefs.edj test_prefs.epb test_focus_custom.edj +files_DATA = test.edj test_external.edj multip.edj cursors.edj font_preview.edj postit_ent.edj multibuttonentry.edj test_prefs.edj test_prefs.epb test_focus_style.edj EXTRA_DIST = \ test.edc \ @@ -19,7 +19,7 @@ cursors.edc \ font_preview.edc \ postit_ent.edc \ multibuttonentry.edc \ -test_focus_custom.edc \ +test_focus_style.edc \ over.png \ under.png \ sky.jpg \ @@ -81,10 +81,10 @@ test_prefs.epb: Makefile test_prefs.epc $(top_srcdir)/data/objects/test_prefs.epc \ $(top_builddir)/data/objects/test_prefs.epb -test_focus_custom.edj: Makefile test_focus_custom.edc +test_focus_style.edj: Makefile test_focus_style.edc $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) \ - $(top_srcdir)/data/objects/test_focus_custom.edc \ - $(top_builddir)/data/objects/test_focus_custom.edj + $(top_srcdir)/data/objects/test_focus_style.edc \ + $(top_builddir)/data/objects/test_focus_style.edj clean-local: rm -f *.edj diff --git a/data/objects/test_focus_custom.edc b/data/objects/test_focus_style.edc similarity index 100% rename from data/objects/test_focus_custom.edc rename to data/objects/test_focus_style.edc diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 46f35f0..312b23c 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -73,8 +73,8 @@ test_flip_page.c \ test_flipselector.c \ test_floating.c \ test_focus.c \ -test_focus2.c \ -test_focus3.c \ +test_focus_custom_chain.c \ +test_focus_style.c \ test_gengrid.c \ test_genlist.c \ test_gesture_layer.c \ diff --git a/src/bin/test.c b/src/bin/test.c index 6de3df8..4c9e790 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -185,9 +185,9 @@ void test_cursor3(void *data, Evas_Object *obj, void *event_info); void test_cursor4(void *data, Evas_Object *obj, void *event_info); void test_focus(void *data, Evas_Object *obj, void *event_info); void test_focus2(void *data, Evas_Object *obj, void *event_info); -void test_focus3(void *data, Evas_Object *obj, void *event_info); -void test_focus4(void *data, Evas_Object *obj, void *event_info); -void test_focus_custom(void *data, Evas_Object *obj, void *event_info); +void test_focus_hide_del(void *data, Evas_Object *obj, void *event_info); +void test_focus_custom_chain(void *data, Evas_Object *obj, void *event_info); +void test_focus_style(void *data, Evas_Object *obj, void *event_info); void test_flipselector(void *data, Evas_Object *obj, void *event_info); void test_diskselector(void *data, Evas_Object *obj, void *event_info); void test_colorselector(void *data, Evas_Object *obj, void *event_info); @@ -750,9 +750,9 @@ add_tests: //------------------------------// ADD_TEST(NULL, "Focus", "Focus", test_focus); ADD_TEST(NULL, "Focus", "Focus 2", test_focus2); - ADD_TEST(NULL, "Focus", "Focus 3", test_focus3); - ADD_TEST(NULL, "Focus", "Focus 4", test_focus4); - ADD_TEST(NULL, "Focus", "Focus Custom", test_focus_custom); + ADD_TEST(NULL, "Focus", "Focus Hide/Del", test_focus_hide_del); + ADD_TEST(NULL, "Focus", "Focus Custom Chain", test_focus_custom_chain); + ADD_TEST(NULL, "Focus", "Focus Style", test_focus_style); //------------------------------// ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe); diff --git a/src/bin/test_focus.c b/src/bin/test_focus.c index ba78e03..4bdbf65 100644 --- a/src/bin/test_focus.c +++ b/src/bin/test_focus.c @@ -1,9 +1,10 @@ -/* Test for Focus Chain Linear*/ #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif #include +/**** focus 1 ****/ + static Eina_Bool _event(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info) { @@ -409,3 +410,252 @@ test_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf } } } + +/**** focus 2 ****/ + +static void +_focus_in(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info) +{ + const char *type = evas_object_type_get(event_info); + if ((type) && (!strcmp(type, "elm_widget"))) + type = elm_object_widget_type_get(event_info); + printf("Evas_Object focus in: %p %s\n", event_info, type); +} + +static void +_focus_out(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info) +{ + const char *type = evas_object_type_get(event_info); + if ((type) && (!strcmp(type, "elm_widget"))) + type = elm_object_widget_type_get(event_info); + printf("Evas_Object focus out: %p %s\n", event_info, type); +} + +static void +_focus_obj(void *data, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *newfocus = data; + const char *type = evas_object_type_get(newfocus); + if ((type) && (!strcmp(type, "elm_widget"))) + type = elm_object_widget_type_get(newfocus); + printf("elm_object_focus_set(%p, EINA_TRUE) %s\n", newfocus, type); + elm_object_focus_set(newfocus, EINA_TRUE); +} + +static void +_focus_layout_part(void *data, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *ed = elm_layout_edje_get(data); + + Evas_Object *newfocus = (Evas_Object *)edje_object_part_object_get(ed, "sky"); + const char *type = evas_object_type_get(newfocus); + printf("evas_object_focus_set(%p, EINA_TRUE) %s\n", newfocus, type); + evas_object_focus_set(newfocus, EINA_TRUE);; +} + +void +test_focus2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *win, *bx, *ly, *bt, *en, *en1, *bt1, *bt2; + char buf[PATH_MAX]; + + win = elm_win_util_standard_add("focus2", "Focus 2"); + elm_win_autodel_set(win, EINA_TRUE); + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + + evas_event_callback_add + (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, + _focus_in, NULL); + evas_event_callback_add + (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, + _focus_out, NULL); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + +#define PARENT bx /* this is broken, but should work */ +//#define PARENT win + + en = elm_entry_add(PARENT); + elm_entry_scrollable_set(en, EINA_TRUE); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); + elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_object_text_set(en, "Entry that should get focus"); + elm_entry_single_line_set(en, EINA_TRUE); + evas_object_show(en); + elm_box_pack_end(bx, en); + + bt = elm_button_add(PARENT); + elm_object_text_set(bt, "Give focus to entry"); + evas_object_smart_callback_add(bt, "clicked", _focus_obj, en); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + ly = elm_layout_add(PARENT); + snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get()); + elm_layout_file_set(ly, buf, "layout"); + evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, ly); + evas_object_show(ly); + + bt1 = bt = elm_button_add(ly); + elm_object_text_set(bt, "Button 1"); + elm_object_part_content_set(ly, "element1", bt); + + en1 = elm_entry_add(ly); + elm_entry_scrollable_set(en1, EINA_TRUE); + evas_object_size_hint_weight_set(en1, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en1, EVAS_HINT_FILL, 0.5); + elm_scroller_policy_set(en1, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_object_text_set(en1, "Scrolled Entry that should get focus"); + elm_entry_single_line_set(en1, EINA_TRUE); + elm_object_part_content_set(ly, "element2", en1); + + bt = elm_button_add(ly); + elm_object_text_set(bt, "Button 2"); + elm_object_part_content_set(ly, "element3", bt); + + bt = elm_button_add(PARENT); + elm_object_text_set(bt, "Give focus to layout"); + evas_object_smart_callback_add(bt, "clicked", _focus_obj, ly); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(PARENT); + elm_object_text_set(bt, "Give focus to layout part"); + evas_object_smart_callback_add(bt, "clicked", _focus_layout_part, ly); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(PARENT); + elm_object_text_set(bt, "Give focus to layout 'Button 1'"); + evas_object_smart_callback_add(bt, "clicked", _focus_obj, bt1); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt2 = elm_button_add(PARENT); + elm_object_text_set(bt2, "Give focus to layout 'Entry'"); + evas_object_smart_callback_add(bt2, "clicked", _focus_obj, en); + evas_object_size_hint_weight_set(bt2, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt2); + evas_object_show(bt2); + + elm_object_focus_next_object_set(bt2, en, ELM_FOCUS_DOWN); + + evas_object_resize(win, 400, 400); + evas_object_show(win); +} + +/**** focus 3 ****/ + +static Evas_Object *foc = NULL; + +static void +_foc(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + foc = obj; + printf("foc -> %p\n", foc); +} + +static void +_unfoc(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + foc = NULL; + printf("foc -> %p\n", foc); +} + +static void +_add(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *bx = data, *en; + + en = elm_entry_add(elm_object_top_widget_get(bx)); + elm_entry_scrollable_set(en, EINA_TRUE); + elm_object_text_set(en, "An entry"); + evas_object_smart_callback_add(en, "focused", _foc, NULL); + evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); + elm_entry_single_line_set(en, EINA_TRUE); + elm_box_pack_start(bx, en); + evas_object_show(en); +} + +static void +_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + if (foc) evas_object_del(foc); +} + +static void +_hide(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + if (foc) evas_object_hide(foc); +} + +void +test_focus_hide_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *win, *bx, *bt, *en; + + win = elm_win_util_standard_add("focus-hide-del", "Focus Hide/Del"); + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + elm_win_autodel_set(win, EINA_TRUE); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + en = elm_entry_add(win); + elm_entry_scrollable_set(en, EINA_TRUE); + elm_object_text_set(en, "An entry"); + evas_object_smart_callback_add(en, "focused", _foc, NULL); + evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); + elm_entry_single_line_set(en, EINA_TRUE); + elm_box_pack_end(bx, en); + evas_object_show(en); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, EINA_FALSE); + elm_object_text_set(bt, "Add"); + evas_object_smart_callback_add(bt, "clicked", _add, bx); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, EINA_FALSE); + elm_object_text_set(bt, "Del"); + evas_object_smart_callback_add(bt, "clicked", _del, NULL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, EINA_FALSE); + elm_object_text_set(bt, "Hide"); + evas_object_smart_callback_add(bt, "clicked", _hide, NULL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + evas_object_resize(win, 320, 480); + evas_object_show(win); +} diff --git a/src/bin/test_focus3.c b/src/bin/test_focus_custom_chain.c similarity index 52% rename from src/bin/test_focus3.c rename to src/bin/test_focus_custom_chain.c index 207327f..8103037 100644 --- a/src/bin/test_focus3.c +++ b/src/bin/test_focus_custom_chain.c @@ -1,110 +1,8 @@ -/* Test for Focus Chain Linear*/ #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif #include -static Evas_Object *foc = NULL; - -static void -_foc(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - foc = obj; - printf("foc -> %p\n", foc); -} - -static void -_unfoc(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - foc = NULL; - printf("foc -> %p\n", foc); -} - -static void -_add(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Evas_Object *bx = data, *en; - - en = elm_entry_add(elm_object_top_widget_get(bx)); - elm_entry_scrollable_set(en, EINA_TRUE); - elm_object_text_set(en, "An entry"); - evas_object_smart_callback_add(en, "focused", _foc, NULL); - evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); - evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); - elm_entry_single_line_set(en, EINA_TRUE); - elm_box_pack_start(bx, en); - evas_object_show(en); -} - -static void -_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - if (foc) evas_object_del(foc); -} - -static void -_hide(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - if (foc) evas_object_hide(foc); -} - -void -test_focus3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Evas_Object *win, *bx, *bt, *en; - - win = elm_win_util_standard_add("focus3", "Focus 3"); - elm_win_focus_highlight_enabled_set(win, EINA_TRUE); - elm_win_autodel_set(win, EINA_TRUE); - - bx = elm_box_add(win); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, bx); - evas_object_show(bx); - - en = elm_entry_add(win); - elm_entry_scrollable_set(en, EINA_TRUE); - elm_object_text_set(en, "An entry"); - evas_object_smart_callback_add(en, "focused", _foc, NULL); - evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); - evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); - elm_entry_single_line_set(en, EINA_TRUE); - elm_box_pack_end(bx, en); - evas_object_show(en); - - bt = elm_button_add(win); - elm_object_focus_allow_set(bt, EINA_FALSE); - elm_object_text_set(bt, "Add"); - evas_object_smart_callback_add(bt, "clicked", _add, bx); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - elm_object_focus_allow_set(bt, EINA_FALSE); - elm_object_text_set(bt, "Del"); - evas_object_smart_callback_add(bt, "clicked", _del, NULL); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - elm_object_focus_allow_set(bt, EINA_FALSE); - elm_object_text_set(bt, "Hide"); - evas_object_smart_callback_add(bt, "clicked", _hide, NULL); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - evas_object_resize(win, 320, 480); - evas_object_show(win); -} - static void highlight_enabled_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { @@ -206,7 +104,7 @@ create_win_bt_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void } void -test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +test_focus_custom_chain(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Evas_Object *win, *fr, *bx, *bx2, *tg, *bt, *sp; Evas_Object *lb, *bt1, *bt2, *bt3, *bt4; @@ -215,7 +113,7 @@ test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in elm_config_focus_highlight_enabled_set(EINA_TRUE); elm_config_focus_highlight_animate_set(EINA_TRUE); - win = elm_win_util_standard_add("focus4", "Focus 4"); + win = elm_win_util_standard_add("focus-custom-chain", "Focus Custom Chain"); elm_win_autodel_set(win, EINA_TRUE); elm_win_focus_highlight_enabled_set(win, EINA_TRUE); elm_win_focus_highlight_animate_set(win, EINA_TRUE); @@ -343,115 +241,3 @@ test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in evas_object_resize(win, 320, 320); evas_object_show(win); } - -static void -glow_effect_on_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - Evas_Object *chk = evas_object_data_get(obj, "glow_is_enable"); - - if (elm_check_state_get(chk)) elm_win_focus_highlight_style_set(data, "glow_effect"); -} - -static void -glow_effect_off_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - Evas_Object *chk = evas_object_data_get(obj, "glow_is_enable"); - - if (elm_check_state_get(chk)) elm_win_focus_highlight_style_set(data, "glow"); -} - -void -test_focus_custom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Evas_Object *win, *fr, *bx, *bx2, *bt, *spinner, *sp, *chk; - char win_focus_theme[PATH_MAX] = { 0 }; - - sprintf(win_focus_theme, "%s/objects/test_focus_custom.edj", elm_app_data_dir_get()); - - elm_theme_overlay_add(NULL, win_focus_theme); - - win = elm_win_util_standard_add("focus_custom", "Focus Custom"); - elm_win_autodel_set(win, EINA_TRUE); - elm_win_focus_highlight_enabled_set(win, EINA_TRUE); - elm_win_focus_highlight_animate_set(win, EINA_TRUE); - elm_win_focus_highlight_style_set(win, "glow"); - - fr = elm_frame_add(win); - evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, fr); - elm_object_style_set(fr, "pad_large"); - evas_object_show(fr); - - bx = elm_box_add(fr); - elm_object_content_set(fr, bx); - evas_object_show(bx); - - chk = elm_check_add(bx); - evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(chk, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_text_set(chk, "Enable glow effect on \"Glow\" Button"); - elm_check_state_set(chk, EINA_TRUE); - elm_box_pack_end(bx, chk); - evas_object_show(chk); - - spinner = elm_spinner_add(bx); - evas_object_size_hint_weight_set(spinner, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(spinner, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx, spinner); - evas_object_show(spinner); - - bt = elm_button_add(bx); - elm_object_text_set(bt, "Glow Button"); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "focused", glow_effect_on_cb, win); - evas_object_smart_callback_add(bt, "unfocused", glow_effect_off_cb, win); - evas_object_data_set(bt, "glow_is_enable", chk); - evas_object_show(bt); - - sp = elm_separator_add(bx); - elm_separator_horizontal_set(sp, EINA_TRUE); - evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx, sp); - evas_object_show(sp); - - bx2 = elm_box_add(bx); - elm_box_horizontal_set(bx2, EINA_TRUE); - evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx, bx2); - evas_object_show(bx2); - - bt = elm_button_add(bx2); - elm_object_text_set(bt, "Button 1"); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx2, bt); - evas_object_show(bt); - - bt = elm_button_add(bx2); - elm_object_text_set(bt, "Button 2"); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx2, bt); - evas_object_show(bt); - - bt = elm_button_add(bx2); - elm_object_text_set(bt, "Button 3"); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx2, bt); - evas_object_show(bt); - - bt = elm_button_add(bx2); - elm_object_text_set(bt, "Button 4"); - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx2, bt); - evas_object_show(bt); - - evas_object_resize(win, 320, 320); - evas_object_show(win); -} diff --git a/src/bin/test_focus_style.c b/src/bin/test_focus_style.c new file mode 100644 index 0000000..7533c2c --- /dev/null +++ b/src/bin/test_focus_style.c @@ -0,0 +1,116 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#include + +static void +glow_effect_on_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *chk = evas_object_data_get(obj, "glow_is_enable"); + + if (elm_check_state_get(chk)) elm_win_focus_highlight_style_set(data, "glow_effect"); +} + +static void +glow_effect_off_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *chk = evas_object_data_get(obj, "glow_is_enable"); + + if (elm_check_state_get(chk)) elm_win_focus_highlight_style_set(data, "glow"); +} + +void +test_focus_style(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *win, *fr, *bx, *bx2, *bt, *spinner, *sp, *chk; + char win_focus_theme[PATH_MAX] = { 0 }; + + sprintf(win_focus_theme, "%s/objects/test_focus_style.edj", elm_app_data_dir_get()); + + elm_theme_overlay_add(NULL, win_focus_theme); + + win = elm_win_util_standard_add("focus-style", "Focus Style"); + elm_win_autodel_set(win, EINA_TRUE); + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + elm_win_focus_highlight_animate_set(win, EINA_TRUE); + elm_win_focus_highlight_style_set(win, "glow"); + + fr = elm_frame_add(win); + evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, fr); + elm_object_style_set(fr, "pad_large"); + evas_object_show(fr); + + bx = elm_box_add(fr); + elm_object_content_set(fr, bx); + evas_object_show(bx); + + chk = elm_check_add(bx); + evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(chk, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(chk, "Enable glow effect on \"Glow\" Button"); + elm_check_state_set(chk, EINA_TRUE); + elm_box_pack_end(bx, chk); + evas_object_show(chk); + + spinner = elm_spinner_add(bx); + evas_object_size_hint_weight_set(spinner, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(spinner, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, spinner); + evas_object_show(spinner); + + bt = elm_button_add(bx); + elm_object_text_set(bt, "Glow Button"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, bt); + evas_object_smart_callback_add(bt, "focused", glow_effect_on_cb, win); + evas_object_smart_callback_add(bt, "unfocused", glow_effect_off_cb, win); + evas_object_data_set(bt, "glow_is_enable", chk); + evas_object_show(bt); + + sp = elm_separator_add(bx); + elm_separator_horizontal_set(sp, EINA_TRUE); + evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, sp); + evas_object_show(sp); + + bx2 = elm_box_add(bx); + elm_box_horizontal_set(bx2, EINA_TRUE); + evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, bx2); + evas_object_show(bx2); + + bt = elm_button_add(bx2); + elm_object_text_set(bt, "Button 1"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx2, bt); + evas_object_show(bt); + + bt = elm_button_add(bx2); + elm_object_text_set(bt, "Button 2"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx2, bt); + evas_object_show(bt); + + bt = elm_button_add(bx2); + elm_object_text_set(bt, "Button 3"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx2, bt); + evas_object_show(bt); + + bt = elm_button_add(bx2); + elm_object_text_set(bt, "Button 4"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx2, bt); + evas_object_show(bt); + + evas_object_resize(win, 320, 320); + evas_object_show(win); +} -- 2.7.4