2011-03-19 08:11:45 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2012-03-29 12:27:13 -07:00
|
|
|
#include <Elementary.h>
|
2013-11-04 00:54:31 -08:00
|
|
|
|
2012-03-02 04:42:42 -08:00
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
highlight_enabled_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2012-03-02 04:42:42 -08:00
|
|
|
{
|
2012-03-06 04:04:25 -08:00
|
|
|
elm_config_focus_highlight_enabled_set(elm_check_state_get(obj));
|
2012-03-02 04:42:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
highlight_animate_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2012-03-02 04:42:42 -08:00
|
|
|
{
|
2012-03-06 04:04:25 -08:00
|
|
|
elm_config_focus_highlight_animate_set(elm_check_state_get(obj));
|
2012-03-02 04:42:42 -08:00
|
|
|
}
|
|
|
|
|
2013-08-11 02:22:34 -07:00
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
win_highlight_enabled_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2013-08-11 02:22:34 -07:00
|
|
|
{
|
|
|
|
elm_win_focus_highlight_enabled_set((Evas_Object *)data,
|
|
|
|
elm_check_state_get(obj));
|
|
|
|
}
|
|
|
|
|
2013-08-11 02:58:28 -07:00
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
win_highlight_animate_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2013-08-11 02:58:28 -07:00
|
|
|
{
|
|
|
|
elm_win_focus_highlight_animate_set((Evas_Object *)data,
|
|
|
|
elm_check_state_get(obj));
|
|
|
|
}
|
|
|
|
|
2012-03-02 04:42:42 -08:00
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
custom_chain_unset_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2012-03-02 04:42:42 -08:00
|
|
|
{
|
|
|
|
Evas_Object *c, *child = NULL;
|
|
|
|
Evas_Object *bx = (Evas_Object *)data;
|
|
|
|
Eina_List *l, *children = NULL, *custom_chain = NULL;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (elm_check_state_get(obj))
|
|
|
|
{
|
|
|
|
children = elm_box_children_get(bx);
|
|
|
|
EINA_LIST_FOREACH(children, l, c)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
child = c;
|
|
|
|
custom_chain = eina_list_append(custom_chain, c);
|
|
|
|
elm_object_focus_custom_chain_set(bx, custom_chain);
|
|
|
|
}
|
|
|
|
else if (i == 1) elm_object_focus_custom_chain_prepend(bx, c, child);
|
|
|
|
else if (i == 2)
|
|
|
|
{
|
|
|
|
elm_object_focus_custom_chain_append(bx, c, child);
|
|
|
|
child = c;
|
|
|
|
}
|
|
|
|
else if (i == 3) elm_object_focus_custom_chain_prepend(bx, c, child);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!elm_object_focus_custom_chain_get(bx)) return;
|
|
|
|
elm_object_focus_custom_chain_unset(bx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
create_win_bt_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2012-03-02 04:42:42 -08:00
|
|
|
{
|
|
|
|
Evas_Object *win, *gd, *bt;
|
|
|
|
|
|
|
|
win = elm_win_util_standard_add("test focus", "Test Focus");
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
|
|
|
|
gd = elm_grid_add(win);
|
|
|
|
elm_grid_size_set(gd, 100, 100);
|
|
|
|
evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(win, gd);
|
|
|
|
evas_object_show(gd);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_object_text_set(bt, "Button 1");
|
|
|
|
elm_grid_pack(gd, bt, 10, 10, 80, 20);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_object_text_set(bt, "Button 2");
|
|
|
|
elm_grid_pack(gd, bt, 10, 30, 80, 20);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_object_text_set(bt, "Button 3");
|
|
|
|
elm_grid_pack(gd, bt, 10, 50, 80, 20);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_object_text_set(bt, "Button 4");
|
|
|
|
elm_grid_pack(gd, bt, 10, 70, 80, 20);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
evas_object_resize(win, 160, 160);
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-02 08:24:11 -08:00
|
|
|
test_focus_custom_chain(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2012-03-02 04:42:42 -08:00
|
|
|
{
|
2013-08-11 09:42:48 -07:00
|
|
|
Evas_Object *win, *fr, *bx, *bx2, *tg, *bt, *sp;
|
|
|
|
Evas_Object *lb, *bt1, *bt2, *bt3, *bt4;
|
2012-03-02 04:42:42 -08:00
|
|
|
Eina_List *custom_chain = NULL;
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_config_focus_highlight_enabled_set(EINA_TRUE);
|
|
|
|
elm_config_focus_highlight_animate_set(EINA_TRUE);
|
|
|
|
|
2014-02-02 08:24:11 -08:00
|
|
|
win = elm_win_util_standard_add("focus-custom-chain", "Focus Custom Chain");
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
2013-08-11 02:58:28 -07:00
|
|
|
elm_win_focus_highlight_animate_set(win, EINA_TRUE);
|
2013-08-11 09:42:48 -07:00
|
|
|
|
|
|
|
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);
|
2012-03-02 04:42:42 -08:00
|
|
|
|
|
|
|
/* First Example - Using Focus Highlight */
|
2013-08-11 09:42:48 -07:00
|
|
|
bx = elm_box_add(fr);
|
|
|
|
elm_object_content_set(fr, bx);
|
|
|
|
evas_object_show(bx);
|
2012-03-02 04:42:42 -08:00
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
tg = elm_check_add(bx);
|
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 02:22:34 -07:00
|
|
|
elm_object_text_set(tg, "Focus Highlight Enabled (Config)");
|
2014-05-01 05:54:24 -07:00
|
|
|
elm_check_state_set(tg, elm_config_focus_highlight_enabled_get());
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_smart_callback_add(tg, "changed", highlight_enabled_cb, NULL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, tg);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(tg);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
tg = elm_check_add(bx);
|
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 02:22:34 -07:00
|
|
|
elm_object_text_set(tg, "Focus Highlight Animate (Config)");
|
2014-05-01 05:54:24 -07:00
|
|
|
elm_check_state_set(tg, elm_config_focus_highlight_animate_get());
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_smart_callback_add(tg, "changed", highlight_animate_cb, NULL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, tg);
|
2013-08-11 02:22:34 -07:00
|
|
|
evas_object_show(tg);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
tg = elm_check_add(bx);
|
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
2013-08-11 02:22:34 -07:00
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(tg, "Focus Highlight Enabled (Win)");
|
2014-05-01 05:54:24 -07:00
|
|
|
elm_check_state_set(tg, elm_win_focus_highlight_enabled_get(win));
|
2013-08-11 02:22:34 -07:00
|
|
|
evas_object_smart_callback_add(tg, "changed", win_highlight_enabled_cb, win);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, tg);
|
2013-08-11 02:58:28 -07:00
|
|
|
evas_object_show(tg);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
tg = elm_check_add(bx);
|
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
2013-08-11 02:58:28 -07:00
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(tg, "Focus Highlight Animate (Win)");
|
2014-05-01 05:54:24 -07:00
|
|
|
elm_check_state_set(tg, elm_win_focus_highlight_enabled_get(win));
|
2013-08-11 02:58:28 -07:00
|
|
|
evas_object_smart_callback_add(tg, "changed", win_highlight_animate_cb, win);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, tg);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(tg);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
bt = elm_button_add(bx);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(bt, "Create Window");
|
2013-08-11 09:42:48 -07:00
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(bx, bt);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_smart_callback_add(bt, "clicked", create_win_bt_clicked, NULL);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
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);
|
|
|
|
|
2012-03-02 04:42:42 -08:00
|
|
|
/* Second Example - Using Custom Chain */
|
2013-08-11 09:42:48 -07:00
|
|
|
lb = elm_label_add(bx);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(lb, "Custom Chain: Please use tab key to check");
|
2013-08-11 09:42:48 -07:00
|
|
|
evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, lb);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(lb);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
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);
|
2012-03-02 04:42:42 -08:00
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
bt1 = elm_button_add(bx2);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(bt1, "Button 1");
|
|
|
|
evas_object_size_hint_weight_set(bt1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bt1, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx2, bt1);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(bt1);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
bt2 = elm_button_add(bx2);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(bt2, "Button 2");
|
|
|
|
evas_object_size_hint_weight_set(bt2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx2, bt2);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(bt2);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
bt3 = elm_button_add(bx2);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(bt3, "Button 3");
|
|
|
|
evas_object_size_hint_weight_set(bt3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bt3, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx2, bt3);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(bt3);
|
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
bt4 = elm_button_add(bx2);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(bt4, "Button 4");
|
|
|
|
evas_object_size_hint_weight_set(bt4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bt4, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx2, bt4);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(bt4);
|
|
|
|
|
|
|
|
custom_chain = eina_list_append(custom_chain, bt2);
|
|
|
|
custom_chain = eina_list_append(custom_chain, bt1);
|
|
|
|
custom_chain = eina_list_append(custom_chain, bt4);
|
|
|
|
custom_chain = eina_list_append(custom_chain, bt3);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_object_focus_custom_chain_set(bx2, custom_chain);
|
2012-03-02 04:42:42 -08:00
|
|
|
|
2013-08-11 09:42:48 -07:00
|
|
|
tg = elm_check_add(bx);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_object_text_set(tg, "Custom Chain");
|
2013-08-11 09:42:48 -07:00
|
|
|
evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2012-03-02 04:42:42 -08:00
|
|
|
elm_check_state_set(tg, EINA_TRUE);
|
2014-01-22 22:07:33 -08:00
|
|
|
evas_object_smart_callback_add(tg, "changed", custom_chain_unset_cb, bx2);
|
2013-08-11 09:42:48 -07:00
|
|
|
elm_box_pack_end(bx, tg);
|
2012-03-02 04:42:42 -08:00
|
|
|
evas_object_show(tg);
|
2014-01-15 16:34:16 -08:00
|
|
|
|
|
|
|
evas_object_resize(win, 320, 320);
|
|
|
|
evas_object_show(win);
|
2012-03-02 04:42:42 -08:00
|
|
|
}
|