summaryrefslogtreecommitdiff
path: root/src/bin/test_focus_policy.c
blob: a54c0077083684b121f431c2a99be1320809df78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>

static void
_rdg_changed_cb(void *data, Evas_Object *obj,
                void *event_info EINA_UNUSED)
{
   Evas_Object *bt = data;
   int value = elm_radio_value_get(obj);

   // set focus move policy to the test button
   switch (value)
     {
      case 0:
        elm_object_text_set(bt, "Test Button(MOUSE CLICK or KEY)");
        elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_CLICK);
        break;
      case 1:
        elm_object_text_set(bt, "Test Button(MOUSE IN or KEY)");
        elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_IN);
        break;
      case 2:
        elm_object_text_set(bt, "Test Button(KEY ONLY)");
        elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_KEY_ONLY);
        break;
      default:
        break;
     }
}

void
test_focus_object_policy(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Evas_Object *win, *fr, *bx, *bt, *test_bt, *rdg, *rd;

   win = elm_win_util_standard_add("focus-object-policy", "Focus Object Policy");
   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);

   bt = elm_button_add(bx);
   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(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(bx);
   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(bx, bt);
   evas_object_show(bt);

   // a button to test focus object policy
   test_bt = elm_button_add(bx);
   elm_object_text_set(test_bt, "Test Button(MOUSE CLICK or KEY)");
   evas_object_size_hint_weight_set(test_bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(test_bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   elm_box_pack_end(bx, test_bt);
   evas_object_show(test_bt);
   elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_CLICK);

   bt = elm_button_add(bx);
   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(bx, bt);
   evas_object_show(bt);

   // radios to select focus object policy
   rd = elm_radio_add(bx);
   elm_radio_state_value_set(rd, 0);
   evas_object_size_hint_align_set(rd, 0.0, 0.5);
   elm_object_text_set(rd, "Focus Move Pollicy Mouse Click");
   elm_box_pack_end(bx, rd);
   evas_object_show(rd);
   evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);

   rdg = rd;

   rd = elm_radio_add(bx);
   elm_radio_state_value_set(rd, 1);
   elm_radio_group_add(rd, rdg);
   evas_object_size_hint_align_set(rd, 0.0, 0.5);
   elm_object_text_set(rd, "Focus Move Policy Mouse In");
   elm_box_pack_end(bx, rd);
   evas_object_show(rd);
   evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);

   rd = elm_radio_add(bx);
   elm_radio_state_value_set(rd, 2);
   elm_radio_group_add(rd, rdg);
   evas_object_size_hint_align_set(rd, 0.0, 0.5);
   elm_object_text_set(rd, "Focus Move Pollicy Key Only");
   elm_box_pack_end(bx, rd);
   evas_object_show(rd);
   evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);

   evas_object_resize(win, 320, 320);
   evas_object_show(win);
}