summaryrefslogtreecommitdiff
path: root/src/edje_external/elementary/elm_list.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/edje_external/elementary/elm_list.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/edje_external/elementary/elm_list.c')
-rw-r--r--src/edje_external/elementary/elm_list.c325
1 files changed, 325 insertions, 0 deletions
diff --git a/src/edje_external/elementary/elm_list.c b/src/edje_external/elementary/elm_list.c
new file mode 100644
index 0000000..a37a225
--- /dev/null
+++ b/src/edje_external/elementary/elm_list.c
@@ -0,0 +1,325 @@
1#include <assert.h>
2#include "private.h"
3
4typedef struct _Elm_Params_List
5{
6 Elm_Params base;
7 const char *policy_h;
8 const char *policy_v;
9 const char *mode;
10 Eina_Bool h_mode : 1;
11 Eina_Bool h_mode_exists : 1;
12 Eina_Bool multi : 1;
13 Eina_Bool multi_exists : 1;
14 Eina_Bool always_select : 1;
15 Eina_Bool always_select_exists : 1;
16} Elm_Params_List;
17
18#define CHOICE_GET(CHOICES, STR) \
19 unsigned int i; \
20 for (i = 0; i < (sizeof(CHOICES)/sizeof(CHOICES[0])); i++) \
21 if (strcmp(STR, CHOICES[i]) == 0) \
22 return i
23
24static const char *scroller_policy_choices[] = { "auto", "on", "off", NULL };
25static const char *list_mode_choices[] =
26{
27 "compress", "scroll", "limit", "expand", NULL
28};
29
30static Elm_Scroller_Policy
31_scroller_policy_choices_setting_get(const char *policy_str)
32{
33 assert(sizeof(scroller_policy_choices)/
34 sizeof(scroller_policy_choices[0]) == ELM_SCROLLER_POLICY_LAST + 1);
35 CHOICE_GET(scroller_policy_choices, policy_str);
36 return ELM_SCROLLER_POLICY_LAST;
37}
38
39static Elm_List_Mode
40_list_mode_setting_get(const char *mode_str)
41{
42 assert(sizeof(list_mode_choices)/sizeof(list_mode_choices[0]) ==
43 ELM_LIST_LAST + 1);
44 CHOICE_GET(list_mode_choices, mode_str);
45 return ELM_LIST_LAST;
46}
47
48static void
49external_list_state_set(void *data EINA_UNUSED, Evas_Object *obj,
50 const void *from_params, const void *to_params,
51 float pos EINA_UNUSED)
52{
53 const Elm_Params_List *p;
54 Elm_Scroller_Policy policy_h, policy_v;
55
56 if (to_params) p = to_params;
57 else if (from_params) p = from_params;
58 else return;
59
60 if (p->mode)
61 {
62 Elm_List_Mode set = _list_mode_setting_get(p->mode);
63
64 if (set != ELM_LIST_LAST)
65 elm_list_mode_set(obj, set);
66 }
67
68 if ((p->policy_h) && (p->policy_v))
69 {
70 policy_h = _scroller_policy_choices_setting_get(p->policy_h);
71 policy_v = _scroller_policy_choices_setting_get(p->policy_v);
72 elm_scroller_policy_set(obj, policy_h, policy_v);
73 }
74 else if ((p->policy_h) || (p->policy_v))
75 {
76 elm_scroller_policy_get(obj, &policy_h, &policy_v);
77 if (p->policy_h)
78 {
79 policy_h = _scroller_policy_choices_setting_get(p->policy_h);
80 elm_scroller_policy_set(obj, policy_h, policy_v);
81 }
82 else
83 {
84 policy_v = _scroller_policy_choices_setting_get(p->policy_v);
85 elm_scroller_policy_set(obj, policy_h, policy_v);
86 }
87 }
88
89 if (p->h_mode_exists)
90 elm_list_horizontal_set(obj, p->h_mode);
91 if (p->multi_exists)
92 elm_list_multi_select_set(obj, p->multi);
93 if (p->always_select_exists)
94 {
95 if (p->always_select)
96 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
97 else
98 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
99 }
100}
101
102static Eina_Bool
103external_list_param_set(void *data EINA_UNUSED, Evas_Object *obj,
104 const Edje_External_Param *param)
105{
106 if (!strcmp(param->name, "list mode"))
107 {
108 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
109 {
110 Elm_List_Mode set = _list_mode_setting_get(param->s);
111 if (set == ELM_LIST_LAST) return EINA_FALSE;
112 elm_list_mode_set(obj, set);
113 return EINA_TRUE;
114 }
115 }
116 else if (!strcmp(param->name, "horizontal scroll"))
117 {
118 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
119 {
120 Elm_Scroller_Policy h, v;
121 elm_scroller_policy_get(obj, &h, &v);
122 h = _scroller_policy_choices_setting_get(param->s);
123 if (h == ELM_SCROLLER_POLICY_LAST) return EINA_FALSE;
124 elm_scroller_policy_set(obj, h, v);
125 return EINA_TRUE;
126 }
127 }
128 else if (!strcmp(param->name, "vertical scroll"))
129 {
130 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
131 {
132 Elm_Scroller_Policy h, v;
133 elm_scroller_policy_get(obj, &h, &v);
134 v = _scroller_policy_choices_setting_get(param->s);
135 if (v == ELM_SCROLLER_POLICY_LAST) return EINA_FALSE;
136 elm_scroller_policy_set(obj, h, v);
137 return EINA_TRUE;
138 }
139 }
140 else if (!strcmp(param->name, "horizontal mode"))
141 {
142 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
143 {
144 elm_list_horizontal_set(obj, param->i);
145 return EINA_TRUE;
146 }
147 }
148 else if (!strcmp(param->name, "multi-select mode"))
149 {
150 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
151 {
152 elm_list_multi_select_set(obj, param->i);
153 return EINA_TRUE;
154 }
155 }
156 else if (!strcmp(param->name, "always-select mode"))
157 {
158 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
159 {
160 if (param->i)
161 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
162 else
163 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
164 return EINA_TRUE;
165 }
166 }
167
168 ERR("unknown parameter '%s' of type '%s'",
169 param->name, edje_external_param_type_str(param->type));
170
171 return EINA_FALSE;
172}
173
174static Eina_Bool
175external_list_param_get(void *data EINA_UNUSED, const Evas_Object *obj,
176 Edje_External_Param *param)
177{
178 if (!strcmp(param->name, "horizontal mode"))
179 {
180 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
181 {
182 param->i = elm_list_horizontal_get(obj);
183 return EINA_TRUE;
184 }
185 }
186 else if (!strcmp(param->name, "multi-select mode"))
187 {
188 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
189 {
190 param->i = elm_list_multi_select_get(obj);
191 return EINA_TRUE;
192 }
193 }
194 else if (!strcmp(param->name, "always-select mode"))
195 {
196 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
197 {
198 if (elm_list_select_mode_get (obj) ==
199 ELM_OBJECT_SELECT_MODE_ALWAYS)
200 param->i = EINA_TRUE;
201 else
202 param->i = EINA_FALSE;
203 return EINA_TRUE;
204 }
205 }
206 else if (!strcmp(param->name, "horizontal scroll"))
207 {
208 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
209 {
210 Elm_Scroller_Policy h, v;
211 elm_scroller_policy_get(obj, &h, &v);
212
213 param->s = scroller_policy_choices[h];
214 return EINA_TRUE;
215 }
216 }
217 else if (!strcmp(param->name, "vertical scroll"))
218 {
219 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
220 {
221 Elm_Scroller_Policy h, v;
222 elm_scroller_policy_get(obj, &h, &v);
223
224 param->s = scroller_policy_choices[v];
225 return EINA_TRUE;
226 }
227 }
228 else if (!strcmp(param->name, "list mode"))
229 {
230 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
231 {
232 Elm_List_Mode m = elm_list_mode_get(obj);
233
234 if (m == ELM_LIST_LAST)
235 return EINA_FALSE;
236
237 param->s = list_mode_choices[m];
238 return EINA_TRUE;
239 }
240 }
241
242 ERR("unknown parameter '%s' of type '%s'",
243 param->name, edje_external_param_type_str(param->type));
244
245 return EINA_FALSE;
246}
247
248static void *
249external_list_params_parse(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
250 const Eina_List *params)
251{
252 Elm_Params_List *mem;
253 Edje_External_Param *param;
254 const Eina_List *l;
255
256 mem = ELM_NEW(Elm_Params_List);
257 if (!mem)
258 return NULL;
259
260 EINA_LIST_FOREACH(params, l, param)
261 {
262 if (!strcmp(param->name, "horizontal mode"))
263 {
264 mem->h_mode = param->i;
265 mem->h_mode_exists = EINA_TRUE;
266 }
267 else if (!strcmp(param->name, "multi-select mode"))
268 {
269 mem->multi = param->i;
270 mem->multi_exists = EINA_TRUE;
271 }
272 else if (!strcmp(param->name, "always-select mode"))
273 {
274 mem->always_select = param->i;
275 mem->always_select_exists = EINA_TRUE;
276 }
277 else if (!strcmp(param->name, "horizontal scroll"))
278 mem->policy_h = eina_stringshare_add(param->s);
279 else if (!strcmp(param->name, "vertical scroll"))
280 mem->policy_v = eina_stringshare_add(param->s);
281 else if (!strcmp(param->name, "list mode"))
282 mem->mode = eina_stringshare_add(param->s);
283 }
284 return mem;
285}
286
287static Evas_Object *external_list_content_get(void *data EINA_UNUSED,
288 const Evas_Object *obj EINA_UNUSED,
289 const char *content EINA_UNUSED)
290{
291 ERR("No content.");
292 return NULL;
293}
294
295static void
296external_list_params_free(void *params)
297{
298 Elm_Params_List *mem = params;
299
300 if (mem->mode)
301 eina_stringshare_del(mem->mode);
302 if (mem->policy_h)
303 eina_stringshare_del(mem->policy_h);
304 if (mem->policy_v)
305 eina_stringshare_del(mem->policy_v);
306
307 free(mem);
308}
309
310static Edje_External_Param_Info external_list_params[] = {
311 DEFINE_EXTERNAL_COMMON_PARAMS,
312 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("list mode", "scroll",
313 list_mode_choices),
314 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("horizontal scroll", "auto",
315 scroller_policy_choices),
316 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("vertical scroll", "auto",
317 scroller_policy_choices),
318 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal mode"),
319 EDJE_EXTERNAL_PARAM_INFO_BOOL("multi-select mode"),
320 EDJE_EXTERNAL_PARAM_INFO_BOOL("always-select mode"),
321 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
322};
323
324DEFINE_EXTERNAL_ICON_ADD(list, "list");
325DEFINE_EXTERNAL_TYPE_SIMPLE(list, "List");