summaryrefslogtreecommitdiff
path: root/src/edje_externals
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-09-28 21:07:23 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-09-28 21:07:23 +0000
commiteb2540509d61dabb765a998147f3d1549983a322 (patch)
tree7e75fea6df521548e132360e9b295856719d5c6f /src/edje_externals
parent1e9b3cc77233a27a21bf9eb13fc3ebe54b2d8298 (diff)
elm: add bg external
I know some guys insinuated it's useless, since if you want to put a image in your theme you can just place a image part. But there are some cool things: - You can add a background that fits the theme (default bg theme) - You can use background options (tile, stretch...) SVN revision: 77212
Diffstat (limited to 'src/edje_externals')
-rw-r--r--src/edje_externals/Makefile.am1
-rw-r--r--src/edje_externals/elm_bg.c155
-rw-r--r--src/edje_externals/modules.inc1
3 files changed, 157 insertions, 0 deletions
diff --git a/src/edje_externals/Makefile.am b/src/edje_externals/Makefile.am
index 727ae8ba2..ee74655eb 100644
--- a/src/edje_externals/Makefile.am
+++ b/src/edje_externals/Makefile.am
@@ -36,6 +36,7 @@ module_la_SOURCES = private.h \
36modules.inc \ 36modules.inc \
37elm.c \ 37elm.c \
38elm_actionslider.c \ 38elm_actionslider.c \
39elm_bg.c \
39elm_bubble.c \ 40elm_bubble.c \
40elm_button.c \ 41elm_button.c \
41elm_calendar.c \ 42elm_calendar.c \
diff --git a/src/edje_externals/elm_bg.c b/src/edje_externals/elm_bg.c
new file mode 100644
index 000000000..084562737
--- /dev/null
+++ b/src/edje_externals/elm_bg.c
@@ -0,0 +1,155 @@
1#include <assert.h>
2#include "private.h"
3
4typedef struct _Elm_Params_Bg
5{
6 Elm_Params base;
7 const char *file;
8 const char *option;
9} Elm_Params_Bg;
10
11#define OPTION_GET(CHOICES, STR) \
12 unsigned int i; \
13 for (i = 0; i < (sizeof(CHOICES) / sizeof(CHOICES[0])); ++i) \
14 if (!strcmp(STR, CHOICES[i])) \
15 return i;
16
17static const char *_bg_options[] = {"center", "scale", "stretch", "tile", NULL};
18
19static Elm_Bg_Option
20_bg_option_get(const char *option)
21{
22 assert(sizeof(_bg_options) / sizeof(_bg_options[0])
23 == ELM_BG_OPTION_TILE + 2);
24 OPTION_GET(_bg_options, option);
25 return -1;
26}
27
28static void
29external_bg_state_set(void *data __UNUSED__, Evas_Object *obj,
30 const void *from_params, const void *to_params,
31 float pos __UNUSED__)
32{
33 const Elm_Params_Bg *p;
34 Elm_Bg_Option option;
35
36 if (to_params) p = to_params;
37 else if (from_params) p = from_params;
38 else return;
39
40 if (p->option)
41 {
42 option = _bg_option_get(p->option);
43 elm_bg_option_set(obj, option);
44 }
45 if (p->file)
46 {
47 elm_bg_file_set(obj, p->file, NULL);
48 }
49}
50
51static Eina_Bool
52external_bg_param_set(void *data __UNUSED__, Evas_Object *obj,
53 const Edje_External_Param *param)
54{
55 if ((!strcmp(param->name, "file"))
56 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
57 {
58 return elm_bg_file_set(obj, param->s, NULL);
59 }
60 else if ((!strcmp(param->name, "select_mode"))
61 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
62 {
63 Elm_Bg_Option option;
64 option = _bg_option_get(param->s);
65 elm_bg_option_set(obj, option);
66 return EINA_TRUE;
67 }
68
69 ERR("unknown parameter '%s' of type '%s'",
70 param->name, edje_external_param_type_str(param->type));
71
72 return EINA_FALSE;
73}
74
75static Eina_Bool
76external_bg_param_get(void *data __UNUSED__,
77 const Evas_Object *obj __UNUSED__,
78 Edje_External_Param *param)
79{
80 if ((!strcmp(param->name, "file"))
81 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
82 {
83 elm_bg_file_get(obj, &(param->s), NULL);
84 return EINA_TRUE;
85 }
86 else if ((!strcmp(param->name, "option"))
87 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
88 {
89 Elm_Bg_Option option;
90 option = elm_bg_option_get(obj);
91 param->s = _bg_options[option];
92 return EINA_TRUE;
93 }
94
95 ERR("unknown parameter '%s' of type '%s'",
96 param->name, edje_external_param_type_str(param->type));
97
98 return EINA_FALSE;
99}
100
101static void *
102external_bg_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
103 const Eina_List *params)
104{
105 Elm_Params_Bg *mem;
106 Edje_External_Param *param;
107 const Eina_List *l;
108
109 mem = calloc(1, sizeof(Elm_Params_Bg));
110 if (!mem)
111 return NULL;
112
113 EINA_LIST_FOREACH(params, l, param)
114 {
115 if (!strcmp(param->name, "file"))
116 mem->file = eina_stringshare_add(param->s);
117 else if (!strcmp(param->name, "option"))
118 mem->option = eina_stringshare_add(param->s);
119 }
120
121 return mem;
122}
123
124static Evas_Object *
125external_bg_content_get(void *data __UNUSED__,
126 const Evas_Object *obj __UNUSED__,
127 const char *content __UNUSED__)
128{
129 ERR("no content");
130 return NULL;
131}
132
133static void
134external_bg_params_free(void *params)
135{
136 Elm_Params_Bg *mem = params;
137
138 if (mem->file)
139 eina_stringshare_del(mem->file);
140
141 if (mem->option)
142 eina_stringshare_del(mem->option);
143
144 free(mem);
145}
146
147static Edje_External_Param_Info external_bg_params[] = {
148 DEFINE_EXTERNAL_COMMON_PARAMS,
149 EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
150 EDJE_EXTERNAL_PARAM_INFO_STRING("option"),
151 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
152};
153
154DEFINE_EXTERNAL_ICON_ADD(bg, "bg");
155DEFINE_EXTERNAL_TYPE_SIMPLE(bg, "Bg");
diff --git a/src/edje_externals/modules.inc b/src/edje_externals/modules.inc
index 81e804d50..221817bcf 100644
--- a/src/edje_externals/modules.inc
+++ b/src/edje_externals/modules.inc
@@ -1,4 +1,5 @@
1DEFINE_TYPE(actionslider) 1DEFINE_TYPE(actionslider)
2DEFINE_TYPE(bg)
2DEFINE_TYPE(bubble) 3DEFINE_TYPE(bubble)
3DEFINE_TYPE(button) 4DEFINE_TYPE(button)
4DEFINE_TYPE(calendar) 5DEFINE_TYPE(calendar)