summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_focus_common.c
blob: 375031861a16d7a4d84e6b3c9fca1552244f6383 (plain)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#define EFL_UI_FOCUS_OBJECT_PROTECTED

#include "efl_ui_test_focus_common.h"

//#define DEBUG

#define Q(o,_x,_y,_w,_h) \
  do {\
   Eina_Rect rect; \
   rect.x = _x; \
   rect.y = _y; \
   rect.w = _w; \
   rect.h = _h; \
   focus_test_size(o, rect); \
  } while (0)

Efl_Ui_Focus_Object*
focus_test_object_new(const char *name, int x, int y, int w, int h)
{
   Efl_Ui_Focus_Object *ret;

   ret = efl_add_ref(FOCUS_TEST_CLASS, NULL,
    efl_name_set(efl_added, name)
   );
   Q(ret, x, y, w, h);

   return ret;
}

void
focus_test_setup_cross(Efl_Ui_Focus_Object **middle,
    Efl_Ui_Focus_Object **south,
    Efl_Ui_Focus_Object **north,
    Efl_Ui_Focus_Object **east,
    Efl_Ui_Focus_Object **west)
  {

   *middle = focus_test_object_new("middle", 40, 40, 20, 20);
   *south = focus_test_object_new("south", 40, 80, 20, 20);
   *north = focus_test_object_new("north", 40, 0, 20, 20);
   *east = focus_test_object_new("east", 80, 40, 20, 20);
   *west = focus_test_object_new("west", 0, 40, 20, 20);
}


Efl_Ui_Focus_Manager*
focus_test_manager_new(Efl_Ui_Focus_Object **middle, Eina_Bool is_root)
{
   Efl_Ui_Focus_Object *root;
   Efl_Ui_Focus_Manager *m;


   if (!is_root)
     {
        root = focus_test_object_new("middle", 40, 40, 20, 20);
     }
   else
     {

         root = efl_add_ref(FOCUS_MANAGER_TEST_CLASS, NULL,
          efl_name_set(efl_added, "middle")
         );
         Q(root, 40,40,20,20);
     }
   m = efl_add_ref(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
     efl_ui_focus_manager_root_set(efl_added, root)
   );

   if (middle)
     *middle = root;

   return m;
}

//Test class implementation

typedef struct {
    Eina_Rect rect;
    Eina_Bool focus;
    Eo *manager;
} Focus_Test_Data;

EOLIAN static Efl_Object*
_focus_test_efl_object_constructor(Eo *obj, Focus_Test_Data *pd)
{
   Eo *eo;

   eo = efl_constructor(efl_super(obj, FOCUS_TEST_CLASS));
   eina_rectangle_coords_from(&pd->rect.rect, 0, 0, 0, 0);
   return eo;
}

EOLIAN static void
_focus_test_efl_ui_focus_object_focus_set(Eo *obj, Focus_Test_Data *pd, Eina_Bool focus)
{
   pd->focus = focus;
#ifdef DEBUG
   printf("Object %p now focused\n", obj);
#endif
   efl_ui_focus_object_focus_set(efl_super(obj, FOCUS_TEST_CLASS), focus);
}

EOLIAN static Eina_Rect
_focus_test_efl_ui_focus_object_focus_geometry_get(const Eo *obj EINA_UNUSED, Focus_Test_Data *pd)
{
   return pd->rect;
}

EOLIAN static void
_focus_test_test_size(Eo *obj EINA_UNUSED, Focus_Test_Data *pd, Eina_Rect rect)
{
   pd->rect = rect;
}

EOLIAN static Eina_Rect
_focus_test_efl_gfx_entity_geometry_get(const Eo *obj EINA_UNUSED, Focus_Test_Data *pd)
{
   return pd->rect;
}

EOLIAN static Efl_Ui_Focus_Manager*
_focus_test_efl_ui_focus_object_focus_manager_get(const Eo *obj EINA_UNUSED, Focus_Test_Data *pd)
{
   return pd->manager;
}

EOLIAN static Efl_Ui_Focus_Object*
_focus_test_efl_ui_focus_object_focus_parent_get(const Eo *obj, Focus_Test_Data *pd EINA_UNUSED)
{
   return efl_parent_get(obj);
}

EOLIAN static void
_focus_test_manager_set(Eo *obj EINA_UNUSED, Focus_Test_Data *pd, Efl_Ui_Focus_Manager *manager)
{
  pd->manager = manager;
}


#include "focus_test.eo.c"

typedef struct {

} Focus_Manager_Test_Data;

#include "focus_manager_test.eo.c"