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);
40 _del_hook(Evas_Object *obj)
42 Widget_Data *wd = elm_widget_data_get(obj);
48 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
50 Widget_Data *wd = elm_widget_data_get(obj);
52 edje_object_mirrored_set(wd->panes, rtl);
56 _theme_hook(Evas_Object *obj)
58 Widget_Data *wd = elm_widget_data_get(obj);
59 const char *style = elm_widget_style_get(obj);
63 _elm_widget_mirrored_reload(obj);
64 _mirrored_set(obj, elm_widget_mirrored_get(obj));
65 size = elm_panes_content_left_size_get(obj);
68 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
70 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
72 if (wd->contents.left)
73 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
74 if (wd->contents.right)
75 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
77 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
80 elm_panes_content_left_size_set(obj, size);
84 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
86 Widget_Data *wd = elm_widget_data_get(obj);
92 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
93 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
94 return elm_widget_focus_next_get(wd->contents.right, dir, next);
96 Evas_Object *chain[2];
99 if (dir == ELM_FOCUS_PREVIOUS)
101 chain[0] = wd->contents.right;
102 chain[1] = wd->contents.left;
104 else if (dir == ELM_FOCUS_NEXT)
106 chain[0] = wd->contents.left;
107 chain[1] = wd->contents.right;
112 unsigned char i = elm_widget_focus_get(chain[1]);
114 if (elm_widget_focus_next_get(chain[i], dir, next))
119 Evas_Object *to_focus;
120 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
130 _sizing_eval(Evas_Object *obj)
132 Widget_Data *wd = elm_widget_data_get(obj);
137 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
143 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
145 Widget_Data *wd = elm_widget_data_get(obj);
146 Evas_Object *sub = event_info;
149 if (sub == wd->contents.left)
151 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
152 _changed_size_hints, obj);
153 wd->contents.left = NULL;
156 else if (sub == wd->contents.right)
158 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
159 _changed_size_hints, obj);
160 wd->contents.right= NULL;
166 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
168 evas_object_smart_callback_call(data, "clicked", NULL);
172 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
174 Widget_Data *wd = elm_widget_data_get(data);
176 wd->clicked_double = EINA_TRUE;
180 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
182 evas_object_smart_callback_call(data, "press", NULL);
186 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
188 Widget_Data *wd = elm_widget_data_get(data);
189 evas_object_smart_callback_call(data, "unpress", NULL);
191 if (wd->clicked_double)
193 evas_object_smart_callback_call(data, "clicked,double", NULL);
194 wd->clicked_double = EINA_FALSE;
199 * Add a new panes to the parent
201 * @param parent The parent object
202 * @return The new object or NULL if it cannot be created
207 elm_panes_add(Evas_Object *parent)
213 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
215 ELM_SET_WIDTYPE(widtype, "panes");
216 elm_widget_type_set(obj, "panes");
217 elm_widget_sub_object_add(parent, obj);
218 elm_widget_data_set(obj, wd);
219 elm_widget_del_hook_set(obj, _del_hook);
220 elm_widget_theme_hook_set(obj, _theme_hook);
221 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
222 elm_widget_can_focus_set(obj, EINA_FALSE);
224 wd->panes = edje_object_add(e);
225 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
226 elm_widget_resize_object_set(obj, wd->panes);
227 evas_object_show(wd->panes);
229 elm_panes_content_left_size_set(obj, 0.5);
231 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
233 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
234 _clicked_double, obj);
235 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
237 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
240 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
241 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
242 _changed_size_hints, obj);
244 _mirrored_set(obj, elm_widget_mirrored_get(obj));
251 * Set the left content of the panes widget.
253 * Once the content object is set, a previously set one will be deleted.
254 * If you want to keep that old content object, use the
255 * elm_panes_content_left_unset() function.
257 * @param obj The panes object
258 * @param content The new left content object
263 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
265 ELM_CHECK_WIDTYPE(obj, widtype);
266 Widget_Data *wd = elm_widget_data_get(obj);
267 if (wd->contents.left)
269 evas_object_del(wd->contents.left);
270 wd->contents.left = NULL;
274 wd->contents.left = content;
275 elm_widget_sub_object_add(obj, content);
276 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
281 * Set the right content of the panes widget.
283 * Once the content object is set, a previously set one will be deleted.
284 * If you want to keep that old content object, use the
285 * elm_panes_content_right_unset() function.
287 * @param obj The panes object
288 * @param content The new right content object
293 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
295 ELM_CHECK_WIDTYPE(obj, widtype);
296 Widget_Data *wd = elm_widget_data_get(obj);
297 if (wd->contents.right)
299 evas_object_del(wd->contents.right);
300 wd->contents.right = NULL;
304 wd->contents.right = content;
305 elm_widget_sub_object_add(obj, content);
306 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
311 * Get the left content used for the panes
313 * Return the left content object which is set for this widget.
315 * @param obj The panes object
316 * @return The left content object that is being used
321 elm_panes_content_left_get(const Evas_Object *obj)
323 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
324 Widget_Data *wd = elm_widget_data_get(obj);
325 return wd->contents.left;
329 * Get the right content used for the panes
331 * Return the right content object which is set for this widget.
333 * @param obj The panes object
334 * @return The right content object that is being used
339 elm_panes_content_right_get(const Evas_Object *obj)
341 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
342 Widget_Data *wd = elm_widget_data_get(obj);
343 return wd->contents.right;
347 * Unset the left content used for the panes
349 * Unparent and return the left content object which was set for this widget.
351 * @param obj The panes object
352 * @return The left content object that was being used
357 elm_panes_content_left_unset(Evas_Object *obj)
359 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
360 Widget_Data *wd = elm_widget_data_get(obj);
361 if (!wd) return NULL;
362 if (!wd->contents.left) return NULL;
363 Evas_Object *content = wd->contents.left;
364 elm_widget_sub_object_del(obj, content);
365 edje_object_part_unswallow(wd->panes, content);
366 wd->contents.left = NULL;
371 * Unset the right content used for the panes
373 * Unparent and return the right content object which was set for this widget.
375 * @param obj The panes object
376 * @return The right content object that was being used
381 elm_panes_content_right_unset(Evas_Object *obj)
383 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
384 Widget_Data *wd = elm_widget_data_get(obj);
385 if (!wd) return NULL;
386 if (!wd->contents.right) return NULL;
387 Evas_Object *content = wd->contents.right;
388 elm_widget_sub_object_del(obj, content);
389 edje_object_part_unswallow(wd->panes, content);
390 wd->contents.right = NULL;
395 elm_panes_content_left_size_get(const Evas_Object *obj)
397 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
398 Widget_Data *wd = elm_widget_data_get(obj);
401 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
402 if (wd->horizontal) return h;
407 elm_panes_content_left_size_set(Evas_Object *obj, double size)
409 ELM_CHECK_WIDTYPE(obj, widtype);
410 Widget_Data *wd = elm_widget_data_get(obj);
412 if (size < 0.0) size = 0.0;
413 else if (size > 1.0) size = 1.0;
415 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
417 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
421 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
423 ELM_CHECK_WIDTYPE(obj, widtype);
424 Widget_Data *wd = elm_widget_data_get(obj);
426 wd->horizontal = horizontal;
428 elm_panes_content_left_size_set(obj, 0.5);
432 elm_panes_horizontal_get(const Evas_Object *obj)
434 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
435 Widget_Data *wd = elm_widget_data_get(obj);
436 return wd->horizontal;