1 #include <Elementary.h>
5 * @defgroup Panes Panes
10 typedef struct _Widget_Data Widget_Data;
29 Eina_Bool clicked_double;
34 static const char *widtype = NULL;
35 static void _del_hook(Evas_Object *obj);
36 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
37 static void _theme_hook(Evas_Object *obj);
38 static void _sizing_eval(Evas_Object *obj);
39 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
42 _del_hook(Evas_Object *obj)
44 Widget_Data *wd = elm_widget_data_get(obj);
46 if (wd->panes) evas_object_del(wd->panes);
51 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
53 Widget_Data *wd = elm_widget_data_get(obj);
55 edje_object_mirrored_set(wd->panes, rtl);
59 _theme_hook(Evas_Object *obj)
61 Widget_Data *wd = elm_widget_data_get(obj);
62 const char *style = elm_widget_style_get(obj);
66 _elm_widget_mirrored_reload(obj);
67 _mirrored_set(obj, elm_widget_mirrored_get(obj));
68 size = elm_panes_content_left_size_get(obj);
71 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
73 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
75 if (wd->contents.left)
76 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
77 if (wd->contents.right)
78 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
79 if(wd->contents.left && wd->contents.right)
80 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
82 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
83 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
86 elm_panes_content_left_size_set(obj, size);
90 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
92 Widget_Data *wd = elm_widget_data_get(obj);
98 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
99 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
100 return elm_widget_focus_next_get(wd->contents.right, dir, next);
102 Evas_Object *chain[2];
105 if (dir == ELM_FOCUS_PREVIOUS)
107 chain[0] = wd->contents.right;
108 chain[1] = wd->contents.left;
110 else if (dir == ELM_FOCUS_NEXT)
112 chain[0] = wd->contents.left;
113 chain[1] = wd->contents.right;
118 unsigned char i = elm_widget_focus_get(chain[1]);
120 if (elm_widget_focus_next_get(chain[i], dir, next))
125 Evas_Object *to_focus;
126 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
136 _sizing_eval(Evas_Object *obj)
138 Widget_Data *wd = elm_widget_data_get(obj);
143 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
149 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
151 Widget_Data *wd = elm_widget_data_get(obj);
152 Evas_Object *sub = event_info;
155 if (sub == wd->contents.left)
157 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
158 _changed_size_hints, obj);
159 wd->contents.left = NULL;
162 else if (sub == wd->contents.right)
164 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
165 _changed_size_hints, obj);
166 wd->contents.right= NULL;
172 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
174 evas_object_smart_callback_call(data, "clicked", NULL);
178 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
180 Widget_Data *wd = elm_widget_data_get(data);
182 wd->clicked_double = EINA_TRUE;
186 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
188 evas_object_smart_callback_call(data, "press", NULL);
192 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
194 Widget_Data *wd = elm_widget_data_get(data);
195 evas_object_smart_callback_call(data, "unpress", NULL);
197 if (wd->clicked_double)
199 evas_object_smart_callback_call(data, "clicked,double", NULL);
200 wd->clicked_double = EINA_FALSE;
205 * Add a new panes to the parent
207 * @param[in] parent The parent object
208 * @return The new object or NULL if it cannot be created
213 elm_panes_add(Evas_Object *parent)
219 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
221 ELM_SET_WIDTYPE(widtype, "panes");
222 elm_widget_type_set(obj, "panes");
223 elm_widget_can_focus_set(obj, EINA_FALSE);
224 elm_widget_sub_object_add(parent, obj);
225 elm_widget_data_set(obj, wd);
226 elm_widget_del_hook_set(obj, _del_hook);
227 elm_widget_theme_hook_set(obj, _theme_hook);
228 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
229 wd->contents.left = NULL;
230 wd->contents.right = NULL;
232 wd->panes = edje_object_add(e);
233 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
234 elm_widget_resize_object_set(obj, wd->panes);
235 evas_object_show(wd->panes);
237 elm_panes_content_left_size_set(obj, 0.5);
239 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
241 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
242 _clicked_double, obj);
243 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
245 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
248 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
249 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
250 _changed_size_hints, obj);
252 _mirrored_set(obj, elm_widget_mirrored_get(obj));
259 * Set the left/top content of the panes widget
261 * Once the content object is set, a previously set one will be deleted.
262 * If you want to keep that old content object, use the
263 * elm_panes_content_left_unset() function.
265 * @param[in] obj The panes object
266 * @param[in] content The new left/top content object
271 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
273 ELM_CHECK_WIDTYPE(obj, widtype);
274 Widget_Data *wd = elm_widget_data_get(obj);
275 if (wd->contents.left)
277 evas_object_del(wd->contents.left);
278 wd->contents.left = NULL;
282 wd->contents.left = content;
283 elm_widget_sub_object_add(obj, content);
284 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
285 if (wd->contents.right)
286 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
289 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
293 * Set the right/bottom content of the panes widget
295 * Once the content object is set, a previously set one will be deleted.
296 * If you want to keep that old content object, use the
297 * elm_panes_content_right_unset() function.
299 * @param[in] obj The panes object
300 * @param[in] content The new right/bottom content object
305 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
307 ELM_CHECK_WIDTYPE(obj, widtype);
308 Widget_Data *wd = elm_widget_data_get(obj);
309 if (wd->contents.right)
311 evas_object_del(wd->contents.right);
312 wd->contents.right = NULL;
316 wd->contents.right = content;
317 elm_widget_sub_object_add(obj, content);
318 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
319 if (wd->contents.left)
320 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
323 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
327 * Get the left/top content used for the panes
329 * Return the left/top content object which is set for this widget.
331 * @param[in] obj The panes object
332 * @return The left/top content object that is being used
337 elm_panes_content_left_get(const Evas_Object *obj)
339 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
340 Widget_Data *wd = elm_widget_data_get(obj);
341 return wd->contents.left;
345 * Get the right/bottom content used for the panes
347 * Return the right/bottom content object which is set for this widget.
349 * @param[in] obj The panes object
350 * @return The right/bottom content object that is being used
355 elm_panes_content_right_get(const Evas_Object *obj)
357 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
358 Widget_Data *wd = elm_widget_data_get(obj);
359 return wd->contents.right;
363 * Unset the left/top content used for the panes
365 * Unparent and return the left content object which was set for this widget.
367 * @param[in] obj The panes object
368 * @return The left/top content object that was being used
373 elm_panes_content_left_unset(Evas_Object *obj)
375 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
376 Widget_Data *wd = elm_widget_data_get(obj);
377 if (!wd) return NULL;
378 if (!wd->contents.left) return NULL;
379 Evas_Object *content = wd->contents.left;
380 elm_widget_sub_object_del(obj, content);
381 edje_object_part_unswallow(wd->panes, content);
382 evas_object_hide(content);
383 wd->contents.left = NULL;
384 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
389 * Unset the right/bottom content used for the panes
391 * Unparent and return the right content object which was set for this widget.
393 * @param[in] obj The panes object
394 * @return The right/bottom content object that was being used
399 elm_panes_content_right_unset(Evas_Object *obj)
401 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
402 Widget_Data *wd = elm_widget_data_get(obj);
403 if (!wd) return NULL;
404 if (!wd->contents.right) return NULL;
405 Evas_Object *content = wd->contents.right;
406 elm_widget_sub_object_del(obj, content);
407 edje_object_part_unswallow(wd->panes, content);
408 evas_object_hide(content);
409 wd->contents.right = NULL;
410 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
415 * Get the relative normalized size of left/top content of the pane
417 * @param[in] obj The panes object
418 * @return The value of type double in the range [0.0,1.0]
423 elm_panes_content_left_size_get(const Evas_Object *obj)
425 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
426 Widget_Data *wd = elm_widget_data_get(obj);
429 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
430 if (wd->horizontal) return h;
435 * Set a size of the left/top content with a relative normalized double value
437 * @param[in] obj The panes object
438 * @param[in] size The value of type double in the range [0.0,1.0]
443 elm_panes_content_left_size_set(Evas_Object *obj, double size)
445 ELM_CHECK_WIDTYPE(obj, widtype);
446 Widget_Data *wd = elm_widget_data_get(obj);
448 if (size < 0.0) size = 0.0;
449 else if (size > 1.0) size = 1.0;
451 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
453 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
457 * Set the type of an existing panes object to horizontal/vertical
459 * By default the panes is of vertical type
461 * @param[in] obj The panes object
462 * @param[in] horizontal Boolean value. If true, then the type is set to horizontal else vertical
467 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
469 ELM_CHECK_WIDTYPE(obj, widtype);
470 Widget_Data *wd = elm_widget_data_get(obj);
472 wd->horizontal = horizontal;
474 elm_panes_content_left_size_set(obj, 0.5);
478 * Indicate if the type of pane object is horizontal or not
480 * @param[in] obj The panes object
481 * @return true if it is of horizontal type else false
486 elm_panes_horizontal_get(const Evas_Object *obj)
488 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
489 Widget_Data *wd = elm_widget_data_get(obj);
490 return wd->horizontal;
494 * Set a handler of the pane object movable or non-movable
496 * @param[in] obj The panes object
497 * @param[in] fixed If set to true then the views size can't be changed using handler otherwise using handler they can be resized
502 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
504 ELM_CHECK_WIDTYPE(obj, widtype);
505 Widget_Data *wd = elm_widget_data_get(obj);
507 if (wd->fixed == EINA_TRUE)
508 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
510 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
514 * Indicate if the handler of the panes object can be moved with user interaction
516 * @param[in] obj The panes object
517 * @return false if the views can be resized using handler else true
522 elm_panes_fixed_get(const Evas_Object *obj)
524 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
525 Widget_Data *wd = elm_widget_data_get(obj);