1 #include <Elementary.h>
5 * @defgroup Panes Panes
9 typedef struct _Widget_Data Widget_Data;
28 Eina_Bool clicked_double;
32 static const char *widtype = NULL;
33 static void _del_hook(Evas_Object *obj);
34 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
35 static void _theme_hook(Evas_Object *obj);
36 static void _sizing_eval(Evas_Object *obj);
37 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
39 static const char SIG_CLICKED[] = "clicked";
40 static const char SIG_PRESS[] = "press";
41 static const char SIG_UNPRESS[] = "unpress";
42 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
44 static const Evas_Smart_Cb_Description _signals[] = {
48 {SIG_CLICKED_DOUBLE, ""},
53 _del_hook(Evas_Object *obj)
55 Widget_Data *wd = elm_widget_data_get(obj);
61 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
63 Widget_Data *wd = elm_widget_data_get(obj);
65 edje_object_mirrored_set(wd->panes, rtl);
69 _theme_hook(Evas_Object *obj)
71 Widget_Data *wd = elm_widget_data_get(obj);
72 const char *style = elm_widget_style_get(obj);
76 _elm_widget_mirrored_reload(obj);
77 _mirrored_set(obj, elm_widget_mirrored_get(obj));
78 size = elm_panes_content_left_size_get(obj);
81 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
83 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
85 if (wd->contents.left)
86 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
87 if (wd->contents.right)
88 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
90 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
93 elm_panes_content_left_size_set(obj, size);
97 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
99 Widget_Data *wd = elm_widget_data_get(obj);
105 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
106 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
107 return elm_widget_focus_next_get(wd->contents.right, dir, next);
109 Evas_Object *chain[2];
112 if (dir == ELM_FOCUS_PREVIOUS)
114 chain[0] = wd->contents.right;
115 chain[1] = wd->contents.left;
117 else if (dir == ELM_FOCUS_NEXT)
119 chain[0] = wd->contents.left;
120 chain[1] = wd->contents.right;
125 unsigned char i = elm_widget_focus_get(chain[1]);
127 if (elm_widget_focus_next_get(chain[i], dir, next))
132 Evas_Object *to_focus;
133 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
143 _sizing_eval(Evas_Object *obj)
145 Widget_Data *wd = elm_widget_data_get(obj);
150 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
156 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
158 Widget_Data *wd = elm_widget_data_get(obj);
159 Evas_Object *sub = event_info;
162 if (sub == wd->contents.left)
164 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
165 _changed_size_hints, obj);
166 wd->contents.left = NULL;
169 else if (sub == wd->contents.right)
171 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
172 _changed_size_hints, obj);
173 wd->contents.right= NULL;
180 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
182 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
186 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
188 Widget_Data *wd = elm_widget_data_get(data);
190 wd->clicked_double = EINA_TRUE;
194 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
196 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
200 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
202 Widget_Data *wd = elm_widget_data_get(data);
203 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
205 if (wd->clicked_double)
207 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
208 wd->clicked_double = EINA_FALSE;
213 * Add a new panes to the parent
215 * @param parent The parent object
216 * @return The new object or NULL if it cannot be created
221 elm_panes_add(Evas_Object *parent)
227 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
229 ELM_SET_WIDTYPE(widtype, "panes");
230 elm_widget_type_set(obj, "panes");
231 elm_widget_sub_object_add(parent, obj);
232 elm_widget_data_set(obj, wd);
233 elm_widget_del_hook_set(obj, _del_hook);
234 elm_widget_theme_hook_set(obj, _theme_hook);
235 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
236 elm_widget_can_focus_set(obj, EINA_FALSE);
238 wd->panes = edje_object_add(e);
239 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
240 elm_widget_resize_object_set(obj, wd->panes);
241 evas_object_show(wd->panes);
243 elm_panes_content_left_size_set(obj, 0.5);
245 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
247 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
248 _clicked_double, obj);
249 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
251 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
254 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
255 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
256 _changed_size_hints, obj);
258 evas_object_smart_callbacks_descriptions_set(obj, _signals);
260 _mirrored_set(obj, elm_widget_mirrored_get(obj));
267 * Set the left content of the panes widget.
269 * Once the content object is set, a previously set one will be deleted.
270 * If you want to keep that old content object, use the
271 * elm_panes_content_left_unset() function.
273 * @param obj The panes object
274 * @param content The new left content object
279 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
281 ELM_CHECK_WIDTYPE(obj, widtype);
282 Widget_Data *wd = elm_widget_data_get(obj);
283 if (wd->contents.left)
285 evas_object_del(wd->contents.left);
286 wd->contents.left = NULL;
290 wd->contents.left = content;
291 elm_widget_sub_object_add(obj, content);
292 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
297 * Set the right content of the panes widget.
299 * Once the content object is set, a previously set one will be deleted.
300 * If you want to keep that old content object, use the
301 * elm_panes_content_right_unset() function.
303 * @param obj The panes object
304 * @param content The new right content object
309 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
311 ELM_CHECK_WIDTYPE(obj, widtype);
312 Widget_Data *wd = elm_widget_data_get(obj);
313 if (wd->contents.right)
315 evas_object_del(wd->contents.right);
316 wd->contents.right = NULL;
320 wd->contents.right = content;
321 elm_widget_sub_object_add(obj, content);
322 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
327 * Get the left content used for the panes
329 * Return the left content object which is set for this widget.
331 * @param obj The panes object
332 * @return The left 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 content used for the panes
347 * Return the right content object which is set for this widget.
349 * @param obj The panes object
350 * @return The right 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 content used for the panes
365 * Unparent and return the left content object which was set for this widget.
367 * @param obj The panes object
368 * @return The left 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 wd->contents.left = NULL;
387 * Unset the right content used for the panes
389 * Unparent and return the right content object which was set for this widget.
391 * @param obj The panes object
392 * @return The right content object that was being used
397 elm_panes_content_right_unset(Evas_Object *obj)
399 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
400 Widget_Data *wd = elm_widget_data_get(obj);
401 if (!wd) return NULL;
402 if (!wd->contents.right) return NULL;
403 Evas_Object *content = wd->contents.right;
404 elm_widget_sub_object_del(obj, content);
405 edje_object_part_unswallow(wd->panes, content);
406 wd->contents.right = NULL;
411 elm_panes_content_left_size_get(const Evas_Object *obj)
413 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
414 Widget_Data *wd = elm_widget_data_get(obj);
417 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
418 if (wd->horizontal) return h;
423 elm_panes_content_left_size_set(Evas_Object *obj, double size)
425 ELM_CHECK_WIDTYPE(obj, widtype);
426 Widget_Data *wd = elm_widget_data_get(obj);
428 if (size < 0.0) size = 0.0;
429 else if (size > 1.0) size = 1.0;
431 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
433 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
437 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
439 ELM_CHECK_WIDTYPE(obj, widtype);
440 Widget_Data *wd = elm_widget_data_get(obj);
442 wd->horizontal = horizontal;
444 elm_panes_content_left_size_set(obj, 0.5);
448 elm_panes_horizontal_get(const Evas_Object *obj)
450 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
451 Widget_Data *wd = elm_widget_data_get(obj);
452 return wd->horizontal;