1 #include <Elementary.h>
6 * Update the minimun height of the bar in the theme.
7 * No minimun should be set in the vertical theme
8 * Add events (move, start ...)
11 typedef struct _Widget_Data Widget_Data;
30 Eina_Bool clicked_double;
35 static const char *widtype = NULL;
36 static void _del_hook(Evas_Object *obj);
37 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
38 static void _theme_hook(Evas_Object *obj);
39 static void _sizing_eval(Evas_Object *obj);
40 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
42 static const char SIG_CLICKED[] = "clicked";
43 static const char SIG_PRESS[] = "press";
44 static const char SIG_UNPRESS[] = "unpress";
45 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
47 static const Evas_Smart_Cb_Description _signals[] = {
51 {SIG_CLICKED_DOUBLE, ""},
56 _del_hook(Evas_Object *obj)
58 Widget_Data *wd = elm_widget_data_get(obj);
64 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
66 Widget_Data *wd = elm_widget_data_get(obj);
68 edje_object_mirrored_set(wd->panes, rtl);
72 _theme_hook(Evas_Object *obj)
74 Widget_Data *wd = elm_widget_data_get(obj);
75 const char *style = elm_widget_style_get(obj);
79 _elm_widget_mirrored_reload(obj);
80 _mirrored_set(obj, elm_widget_mirrored_get(obj));
81 size = elm_panes_content_left_size_get(obj);
84 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
86 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
88 if (wd->contents.left)
89 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
90 if (wd->contents.right)
91 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
93 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
95 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
98 elm_panes_content_left_size_set(obj, size);
102 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
104 Widget_Data *wd = elm_widget_data_get(obj);
105 if (!wd) return EINA_FALSE;
108 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
109 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
110 return elm_widget_focus_next_get(wd->contents.right, dir, next);
112 Evas_Object *chain[2];
115 if (dir == ELM_FOCUS_PREVIOUS)
117 chain[0] = wd->contents.right;
118 chain[1] = wd->contents.left;
120 else if (dir == ELM_FOCUS_NEXT)
122 chain[0] = wd->contents.left;
123 chain[1] = wd->contents.right;
128 unsigned char i = elm_widget_focus_get(chain[1]);
130 if (elm_widget_focus_next_get(chain[i], dir, next))
135 Evas_Object *to_focus;
136 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
146 _sizing_eval(Evas_Object *obj)
148 Widget_Data *wd = elm_widget_data_get(obj);
153 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
159 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
161 Widget_Data *wd = elm_widget_data_get(obj);
162 Evas_Object *sub = event_info;
165 if (sub == wd->contents.left)
167 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
168 _changed_size_hints, obj);
169 wd->contents.left = NULL;
172 else if (sub == wd->contents.right)
174 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
175 _changed_size_hints, obj);
176 wd->contents.right= NULL;
183 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
185 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
189 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
191 Widget_Data *wd = elm_widget_data_get(data);
193 wd->clicked_double = EINA_TRUE;
197 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
199 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
203 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
205 Widget_Data *wd = elm_widget_data_get(data);
206 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
208 if (wd->clicked_double)
210 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
211 wd->clicked_double = EINA_FALSE;
216 _content_left_set(Evas_Object *obj, Evas_Object *content)
218 Widget_Data *wd = elm_widget_data_get(obj);
219 if (wd->contents.left)
221 evas_object_del(wd->contents.left);
222 wd->contents.left = NULL;
226 wd->contents.left = content;
227 elm_widget_sub_object_add(obj, content);
228 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
233 _content_right_set(Evas_Object *obj, Evas_Object *content)
235 Widget_Data *wd = elm_widget_data_get(obj);
236 if (wd->contents.right)
238 evas_object_del(wd->contents.right);
239 wd->contents.right = NULL;
243 wd->contents.right = content;
244 elm_widget_sub_object_add(obj, content);
245 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
250 _content_left_unset(Evas_Object *obj)
252 Widget_Data *wd = elm_widget_data_get(obj);
253 if (!wd->contents.left) return NULL;
254 Evas_Object *content = wd->contents.left;
255 elm_widget_sub_object_del(obj, content);
256 edje_object_part_unswallow(wd->panes, content);
257 wd->contents.left = NULL;
262 _content_right_unset(Evas_Object *obj)
264 Widget_Data *wd = elm_widget_data_get(obj);
265 if (!wd->contents.right) return NULL;
266 Evas_Object *content = wd->contents.right;
267 elm_widget_sub_object_del(obj, content);
268 edje_object_part_unswallow(wd->panes, content);
269 wd->contents.right = NULL;
274 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
276 ELM_CHECK_WIDTYPE(obj, widtype);
277 Widget_Data *wd = elm_widget_data_get(obj);
279 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
280 if (!part || !strcmp(part, "right"))
281 _content_right_set(obj, content);
282 else if(!strcmp(part, "left"))
283 _content_left_set(obj, content);
287 _content_get_hook(const Evas_Object *obj, const char *part)
289 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
290 Widget_Data *wd = elm_widget_data_get(obj);
291 if (!wd) return NULL;
292 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
293 if (!part || !strcmp(part, "right"))
294 return wd->contents.right;
295 else if (!strcmp(part, "left"))
296 return wd->contents.left;
301 _content_unset_hook(Evas_Object *obj, const char *part)
303 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
304 Widget_Data *wd = elm_widget_data_get(obj);
305 if (!wd) return NULL;
306 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
307 if (!part || !strcmp(part, "right"))
308 return _content_right_unset(obj);
309 else if (!strcmp(part, "left"))
310 return _content_left_unset(obj);
315 elm_panes_add(Evas_Object *parent)
321 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
323 ELM_SET_WIDTYPE(widtype, "panes");
324 elm_widget_type_set(obj, "panes");
325 elm_widget_sub_object_add(parent, obj);
326 elm_widget_data_set(obj, wd);
327 elm_widget_del_hook_set(obj, _del_hook);
328 elm_widget_theme_hook_set(obj, _theme_hook);
329 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
330 elm_widget_content_set_hook_set(obj, _content_set_hook);
331 elm_widget_content_get_hook_set(obj, _content_get_hook);
332 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
333 elm_widget_can_focus_set(obj, EINA_FALSE);
335 wd->panes = edje_object_add(e);
336 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
337 elm_widget_resize_object_set(obj, wd->panes);
338 evas_object_show(wd->panes);
340 elm_panes_content_left_size_set(obj, 0.5);
342 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
344 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
345 _clicked_double, obj);
346 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
348 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
351 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
352 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
353 _changed_size_hints, obj);
355 evas_object_smart_callbacks_descriptions_set(obj, _signals);
357 _mirrored_set(obj, elm_widget_mirrored_get(obj));
363 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
365 _content_set_hook(obj, "left", content);
369 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
371 _content_set_hook(obj, "right", content);
375 elm_panes_content_left_get(const Evas_Object *obj)
377 return _content_get_hook(obj, "left");
381 elm_panes_content_right_get(const Evas_Object *obj)
383 return _content_get_hook(obj, "right");
387 elm_panes_content_left_unset(Evas_Object *obj)
389 return _content_unset_hook(obj, "left");
393 elm_panes_content_right_unset(Evas_Object *obj)
395 return _content_unset_hook(obj, "right");
399 elm_panes_content_left_size_get(const Evas_Object *obj)
401 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
402 Widget_Data *wd = elm_widget_data_get(obj);
406 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
407 if (wd->horizontal) return h;
412 elm_panes_content_left_size_set(Evas_Object *obj, double size)
414 ELM_CHECK_WIDTYPE(obj, widtype);
415 Widget_Data *wd = elm_widget_data_get(obj);
417 if (size < 0.0) size = 0.0;
418 else if (size > 1.0) size = 1.0;
420 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
422 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
426 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
428 ELM_CHECK_WIDTYPE(obj, widtype);
429 Widget_Data *wd = elm_widget_data_get(obj);
431 wd->horizontal = horizontal;
433 elm_panes_content_left_size_set(obj, 0.5);
437 elm_panes_horizontal_get(const Evas_Object *obj)
439 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
440 Widget_Data *wd = elm_widget_data_get(obj);
441 if (!wd) return EINA_FALSE;
442 return wd->horizontal;
446 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
448 ELM_CHECK_WIDTYPE(obj, widtype);
449 Widget_Data *wd = elm_widget_data_get(obj);
452 if (wd->fixed == EINA_TRUE)
453 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
455 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
459 elm_panes_fixed_get(const Evas_Object *obj)
461 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
462 Widget_Data *wd = elm_widget_data_get(obj);
463 if (!wd) return EINA_FALSE;