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 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
215 wd = ELM_NEW(Widget_Data);
216 e = evas_object_evas_get(parent);
218 obj = elm_widget_add(e);
219 ELM_SET_WIDTYPE(widtype, "panes");
220 elm_widget_type_set(obj, "panes");
221 elm_widget_sub_object_add(parent, obj);
222 elm_widget_data_set(obj, wd);
223 elm_widget_del_hook_set(obj, _del_hook);
224 elm_widget_theme_hook_set(obj, _theme_hook);
225 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
226 elm_widget_can_focus_set(obj, EINA_FALSE);
228 wd->panes = edje_object_add(e);
229 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
230 elm_widget_resize_object_set(obj, wd->panes);
231 evas_object_show(wd->panes);
233 elm_panes_content_left_size_set(obj, 0.5);
235 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
237 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
238 _clicked_double, obj);
239 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
241 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
244 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
245 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
246 _changed_size_hints, obj);
248 _mirrored_set(obj, elm_widget_mirrored_get(obj));
255 * Set the left content of the panes widget.
257 * Once the content object is set, a previously set one will be deleted.
258 * If you want to keep that old content object, use the
259 * elm_panes_content_left_unset() function.
261 * @param obj The panes object
262 * @param content The new left content object
267 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
269 ELM_CHECK_WIDTYPE(obj, widtype);
270 Widget_Data *wd = elm_widget_data_get(obj);
271 if (wd->contents.left)
273 evas_object_del(wd->contents.left);
274 wd->contents.left = NULL;
278 wd->contents.left = content;
279 elm_widget_sub_object_add(obj, content);
280 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
285 * Set the right content of the panes widget.
287 * Once the content object is set, a previously set one will be deleted.
288 * If you want to keep that old content object, use the
289 * elm_panes_content_right_unset() function.
291 * @param obj The panes object
292 * @param content The new right content object
297 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
299 ELM_CHECK_WIDTYPE(obj, widtype);
300 Widget_Data *wd = elm_widget_data_get(obj);
301 if (wd->contents.right)
303 evas_object_del(wd->contents.right);
304 wd->contents.right = NULL;
308 wd->contents.right = content;
309 elm_widget_sub_object_add(obj, content);
310 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
315 * Get the left content used for the panes
317 * Return the left content object which is set for this widget.
319 * @param obj The panes object
320 * @return The left content object that is being used
325 elm_panes_content_left_get(const Evas_Object *obj)
327 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
328 Widget_Data *wd = elm_widget_data_get(obj);
329 return wd->contents.left;
333 * Get the right content used for the panes
335 * Return the right content object which is set for this widget.
337 * @param obj The panes object
338 * @return The right content object that is being used
343 elm_panes_content_right_get(const Evas_Object *obj)
345 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
346 Widget_Data *wd = elm_widget_data_get(obj);
347 return wd->contents.right;
351 * Unset the left content used for the panes
353 * Unparent and return the left content object which was set for this widget.
355 * @param obj The panes object
356 * @return The left content object that was being used
361 elm_panes_content_left_unset(Evas_Object *obj)
363 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
364 Widget_Data *wd = elm_widget_data_get(obj);
365 if (!wd) return NULL;
366 if (!wd->contents.left) return NULL;
367 Evas_Object *content = wd->contents.left;
368 elm_widget_sub_object_del(obj, content);
369 edje_object_part_unswallow(wd->panes, content);
370 wd->contents.left = NULL;
375 * Unset the right content used for the panes
377 * Unparent and return the right content object which was set for this widget.
379 * @param obj The panes object
380 * @return The right content object that was being used
385 elm_panes_content_right_unset(Evas_Object *obj)
387 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
388 Widget_Data *wd = elm_widget_data_get(obj);
389 if (!wd) return NULL;
390 if (!wd->contents.right) return NULL;
391 Evas_Object *content = wd->contents.right;
392 elm_widget_sub_object_del(obj, content);
393 edje_object_part_unswallow(wd->panes, content);
394 wd->contents.right = NULL;
399 elm_panes_content_left_size_get(const Evas_Object *obj)
401 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
402 Widget_Data *wd = elm_widget_data_get(obj);
405 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
406 if (wd->horizontal) return h;
411 elm_panes_content_left_size_set(Evas_Object *obj, double size)
413 ELM_CHECK_WIDTYPE(obj, widtype);
414 Widget_Data *wd = elm_widget_data_get(obj);
416 if (size < 0.0) size = 0.0;
417 else if (size > 1.0) size = 1.0;
419 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
421 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
425 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
427 ELM_CHECK_WIDTYPE(obj, widtype);
428 Widget_Data *wd = elm_widget_data_get(obj);
430 wd->horizontal = horizontal;
432 elm_panes_content_left_size_set(obj, 0.5);
436 elm_panes_horizontal_get(const Evas_Object *obj)
438 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
439 Widget_Data *wd = elm_widget_data_get(obj);
440 return wd->horizontal;