summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/edje_externals/elm_icon.c
diff options
context:
space:
mode:
author윤정현 <jh0506.yun@samsung.com>2011-10-11 02:06:21 +0000
committerMike McCormack <mikem@ring3k.org>2011-10-11 02:06:21 +0000
commita2aefee16fcd114b963768f43fe4533c3d88c00c (patch)
tree5cca81ed5f8b5c538552c7f98a5364288bb4e162 /legacy/elementary/src/edje_externals/elm_icon.c
parent7aa4684ab19e1ec20b57bf2ea4699b43053be64c (diff)
elementary: Add more icon parameters in edje
Signed-off-by: 윤정현 <jh0506.yun@samsung.com> Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> SVN revision: 63970
Diffstat (limited to 'legacy/elementary/src/edje_externals/elm_icon.c')
-rw-r--r--legacy/elementary/src/edje_externals/elm_icon.c228
1 files changed, 217 insertions, 11 deletions
diff --git a/legacy/elementary/src/edje_externals/elm_icon.c b/legacy/elementary/src/edje_externals/elm_icon.c
index 0c7556a..3d2ca29 100644
--- a/legacy/elementary/src/edje_externals/elm_icon.c
+++ b/legacy/elementary/src/edje_externals/elm_icon.c
@@ -1,13 +1,31 @@
1#include <assert.h>
1#include "private.h" 2#include "private.h"
2 3
3typedef struct _Elm_Params_Icon 4typedef struct _Elm_Params_Icon
4{ 5{
6 const char *file;
7 Eina_Bool scale_up_exists;
8 Eina_Bool scale_up : 1;
9 Eina_Bool scale_down_exists;
10 Eina_Bool scale_down : 1;
11 Eina_Bool smooth_exists;
12 Eina_Bool smooth : 1;
13 Eina_Bool fill_outside_exists;
14 Eina_Bool fill_outside : 1;
15 Eina_Bool no_scale_exists;
16 Eina_Bool no_scale : 1;
17 Eina_Bool prescale_size_exists;
18 int prescale_size;
5 Elm_Params base; 19 Elm_Params base;
6 const char *icon; 20 const char *icon;
7} Elm_Params_Icon; 21} Elm_Params_Icon;
8 22
23static Elm_Params_Icon *param_icon;
24
9static void 25static void
10external_icon_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) 26external_icon_state_set(void *data __UNUSED__, Evas_Object *obj,
27 const void *from_params, const void *to_params,
28 float pos __UNUSED__)
11{ 29{
12 const Elm_Params_Icon *p; 30 const Elm_Params_Icon *p;
13 Evas_Object *edje; 31 Evas_Object *edje;
@@ -17,6 +35,50 @@ external_icon_state_set(void *data __UNUSED__, Evas_Object *obj, const void *fro
17 else if (from_params) p = from_params; 35 else if (from_params) p = from_params;
18 else return; 36 else return;
19 37
38 if (p->file)
39 {
40 elm_icon_file_set(obj, p->file, NULL);
41 param_icon->file = p->file;
42 }
43 if (p->smooth_exists)
44 {
45 elm_icon_smooth_set(obj, p->smooth);
46 param_icon->smooth = p->smooth;
47 }
48 if (p->no_scale_exists)
49 {
50 elm_icon_no_scale_set(obj, p->no_scale);
51 param_icon->no_scale = p->no_scale;
52 }
53 if (p->scale_up_exists && p->scale_down_exists)
54 {
55 elm_icon_scale_set(obj, p->scale_up, p->scale_down);
56 param_icon->scale_up = p->scale_up;
57 param_icon->scale_down = p->scale_down;
58 }
59 else if (p->scale_up_exists || p->scale_down_exists)
60 {
61 if (p->scale_up_exists)
62 {
63 elm_icon_scale_set(obj, p->scale_up, param_icon->scale_down);
64 param_icon->scale_up = p->scale_up;
65 }
66 else
67 {
68 elm_icon_scale_set(obj, param_icon->scale_up, p->scale_down);
69 param_icon->scale_down = p->scale_down;
70 }
71 }
72 if (p->fill_outside_exists)
73 {
74 elm_icon_fill_outside_set(obj, p->fill_outside);
75 param_icon->fill_outside = p->fill_outside;
76 }
77 if (p->prescale_size_exists)
78 {
79 elm_icon_prescale_set(obj, p->prescale_size);
80 param_icon->prescale_size = p->prescale_size;
81 }
20 if (p->icon) 82 if (p->icon)
21 { 83 {
22 edje = evas_object_smart_parent_get(obj); 84 edje = evas_object_smart_parent_get(obj);
@@ -28,12 +90,63 @@ external_icon_state_set(void *data __UNUSED__, Evas_Object *obj, const void *fro
28} 90}
29 91
30static Eina_Bool 92static Eina_Bool
31external_icon_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) 93external_icon_param_set(void *data __UNUSED__, Evas_Object *obj,
94 const Edje_External_Param *param)
32{ 95{
33 Evas_Object *edje; 96 Evas_Object *edje;
34 const char *file; 97 const char *file;
35 98
36 if (!strcmp(param->name, "icon")) 99 if (!strcmp(param->name, "file")
100 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
101 {
102 Eina_Bool ret = elm_icon_file_set(obj, param->s, NULL);
103 if (ret)
104 param_icon->file = param->s;
105 return ret;
106 }
107 else if (!strcmp(param->name, "smooth")
108 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
109 {
110 elm_icon_smooth_set(obj, param->i);
111 param_icon->smooth = param->i;
112 return EINA_TRUE;
113 }
114 else if (!strcmp(param->name, "no scale")
115 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
116 {
117 elm_icon_no_scale_set(obj, param->i);
118 param_icon->no_scale = param->i;
119 return EINA_TRUE;
120 }
121 else if (!strcmp(param->name, "scale up")
122 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
123 {
124 elm_icon_scale_set(obj, param->i, param_icon->scale_down);
125 param_icon->scale_up = param->i;
126 return EINA_TRUE;
127 }
128 else if (!strcmp(param->name, "scale down")
129 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
130 {
131 elm_icon_scale_set(obj, param_icon->scale_up, param->i);
132 param_icon->scale_down = param->i;
133 return EINA_TRUE;
134 }
135 else if (!strcmp(param->name, "fill outside")
136 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
137 {
138 elm_icon_fill_outside_set(obj, param->i);
139 param_icon->fill_outside = param->i;
140 return EINA_TRUE;
141 }
142 else if (!strcmp(param->name, "prescale")
143 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
144 {
145 elm_icon_prescale_set(obj, param->i);
146 param_icon->prescale_size = param->i;
147 return EINA_TRUE;
148 }
149 else if (!strcmp(param->name, "icon"))
37 { 150 {
38 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) 151 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
39 { 152 {
@@ -53,9 +166,53 @@ external_icon_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Exte
53} 166}
54 167
55static Eina_Bool 168static Eina_Bool
56external_icon_param_get(void *data __UNUSED__, const Evas_Object *obj __UNUSED__, Edje_External_Param *param) 169external_icon_param_get(void *data __UNUSED__,
170 const Evas_Object *obj __UNUSED__,
171 Edje_External_Param *param)
57{ 172{
58 if (!strcmp(param->name, "icon")) 173 if (!strcmp(param->name, "file")
174 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
175 {
176 param->s = param_icon->file;
177 return EINA_TRUE;
178 }
179 else if (!strcmp(param->name, "smooth")
180 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
181 {
182 param->i = param_icon->smooth;
183 return EINA_TRUE;
184 }
185 else if (!strcmp(param->name, "no scale")
186 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
187 {
188 param->i = param_icon->no_scale;
189 return EINA_TRUE;
190 }
191 else if (!strcmp(param->name, "scale up")
192 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
193 {
194 param->i = param_icon->scale_up;
195 return EINA_TRUE;
196 }
197 else if (!strcmp(param->name, "scale down")
198 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
199 {
200 param->i = param_icon->scale_down;
201 return EINA_TRUE;
202 }
203 else if (!strcmp(param->name, "fill outside")
204 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
205 {
206 param->i = param_icon->fill_outside;
207 return EINA_TRUE;
208 }
209 else if (!strcmp(param->name, "prescale")
210 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
211 {
212 param->i = param_icon->prescale_size;
213 return EINA_TRUE;
214 }
215 else if (!strcmp(param->name, "icon"))
59 { 216 {
60 /* not easy to get icon name back from live object */ 217 /* not easy to get icon name back from live object */
61 return EINA_FALSE; 218 return EINA_FALSE;
@@ -68,19 +225,52 @@ external_icon_param_get(void *data __UNUSED__, const Evas_Object *obj __UNUSED__
68} 225}
69 226
70static void * 227static void *
71external_icon_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) 228external_icon_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
229 const Eina_List *params)
72{ 230{
73 Elm_Params_Icon *mem; 231 Elm_Params_Icon *mem;
74 Edje_External_Param *param; 232 Edje_External_Param *param;
75 const Eina_List *l; 233 const Eina_List *l;
76 234 param_icon = calloc(1, sizeof(Elm_Params_Icon));
77 mem = ELM_NEW(Elm_Params_Icon); 235 mem = ELM_NEW(Elm_Params_Icon);
78 if (!mem) 236 if (!mem)
79 return NULL; 237 return NULL;
80 238
81 EINA_LIST_FOREACH(params, l, param) 239 EINA_LIST_FOREACH(params, l, param)
82 { 240 {
83 if (!strcmp(param->name, "icon")) 241 if (!strcmp(param->name, "file"))
242 mem->file = eina_stringshare_add(param->s);
243 else if (!strcmp(param->name, "smooth"))
244 {
245 mem->smooth = param->i;
246 mem->smooth_exists = EINA_TRUE;
247 }
248 else if (!strcmp(param->name, "no scale"))
249 {
250 mem->no_scale = param->i;
251 mem->no_scale_exists = EINA_TRUE;
252 }
253 else if (!strcmp(param->name, "scale up"))
254 {
255 mem->scale_up = param->i;
256 mem->scale_up_exists = EINA_TRUE;
257 }
258 else if (!strcmp(param->name, "scale down"))
259 {
260 mem->scale_down = param->i;
261 mem->scale_down_exists = EINA_TRUE;
262 }
263 else if (!strcmp(param->name, "fill outside"))
264 {
265 mem->fill_outside = param->i;
266 mem->fill_outside_exists = EINA_TRUE;
267 }
268 else if (!strcmp(param->name, "prescale"))
269 {
270 mem->prescale_size = param->i;
271 mem->prescale_size_exists = EINA_TRUE;
272 }
273 else if (!strcmp(param->name, "icon"))
84 { 274 {
85 mem->icon = eina_stringshare_add(param->s); 275 mem->icon = eina_stringshare_add(param->s);
86 } 276 }
@@ -89,8 +279,10 @@ external_icon_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, c
89 return mem; 279 return mem;
90} 280}
91 281
92static Evas_Object *external_icon_content_get(void *data __UNUSED__, 282static Evas_Object *
93 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__) 283external_icon_content_get(void *data __UNUSED__,
284 const Evas_Object *obj __UNUSED__,
285 const char *content __UNUSED__)
94{ 286{
95 ERR("no content"); 287 ERR("no content");
96 return NULL; 288 return NULL;
@@ -101,14 +293,28 @@ external_icon_params_free(void *params)
101{ 293{
102 Elm_Params_Icon *mem = params; 294 Elm_Params_Icon *mem = params;
103 295
296 if (mem->file)
297 eina_stringshare_del(mem->file);
298
299 if (param_icon->file)
300 eina_stringshare_del(param_icon->file);
301 free(param_icon);
302
104 if (mem->icon) 303 if (mem->icon)
105 eina_stringshare_del(mem->icon); 304 eina_stringshare_del(mem->icon);
106 external_common_params_free(params); 305 free(mem);
107} 306}
108 307
109static Edje_External_Param_Info external_icon_params[] = { 308static Edje_External_Param_Info external_icon_params[] = {
110 DEFINE_EXTERNAL_COMMON_PARAMS, 309 DEFINE_EXTERNAL_COMMON_PARAMS,
111 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"), 310 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
311 EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
312 EDJE_EXTERNAL_PARAM_INFO_BOOL("smooth"),
313 EDJE_EXTERNAL_PARAM_INFO_BOOL("no scale"),
314 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale up"),
315 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale down"),
316 EDJE_EXTERNAL_PARAM_INFO_BOOL("fill outside"),
317 EDJE_EXTERNAL_PARAM_INFO_INT("prescale"),
112 EDJE_EXTERNAL_PARAM_INFO_SENTINEL 318 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
113}; 319};
114 320