summaryrefslogtreecommitdiff
path: root/src/tests/elementary/elm_test_focus_common.c
blob: 896d86dd54bf2fd30289cd250aae441e0b6f7a6e (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
#include "elm_test_focus_common.h"

#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*
elm_focus_test_object_new(const char *name, int x, int y, int w, int h)
{
   Efl_Ui_Focus_Object *ret;

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

   return ret;
}

void
elm_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 = elm_focus_test_object_new("middle", 40, 40, 20, 20);
   *south = elm_focus_test_object_new("south", 40, 80, 20, 20);
   *north = elm_focus_test_object_new("north", 40, 0, 20, 20);
   *east = elm_focus_test_object_new("east", 80, 40, 20, 20);
   *west = elm_focus_test_object_new("west", 0, 40, 20, 20);
}


Efl_Ui_Focus_Manager*
elm_focus_test_manager_new(Efl_Ui_Focus_Object **middle)
{
   Efl_Ui_Focus_Object *root;
   Efl_Ui_Focus_Manager *m;

   root = elm_focus_test_object_new("middle", 40, 40, 20, 20);
   m = efl_add(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;
} 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;
   printf("Object %p now focused\n", obj);
}

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

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

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


#include "focus_test.eo.c"