diff options
Diffstat (limited to 'libraries/elementary/src/edje_externals/elm_panes.c')
-rw-r--r-- | libraries/elementary/src/edje_externals/elm_panes.c | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/libraries/elementary/src/edje_externals/elm_panes.c b/libraries/elementary/src/edje_externals/elm_panes.c new file mode 100644 index 0000000..3b96303 --- /dev/null +++ b/libraries/elementary/src/edje_externals/elm_panes.c | |||
@@ -0,0 +1,198 @@ | |||
1 | #include "private.h" | ||
2 | #include <assert.h> | ||
3 | |||
4 | |||
5 | typedef struct _Elm_Params_Panes Elm_Params_Panes; | ||
6 | |||
7 | struct _Elm_Params_Panes { | ||
8 | Elm_Params base; | ||
9 | Evas_Object *content_left; | ||
10 | Evas_Object *content_right; | ||
11 | Eina_Bool is_horizontal; | ||
12 | Eina_Bool horizontal; | ||
13 | Eina_Bool is_left_size; | ||
14 | double left_size; | ||
15 | Eina_Bool is_fixed; | ||
16 | Eina_Bool fixed; | ||
17 | }; | ||
18 | |||
19 | static void external_panes_state_set(void *data __UNUSED__, | ||
20 | Evas_Object *obj, const void *from_params, | ||
21 | const void *to_params, float pos __UNUSED__) | ||
22 | { | ||
23 | const Elm_Params_Panes *p; | ||
24 | |||
25 | if (to_params) p = to_params; | ||
26 | else if (from_params) p = from_params; | ||
27 | else return; | ||
28 | |||
29 | if (p->content_left) | ||
30 | elm_object_part_content_set(obj, "left", p->content_left); | ||
31 | |||
32 | if (p->content_right) | ||
33 | elm_object_part_content_set(obj, "right", p->content_right); | ||
34 | |||
35 | if (p->is_left_size) | ||
36 | elm_panes_content_left_size_set(obj, p->left_size); | ||
37 | |||
38 | if (p->is_horizontal) | ||
39 | elm_panes_horizontal_set(obj, p->horizontal); | ||
40 | |||
41 | if (p->is_fixed) | ||
42 | elm_panes_fixed_set(obj, p->fixed); | ||
43 | } | ||
44 | |||
45 | static Eina_Bool external_panes_param_set(void *data __UNUSED__, | ||
46 | Evas_Object *obj, const Edje_External_Param *param) | ||
47 | { | ||
48 | if ((!strcmp(param->name, "content left")) | ||
49 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)) | ||
50 | { | ||
51 | Evas_Object *content = external_common_param_edje_object_get(obj, param); | ||
52 | if ((strcmp(param->s, "")) && (!content)) | ||
53 | return EINA_FALSE; | ||
54 | elm_object_part_content_set(obj, "left", content); | ||
55 | return EINA_TRUE; | ||
56 | } | ||
57 | else if ((!strcmp(param->name, "content right")) | ||
58 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)) | ||
59 | { | ||
60 | Evas_Object *content = external_common_param_edje_object_get(obj, param); | ||
61 | if ((strcmp(param->s, "")) && (!content)) | ||
62 | return EINA_FALSE; | ||
63 | elm_object_part_content_set(obj, "right", content); | ||
64 | return EINA_TRUE; | ||
65 | } | ||
66 | else if ((!strcmp(param->name, "horizontal")) | ||
67 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) | ||
68 | { | ||
69 | elm_panes_horizontal_set(obj, param->i); | ||
70 | return EINA_TRUE; | ||
71 | } | ||
72 | else if ((!strcmp(param->name, "left size")) | ||
73 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)) | ||
74 | { | ||
75 | elm_panes_content_left_size_set(obj, param->d); | ||
76 | return EINA_TRUE; | ||
77 | } | ||
78 | else if ((!strcmp(param->name, "fixed")) | ||
79 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) | ||
80 | { | ||
81 | elm_panes_fixed_set(obj, param->i); | ||
82 | return EINA_TRUE; | ||
83 | } | ||
84 | |||
85 | ERR("unknown parameter '%s' of type '%s'", | ||
86 | param->name, edje_external_param_type_str(param->type)); | ||
87 | |||
88 | return EINA_FALSE; | ||
89 | } | ||
90 | |||
91 | static Eina_Bool | ||
92 | external_panes_param_get(void *data __UNUSED__, const Evas_Object *obj, | ||
93 | Edje_External_Param *param) | ||
94 | { | ||
95 | if (!strcmp(param->name, "content left")) | ||
96 | { | ||
97 | /* not easy to get content name back from live object */ | ||
98 | return EINA_FALSE; | ||
99 | } | ||
100 | else if (!strcmp(param->name, "content right")) | ||
101 | { | ||
102 | /* not easy to get content name back from live object */ | ||
103 | return EINA_FALSE; | ||
104 | } | ||
105 | else if ((!strcmp(param->name, "horizontal")) | ||
106 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) | ||
107 | { | ||
108 | param->i = elm_panes_horizontal_get(obj); | ||
109 | return EINA_TRUE; | ||
110 | } | ||
111 | else if ((!strcmp(param->name, "left size")) | ||
112 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)) | ||
113 | { | ||
114 | param->d = elm_panes_content_left_size_get(obj); | ||
115 | return EINA_TRUE; | ||
116 | } | ||
117 | else if ((!strcmp(param->name, "fixed")) | ||
118 | && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) | ||
119 | { | ||
120 | param->i = elm_panes_fixed_get(obj); | ||
121 | return EINA_TRUE; | ||
122 | } | ||
123 | |||
124 | ERR("unknown parameter '%s' of type '%s'", | ||
125 | param->name, edje_external_param_type_str(param->type)); | ||
126 | |||
127 | return EINA_FALSE; | ||
128 | } | ||
129 | |||
130 | static void * | ||
131 | external_panes_params_parse(void *data __UNUSED__, Evas_Object *obj, | ||
132 | const Eina_List *params) | ||
133 | { | ||
134 | Elm_Params_Panes *mem; | ||
135 | Edje_External_Param *param; | ||
136 | const Eina_List *l; | ||
137 | |||
138 | mem = calloc(1, sizeof(Elm_Params_Panes)); | ||
139 | if (!mem) | ||
140 | return NULL; | ||
141 | |||
142 | EINA_LIST_FOREACH(params, l, param) | ||
143 | { | ||
144 | if (!strcmp(param->name, "content left")) | ||
145 | mem->content_left = external_common_param_edje_object_get(obj, param); | ||
146 | else if (!strcmp(param->name, "content right")) | ||
147 | mem->content_right = external_common_param_edje_object_get(obj, param); | ||
148 | else if (!strcmp(param->name, "horizontal")) | ||
149 | { | ||
150 | mem->is_horizontal = EINA_TRUE; | ||
151 | mem->horizontal = param->i; | ||
152 | } | ||
153 | else if (!strcmp(param->name, "left size")) | ||
154 | { | ||
155 | mem->is_left_size = EINA_TRUE; | ||
156 | mem->left_size = param->d; | ||
157 | } | ||
158 | else if (!strcmp(param->name, "fixed")) | ||
159 | { | ||
160 | mem->is_fixed = EINA_TRUE; | ||
161 | mem->fixed = param->i; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | return mem; | ||
166 | } | ||
167 | |||
168 | static Evas_Object * | ||
169 | external_panes_content_get(void *data __UNUSED__, const Evas_Object *obj, | ||
170 | const char *content) | ||
171 | { | ||
172 | if (!strcmp(content, "left")) | ||
173 | return elm_object_part_content_get(obj, "left"); | ||
174 | else if (!strcmp(content, "right")) | ||
175 | return elm_object_part_content_get(obj, "right"); | ||
176 | |||
177 | ERR("unknown content '%s'", content); | ||
178 | |||
179 | return NULL; | ||
180 | } | ||
181 | |||
182 | static void external_panes_params_free(void *params) | ||
183 | { | ||
184 | free(params); | ||
185 | } | ||
186 | |||
187 | static Edje_External_Param_Info external_panes_params[] = { | ||
188 | DEFINE_EXTERNAL_COMMON_PARAMS, | ||
189 | EDJE_EXTERNAL_PARAM_INFO_STRING("content left"), | ||
190 | EDJE_EXTERNAL_PARAM_INFO_STRING("content right"), | ||
191 | EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"), | ||
192 | EDJE_EXTERNAL_PARAM_INFO_DOUBLE("left size"), | ||
193 | EDJE_EXTERNAL_PARAM_INFO_BOOL("fixed"), | ||
194 | EDJE_EXTERNAL_PARAM_INFO_SENTINEL | ||
195 | }; | ||
196 | |||
197 | DEFINE_EXTERNAL_ICON_ADD(panes, "panes"); | ||
198 | DEFINE_EXTERNAL_TYPE_SIMPLE(panes, "panes"); | ||