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 if(wd->contents.left && wd->contents.right)
94 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
98 >>>>>>> remotes/origin/upstream
99 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
101 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
104 elm_panes_content_left_size_set(obj, size);
108 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
110 Widget_Data *wd = elm_widget_data_get(obj);
111 if (!wd) return EINA_FALSE;
114 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
115 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
116 return elm_widget_focus_next_get(wd->contents.right, dir, next);
118 Evas_Object *chain[2];
121 if (dir == ELM_FOCUS_PREVIOUS)
123 chain[0] = wd->contents.right;
124 chain[1] = wd->contents.left;
126 else if (dir == ELM_FOCUS_NEXT)
128 chain[0] = wd->contents.left;
129 chain[1] = wd->contents.right;
134 unsigned char i = elm_widget_focus_get(chain[1]);
136 if (elm_widget_focus_next_get(chain[i], dir, next))
141 Evas_Object *to_focus;
142 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
152 _sizing_eval(Evas_Object *obj)
154 Widget_Data *wd = elm_widget_data_get(obj);
159 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
165 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
167 Widget_Data *wd = elm_widget_data_get(obj);
168 Evas_Object *sub = event_info;
171 if (sub == wd->contents.left)
173 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
174 _changed_size_hints, obj);
175 wd->contents.left = NULL;
178 else if (sub == wd->contents.right)
180 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
181 _changed_size_hints, obj);
182 wd->contents.right= NULL;
190 >>>>>>> remotes/origin/upstream
192 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
194 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
198 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
200 Widget_Data *wd = elm_widget_data_get(data);
202 wd->clicked_double = EINA_TRUE;
206 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
208 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
212 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
214 Widget_Data *wd = elm_widget_data_get(data);
215 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
217 if (wd->clicked_double)
219 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
220 wd->clicked_double = EINA_FALSE;
225 _content_left_set(Evas_Object *obj, Evas_Object *content)
227 Widget_Data *wd = elm_widget_data_get(obj);
228 if (wd->contents.left)
230 evas_object_del(wd->contents.left);
231 wd->contents.left = NULL;
233 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
235 >>>>>>> remotes/origin/upstream
239 wd->contents.left = content;
240 elm_widget_sub_object_add(obj, content);
241 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
243 if (wd->contents.right)
244 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
246 >>>>>>> remotes/origin/upstream
251 _content_right_set(Evas_Object *obj, Evas_Object *content)
253 Widget_Data *wd = elm_widget_data_get(obj);
254 if (wd->contents.right)
256 evas_object_del(wd->contents.right);
257 wd->contents.right = NULL;
259 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
261 >>>>>>> remotes/origin/upstream
265 wd->contents.right = content;
266 elm_widget_sub_object_add(obj, content);
267 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
269 if (wd->contents.left)
270 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
272 >>>>>>> remotes/origin/upstream
277 _content_left_unset(Evas_Object *obj)
279 Widget_Data *wd = elm_widget_data_get(obj);
280 if (!wd->contents.left) return NULL;
281 Evas_Object *content = wd->contents.left;
284 edje_object_part_unswallow(wd->panes, content);
285 evas_object_hide(wd->contents.left);
286 elm_widget_sub_object_del(obj, content);
287 wd->contents.left = NULL;
288 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
290 elm_widget_sub_object_del(obj, content);
291 edje_object_part_unswallow(wd->panes, content);
292 wd->contents.left = NULL;
293 >>>>>>> remotes/origin/upstream
298 _content_right_unset(Evas_Object *obj)
300 Widget_Data *wd = elm_widget_data_get(obj);
301 if (!wd->contents.right) return NULL;
302 Evas_Object *content = wd->contents.right;
305 edje_object_part_unswallow(wd->panes, content);
306 evas_object_hide(wd->contents.right);
307 elm_widget_sub_object_del(obj, content);
308 wd->contents.right = NULL;
309 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
311 elm_widget_sub_object_del(obj, content);
312 edje_object_part_unswallow(wd->panes, content);
313 wd->contents.right = NULL;
314 >>>>>>> remotes/origin/upstream
319 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
321 ELM_CHECK_WIDTYPE(obj, widtype);
322 Widget_Data *wd = elm_widget_data_get(obj);
324 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
325 if (!part || !strcmp(part, "left"))
326 _content_left_set(obj, content);
327 else if(!strcmp(part, "right"))
328 _content_right_set(obj, content);
332 _content_get_hook(const Evas_Object *obj, const char *part)
334 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
335 Widget_Data *wd = elm_widget_data_get(obj);
336 if (!wd) return NULL;
337 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
338 if (!part || !strcmp(part, "left"))
339 return wd->contents.left;
340 else if (!strcmp(part, "right"))
341 return wd->contents.right;
346 _content_unset_hook(Evas_Object *obj, const char *part)
348 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
349 Widget_Data *wd = elm_widget_data_get(obj);
350 if (!wd) return NULL;
351 if (part && (!strncmp(part, "elm.swallow.", 12))) part += 12;
352 if (!part || !strcmp(part, "left"))
353 return _content_left_unset(obj);
354 else if (!strcmp(part, "right"))
355 return _content_right_unset(obj);
360 elm_panes_add(Evas_Object *parent)
366 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
368 ELM_SET_WIDTYPE(widtype, "panes");
369 elm_widget_type_set(obj, "panes");
370 elm_widget_sub_object_add(parent, obj);
371 elm_widget_data_set(obj, wd);
372 elm_widget_del_hook_set(obj, _del_hook);
373 elm_widget_theme_hook_set(obj, _theme_hook);
374 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
375 elm_widget_content_set_hook_set(obj, _content_set_hook);
376 elm_widget_content_get_hook_set(obj, _content_get_hook);
377 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
378 elm_widget_can_focus_set(obj, EINA_FALSE);
380 wd->panes = edje_object_add(e);
381 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
382 elm_widget_resize_object_set(obj, wd->panes);
383 evas_object_show(wd->panes);
385 elm_panes_content_left_size_set(obj, 0.5);
387 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
389 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
390 _clicked_double, obj);
391 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
393 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
396 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
397 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
398 _changed_size_hints, obj);
400 evas_object_smart_callbacks_descriptions_set(obj, _signals);
402 _mirrored_set(obj, elm_widget_mirrored_get(obj));
410 EINA_DEPRECATED EAPI void
411 >>>>>>> remotes/origin/upstream
412 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
414 _content_set_hook(obj, "left", content);
420 EINA_DEPRECATED EAPI void
421 >>>>>>> remotes/origin/upstream
422 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
424 _content_set_hook(obj, "right", content);
430 EINA_DEPRECATED EAPI Evas_Object *
431 >>>>>>> remotes/origin/upstream
432 elm_panes_content_left_get(const Evas_Object *obj)
434 return _content_get_hook(obj, "left");
440 EINA_DEPRECATED EAPI Evas_Object *
441 >>>>>>> remotes/origin/upstream
442 elm_panes_content_right_get(const Evas_Object *obj)
444 return _content_get_hook(obj, "right");
450 EINA_DEPRECATED EAPI Evas_Object *
451 >>>>>>> remotes/origin/upstream
452 elm_panes_content_left_unset(Evas_Object *obj)
454 return _content_unset_hook(obj, "left");
460 EINA_DEPRECATED EAPI Evas_Object *
461 >>>>>>> remotes/origin/upstream
462 elm_panes_content_right_unset(Evas_Object *obj)
464 return _content_unset_hook(obj, "right");
468 elm_panes_content_left_size_get(const Evas_Object *obj)
470 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
471 Widget_Data *wd = elm_widget_data_get(obj);
475 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
476 if (wd->horizontal) return h;
481 elm_panes_content_left_size_set(Evas_Object *obj, double size)
483 ELM_CHECK_WIDTYPE(obj, widtype);
484 Widget_Data *wd = elm_widget_data_get(obj);
486 if (size < 0.0) size = 0.0;
487 else if (size > 1.0) size = 1.0;
489 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
491 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
497 elm_panes_content_right_size_get(const Evas_Object *obj)
499 return (1.0 - elm_panes_content_left_size_get(obj));
503 elm_panes_content_right_size_set(Evas_Object *obj, double size)
505 elm_panes_content_left_size_set(obj, (1.0 - size));
508 >>>>>>> remotes/origin/upstream
510 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
512 ELM_CHECK_WIDTYPE(obj, widtype);
513 Widget_Data *wd = elm_widget_data_get(obj);
515 wd->horizontal = horizontal;
517 elm_panes_content_left_size_set(obj, 0.5);
521 elm_panes_horizontal_get(const Evas_Object *obj)
523 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
524 Widget_Data *wd = elm_widget_data_get(obj);
525 if (!wd) return EINA_FALSE;
526 return wd->horizontal;
530 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
532 ELM_CHECK_WIDTYPE(obj, widtype);
533 Widget_Data *wd = elm_widget_data_get(obj);
536 if (wd->fixed == EINA_TRUE)
537 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
539 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
543 elm_panes_fixed_get(const Evas_Object *obj)
545 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
546 Widget_Data *wd = elm_widget_data_get(obj);
547 if (!wd) return EINA_FALSE;