aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/evas/src/lib/canvas/common_interfaces.c
blob: 0246138f34c4f923c4478fa17e59ed26bb0b10bb (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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#include "evas_common.h"
#include "evas_private.h"

#include "Eo.h"

Eina_Hash* signals_hash_table = NULL;

EAPI const Eo_Event_Description _CLICKED_EVENT =
   EO_EVENT_DESCRIPTION("clicked", "");

EAPI const Eo_Event_Description _CLICKED_DOUBLE_EVENT =
   EO_EVENT_DESCRIPTION("clicked,double", "");

EAPI const Eo_Event_Description _CLICKED_TRIPLE_EVENT =
   EO_EVENT_DESCRIPTION("clicked,triple", "");

EAPI const Eo_Event_Description _PRESSED_EVENT =
   EO_EVENT_DESCRIPTION("pressed", "");

EAPI const Eo_Event_Description _UNPRESSED_EVENT =
   EO_EVENT_DESCRIPTION("unpressed", "");

EAPI const Eo_Event_Description _LONGPRESSED_EVENT =
   EO_EVENT_DESCRIPTION("longpressed", "");

EAPI const Eo_Event_Description _REPEATED_EVENT =
   EO_EVENT_DESCRIPTION("repeated", "");

EAPI const Eo_Event_Description _SCROLL_EVENT =
   EO_EVENT_DESCRIPTION("scroll", "");

EAPI const Eo_Event_Description _SCROLL_ANIM_START_EVENT =
   EO_EVENT_DESCRIPTION("scroll,anim,start", "");

EAPI const Eo_Event_Description _SCROLL_ANIM_STOP_EVENT =
   EO_EVENT_DESCRIPTION("scroll,anim,stop", "");

EAPI const Eo_Event_Description _SCROLL_DRAG_START_EVENT =
   EO_EVENT_DESCRIPTION("scroll,drag,start", "");

EAPI const Eo_Event_Description _SCROLL_DRAG_STOP_EVENT =
   EO_EVENT_DESCRIPTION("scroll,drag,stop", "");

EAPI const Eo_Event_Description _ZOOM_START_EVENT =
   EO_EVENT_DESCRIPTION("zoom,start", "");

EAPI const Eo_Event_Description _ZOOM_STOP_EVENT =
   EO_EVENT_DESCRIPTION("zoom,stop", "");

EAPI const Eo_Event_Description _ZOOM_CHANGE_EVENT =
   EO_EVENT_DESCRIPTION("zoom,changed", "");

EAPI const Eo_Event_Description _SELECTED_EVENT =
   EO_EVENT_DESCRIPTION("selected", "");

EAPI const Eo_Event_Description _UNSELECTED_EVENT =
   EO_EVENT_DESCRIPTION("unselected", "");

EAPI const Eo_Event_Description _SELECTION_PASTE_EVENT =
   EO_EVENT_DESCRIPTION("selection,paste", "");

EAPI const Eo_Event_Description _SELECTION_COPY_EVENT =
   EO_EVENT_DESCRIPTION("selection,copy", "");

EAPI const Eo_Event_Description _SELECTION_CUT_EVENT =
   EO_EVENT_DESCRIPTION("selection,cut", "");

EAPI const Eo_Event_Description _SELECTION_START_EVENT =
   EO_EVENT_DESCRIPTION("selection,start", "");

EAPI const Eo_Event_Description _SELECTION_CHANGED_EVENT =
   EO_EVENT_DESCRIPTION("selection,changed", "");

EAPI const Eo_Event_Description _SELECTION_CLEARED_EVENT =
   EO_EVENT_DESCRIPTION("selection,cleared", "");

EAPI const Eo_Event_Description _DRAG_EVENT =
   EO_EVENT_DESCRIPTION("drag", "");

EAPI const Eo_Event_Description _DRAG_START_EVENT =
   EO_EVENT_DESCRIPTION("drag,start", "");

EAPI const Eo_Event_Description _DRAG_STOP_EVENT =
   EO_EVENT_DESCRIPTION("drag,stop", "");

EAPI const Eo_Event_Description _DRAG_END_EVENT =
   EO_EVENT_DESCRIPTION("drag,end", "");

EAPI const Eo_Event_Description _DRAG_START_UP_EVENT =
   EO_EVENT_DESCRIPTION("drag,start,up", "");

EAPI const Eo_Event_Description _DRAG_START_DOWN_EVENT =
   EO_EVENT_DESCRIPTION("drag,start,down", "");

EAPI const Eo_Event_Description _DRAG_START_RIGHT_EVENT =
   EO_EVENT_DESCRIPTION("drag,start,right", "");

EAPI const Eo_Event_Description _DRAG_START_LEFT_EVENT =
   EO_EVENT_DESCRIPTION("drag,start,left", "");

static const Eo_Event_Description *_clickable_events_desc[] = {
     EVAS_SMART_CLICKED_EVENT,
     EVAS_SMART_CLICKED_DOUBLE_EVENT,
     EVAS_SMART_CLICKED_TRIPLE_EVENT,
     EVAS_SMART_PRESSED_EVENT,
     EVAS_SMART_UNPRESSED_EVENT,
     EVAS_SMART_LONGPRESSED_EVENT,
     EVAS_SMART_REPEATED_EVENT,
     NULL
};

static const Eo_Event_Description *_scrollable_events_desc[] = {
     EVAS_SMART_SCROLL_EVENT,
     EVAS_SMART_SCROLL_ANIM_START_EVENT,
     EVAS_SMART_SCROLL_ANIM_STOP_EVENT,
     EVAS_SMART_SCROLL_DRAG_START_EVENT,
     EVAS_SMART_SCROLL_DRAG_STOP_EVENT,
     NULL
};

static const Eo_Event_Description *_zoomable_events_desc[] = {
     EVAS_SMART_ZOOM_START_EVENT,
     EVAS_SMART_ZOOM_STOP_EVENT,
     EVAS_SMART_ZOOM_CHANGE_EVENT,
     NULL
};

static const Eo_Event_Description *_selectable_events_desc[] = {
     EVAS_SMART_SELECTED_EVENT,
     EVAS_SMART_UNSELECTED_EVENT,
     EVAS_SMART_SELECTION_PASTE_EVENT,
     EVAS_SMART_SELECTION_COPY_EVENT,
     EVAS_SMART_SELECTION_CUT_EVENT,
     EVAS_SMART_SELECTION_START_EVENT,
     EVAS_SMART_SELECTION_CHANGED_EVENT,
     EVAS_SMART_SELECTION_CLEARED_EVENT,
     NULL
};

static const Eo_Event_Description *_draggable_events_desc[] = {
     EVAS_SMART_DRAG_EVENT,
     EVAS_SMART_DRAG_START_EVENT,
     EVAS_SMART_DRAG_STOP_EVENT,
     EVAS_SMART_DRAG_END_EVENT,
     EVAS_SMART_DRAG_START_UP_EVENT,
     EVAS_SMART_DRAG_START_DOWN_EVENT,
     EVAS_SMART_DRAG_START_RIGHT_EVENT,
     EVAS_SMART_DRAG_START_LEFT_EVENT,
     NULL
};

#define ADD_SIGNAL(name, event) eina_hash_add(signals_hash_table, name, event)
#define ADD_INTERFACE_SIGNALS(events_desc) \
   do \
   { \
      int i = 0; \
      while (events_desc[i]) { \
           _Evas_Event_Description *desc = calloc(1, sizeof(*desc)); \
           desc->eo_desc = (Eo_Event_Description *)events_desc[i];                           \
           desc->is_desc_allocated = EINA_FALSE;                     \
           ADD_SIGNAL(events_desc[i]->name, desc);                   \
           i++; \
      } \
   } \
   while (0);

static void
_signal_interface_del(void *data)
{
   _Evas_Event_Description *desc = data;
   if (desc->is_desc_allocated) free(desc->eo_desc);
   free(desc);
}

static void
_signal_interface_constructor(Eo_Class *klass EINA_UNUSED)
{
   signals_hash_table = eina_hash_string_superfast_new(_signal_interface_del);
   ADD_INTERFACE_SIGNALS(_clickable_events_desc);
   ADD_INTERFACE_SIGNALS(_scrollable_events_desc);
   ADD_INTERFACE_SIGNALS(_zoomable_events_desc);
   ADD_INTERFACE_SIGNALS(_selectable_events_desc);
   ADD_INTERFACE_SIGNALS(_draggable_events_desc);
}
#undef ADD_INTERFACE_SIGNALS
#undef ADD_SIGNAL

static void
_signal_interface_destructor(Eo_Class *klass EINA_UNUSED)
{
   eina_hash_free(signals_hash_table);
}

static const Eo_Class_Description signal_interface_desc = {
     EO_VERSION,
     "Signal_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     NULL,
     0,
     _signal_interface_constructor,
     _signal_interface_destructor
};

EO_DEFINE_CLASS(evas_smart_signal_interface_get, &signal_interface_desc, NULL, NULL);

static const Eo_Class_Description clickable_interface_desc = {
     EO_VERSION,
     "Clickable_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     _clickable_events_desc,
     0,
     NULL,
     NULL
};

EO_DEFINE_CLASS(evas_smart_clickable_interface_get, &clickable_interface_desc, EVAS_SMART_SIGNAL_INTERFACE, NULL);

static const Eo_Class_Description scrollable_interface_desc = {
     EO_VERSION,
     "Scrollable_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     _scrollable_events_desc,
     0,
     NULL,
     NULL
};

EO_DEFINE_CLASS(evas_smart_scrollable_interface_get, &scrollable_interface_desc, EVAS_SMART_SIGNAL_INTERFACE, NULL);

static const Eo_Class_Description zoomable_interface_desc = {
     EO_VERSION,
     "Zoomable_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     _zoomable_events_desc,
     0,
     NULL,
     NULL
};

EO_DEFINE_CLASS(evas_smart_zoomable_interface_get, &zoomable_interface_desc, EVAS_SMART_SIGNAL_INTERFACE, NULL);

static const Eo_Class_Description selectable_interface_desc = {
     EO_VERSION,
     "Selectable_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     _selectable_events_desc,
     0,
     NULL,
     NULL
};

EO_DEFINE_CLASS(evas_smart_selectable_interface_get, &selectable_interface_desc, EVAS_SMART_SIGNAL_INTERFACE, NULL);

static const Eo_Class_Description draggable_interface_desc = {
     EO_VERSION,
     "Draggable_Interface",
     EO_CLASS_TYPE_INTERFACE,
     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
     _draggable_events_desc,
     0,
     NULL,
     NULL
};

EO_DEFINE_CLASS(evas_smart_draggable_interface_get, &draggable_interface_desc, EVAS_SMART_SIGNAL_INTERFACE, NULL);