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);
92 if(wd->contents.left && wd->contents.right)
93 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
95 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
97 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
100 elm_panes_content_left_size_set(obj, size);
104 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
106 Widget_Data *wd = elm_widget_data_get(obj);
112 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
113 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
114 return elm_widget_focus_next_get(wd->contents.right, dir, next);
116 Evas_Object *chain[2];
119 if (dir == ELM_FOCUS_PREVIOUS)
121 chain[0] = wd->contents.right;
122 chain[1] = wd->contents.left;
124 else if (dir == ELM_FOCUS_NEXT)
126 chain[0] = wd->contents.left;
127 chain[1] = wd->contents.right;
132 unsigned char i = elm_widget_focus_get(chain[1]);
134 if (elm_widget_focus_next_get(chain[i], dir, next))
139 Evas_Object *to_focus;
140 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
150 _sizing_eval(Evas_Object *obj)
152 Widget_Data *wd = elm_widget_data_get(obj);
157 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
163 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
165 Widget_Data *wd = elm_widget_data_get(obj);
166 Evas_Object *sub = event_info;
169 if (sub == wd->contents.left)
171 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
172 _changed_size_hints, obj);
173 wd->contents.left = NULL;
176 else if (sub == wd->contents.right)
178 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
179 _changed_size_hints, obj);
180 wd->contents.right= NULL;
186 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
188 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
192 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
194 Widget_Data *wd = elm_widget_data_get(data);
196 wd->clicked_double = EINA_TRUE;
200 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
202 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
206 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
208 Widget_Data *wd = elm_widget_data_get(data);
209 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
211 if (wd->clicked_double)
213 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
214 wd->clicked_double = EINA_FALSE;
219 _content_left_set(Evas_Object *obj, Evas_Object *content)
221 Widget_Data *wd = elm_widget_data_get(obj);
222 if (wd->contents.left)
224 evas_object_del(wd->contents.left);
225 wd->contents.left = NULL;
226 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
230 wd->contents.left = content;
231 elm_widget_sub_object_add(obj, content);
232 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
233 if (wd->contents.right)
234 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
239 _content_right_set(Evas_Object *obj, Evas_Object *content)
241 Widget_Data *wd = elm_widget_data_get(obj);
242 if (wd->contents.right)
244 evas_object_del(wd->contents.right);
245 wd->contents.right = NULL;
246 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
250 wd->contents.right = content;
251 elm_widget_sub_object_add(obj, content);
252 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
253 if (wd->contents.left)
254 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
259 _content_left_unset(Evas_Object *obj)
261 Widget_Data *wd = elm_widget_data_get(obj);
262 if (!wd->contents.left) return NULL;
263 Evas_Object *content = wd->contents.left;
264 elm_widget_sub_object_del(obj, content);
265 edje_object_part_unswallow(wd->panes, content);
266 evas_object_hide(content);
267 wd->contents.left = NULL;
268 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
273 _content_right_unset(Evas_Object *obj)
275 Widget_Data *wd = elm_widget_data_get(obj);
276 if (!wd->contents.right) return NULL;
277 Evas_Object *content = wd->contents.right;
278 elm_widget_sub_object_del(obj, content);
279 edje_object_part_unswallow(wd->panes, content);
280 evas_object_hide(content);
281 wd->contents.right = NULL;
282 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
287 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
289 ELM_CHECK_WIDTYPE(obj, widtype);
290 Widget_Data *wd = elm_widget_data_get(obj);
292 if (!part || !strcmp(part, "right"))
293 _content_right_set(obj, content);
294 else if(!strcmp(part, "left"))
295 _content_left_set(obj, content);
299 _content_get_hook(const Evas_Object *obj, const char *part)
301 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
302 Widget_Data *wd = elm_widget_data_get(obj);
303 if (!wd) return NULL;
304 if (!part || !strcmp(part, "right"))
305 return wd->contents.right;
306 else if (!strcmp(part, "left"))
307 return wd->contents.left;
312 _content_unset_hook(Evas_Object *obj, const char *part)
314 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
315 Widget_Data *wd = elm_widget_data_get(obj);
316 if (!wd) return NULL;
317 if (!part || !strcmp(part, "right"))
318 return _content_right_unset(obj);
319 else if (!strcmp(part, "left"))
320 return _content_left_unset(obj);
325 elm_panes_add(Evas_Object *parent)
331 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
333 ELM_SET_WIDTYPE(widtype, "panes");
334 elm_widget_type_set(obj, "panes");
335 elm_widget_can_focus_set(obj, EINA_FALSE);
336 elm_widget_sub_object_add(parent, obj);
337 elm_widget_data_set(obj, wd);
338 elm_widget_del_hook_set(obj, _del_hook);
339 elm_widget_theme_hook_set(obj, _theme_hook);
340 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
341 elm_widget_content_set_hook_set(obj, _content_set_hook);
342 elm_widget_content_get_hook_set(obj, _content_get_hook);
343 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
344 elm_widget_can_focus_set(obj, EINA_FALSE);
346 wd->panes = edje_object_add(e);
347 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
348 elm_widget_resize_object_set(obj, wd->panes);
349 evas_object_show(wd->panes);
351 elm_panes_content_left_size_set(obj, 0.5);
353 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
355 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
356 _clicked_double, obj);
357 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
359 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
362 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
363 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
364 _changed_size_hints, obj);
366 evas_object_smart_callbacks_descriptions_set(obj, _signals);
368 _mirrored_set(obj, elm_widget_mirrored_get(obj));
374 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
376 _content_set_hook(obj, "left", content);
380 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
382 _content_set_hook(obj, "right", content);
386 elm_panes_content_left_get(const Evas_Object *obj)
388 return _content_get_hook(obj, "left");
392 elm_panes_content_right_get(const Evas_Object *obj)
394 return _content_get_hook(obj, "right");
398 elm_panes_content_left_unset(Evas_Object *obj)
400 return _content_unset_hook(obj, "left");
404 elm_panes_content_right_unset(Evas_Object *obj)
406 return _content_unset_hook(obj, "right");
410 elm_panes_content_left_size_get(const Evas_Object *obj)
412 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
413 Widget_Data *wd = elm_widget_data_get(obj);
416 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
417 if (wd->horizontal) return h;
422 elm_panes_content_left_size_set(Evas_Object *obj, double size)
424 ELM_CHECK_WIDTYPE(obj, widtype);
425 Widget_Data *wd = elm_widget_data_get(obj);
427 if (size < 0.0) size = 0.0;
428 else if (size > 1.0) size = 1.0;
430 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
432 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
436 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
438 ELM_CHECK_WIDTYPE(obj, widtype);
439 Widget_Data *wd = elm_widget_data_get(obj);
441 wd->horizontal = horizontal;
443 elm_panes_content_left_size_set(obj, 0.5);
447 elm_panes_horizontal_get(const Evas_Object *obj)
449 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
450 Widget_Data *wd = elm_widget_data_get(obj);
451 return wd->horizontal;
455 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
457 ELM_CHECK_WIDTYPE(obj, widtype);
458 Widget_Data *wd = elm_widget_data_get(obj);
460 if (wd->fixed == EINA_TRUE)
461 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
463 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
467 elm_panes_fixed_get(const Evas_Object *obj)
469 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
470 Widget_Data *wd = elm_widget_data_get(obj);