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 _theme_hook(Evas_Object *obj);
35 static void _sizing_eval(Evas_Object *obj);
36 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
39 _del_hook(Evas_Object *obj)
41 Widget_Data *wd = elm_widget_data_get(obj);
47 _theme_hook(Evas_Object *obj)
49 Widget_Data *wd = elm_widget_data_get(obj);
50 const char *style = elm_widget_style_get(obj);
54 size = elm_panes_content_left_size_get(obj);
57 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
59 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
61 if (wd->contents.left)
62 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
63 if (wd->contents.right)
64 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
66 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
69 elm_panes_content_left_size_set(obj, size);
73 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
75 Widget_Data *wd = elm_widget_data_get(obj);
81 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
82 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
83 return elm_widget_focus_next_get(wd->contents.right, dir, next);
85 Evas_Object *chain[2];
88 if (dir == ELM_FOCUS_PREVIOUS)
90 chain[0] = wd->contents.right;
91 chain[1] = wd->contents.left;
93 else if (dir == ELM_FOCUS_NEXT)
95 chain[0] = wd->contents.left;
96 chain[1] = wd->contents.right;
101 unsigned char i = elm_widget_focus_get(chain[1]);
103 if (elm_widget_focus_next_get(chain[i], dir, next))
108 Evas_Object *to_focus;
109 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
119 _sizing_eval(Evas_Object *obj)
121 Widget_Data *wd = elm_widget_data_get(obj);
126 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
132 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
134 Widget_Data *wd = elm_widget_data_get(obj);
135 Evas_Object *sub = event_info;
138 if (sub == wd->contents.left)
140 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
141 _changed_size_hints, obj);
142 wd->contents.left = NULL;
145 else if (sub == wd->contents.right)
147 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
148 _changed_size_hints, obj);
149 wd->contents.right= NULL;
155 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
157 evas_object_smart_callback_call(data, "clicked", NULL);
161 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
163 Widget_Data *wd = elm_widget_data_get(data);
165 wd->clicked_double = EINA_TRUE;
169 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
171 evas_object_smart_callback_call(data, "press", NULL);
175 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
177 Widget_Data *wd = elm_widget_data_get(data);
178 evas_object_smart_callback_call(data, "unpress", NULL);
180 if (wd->clicked_double)
182 evas_object_smart_callback_call(data, "clicked,double", NULL);
183 wd->clicked_double = EINA_FALSE;
188 * Add a new panes to the parent
190 * @param parent The parent object
191 * @return The new object or NULL if it cannot be created
196 elm_panes_add(Evas_Object *parent)
202 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
204 wd = ELM_NEW(Widget_Data);
205 e = evas_object_evas_get(parent);
207 obj = elm_widget_add(e);
208 ELM_SET_WIDTYPE(widtype, "panes");
209 elm_widget_type_set(obj, "panes");
210 elm_widget_sub_object_add(parent, obj);
211 elm_widget_data_set(obj, wd);
212 elm_widget_del_hook_set(obj, _del_hook);
213 elm_widget_theme_hook_set(obj, _theme_hook);
214 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
215 elm_widget_can_focus_set(obj, EINA_FALSE);
217 wd->panes = edje_object_add(e);
218 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
219 elm_widget_resize_object_set(obj, wd->panes);
220 evas_object_show(wd->panes);
222 elm_panes_content_left_size_set(obj, 0.5);
224 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
226 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
227 _clicked_double, obj);
228 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
230 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
233 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
234 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
235 _changed_size_hints, obj);
243 * Set the left content of the panes widget.
245 * Once the content object is set, a previously set one will be deleted.
246 * If you want to keep that old content object, use the
247 * elm_panes_content_left_unset() function.
249 * @param obj The panes object
250 * @param content The new left content object
255 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
257 ELM_CHECK_WIDTYPE(obj, widtype);
258 Widget_Data *wd = elm_widget_data_get(obj);
259 if (wd->contents.left)
261 evas_object_del(wd->contents.left);
262 wd->contents.left = NULL;
266 wd->contents.left = content;
267 elm_widget_sub_object_add(obj, content);
268 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
273 * Set the right content of the panes widget.
275 * Once the content object is set, a previously set one will be deleted.
276 * If you want to keep that old content object, use the
277 * elm_panes_content_right_unset() function.
279 * @param obj The panes object
280 * @param content The new right content object
285 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
287 ELM_CHECK_WIDTYPE(obj, widtype);
288 Widget_Data *wd = elm_widget_data_get(obj);
289 if (wd->contents.right)
291 evas_object_del(wd->contents.right);
292 wd->contents.right = NULL;
296 wd->contents.right = content;
297 elm_widget_sub_object_add(obj, content);
298 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
303 * Get the left content used for the panes
305 * Return the left content object which is set for this widget.
307 * @param obj The panes object
308 * @return The left content object that is being used
313 elm_panes_content_left_get(const Evas_Object *obj)
315 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
316 Widget_Data *wd = elm_widget_data_get(obj);
317 return wd->contents.left;
321 * Get the right content used for the panes
323 * Return the right content object which is set for this widget.
325 * @param obj The panes object
326 * @return The right content object that is being used
331 elm_panes_content_right_get(const Evas_Object *obj)
333 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
334 Widget_Data *wd = elm_widget_data_get(obj);
335 return wd->contents.right;
339 * Unset the left content used for the panes
341 * Unparent and return the left content object which was set for this widget.
343 * @param obj The panes object
344 * @return The left content object that was being used
349 elm_panes_content_left_unset(Evas_Object *obj)
351 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
352 Widget_Data *wd = elm_widget_data_get(obj);
353 if (!wd) return NULL;
354 if (!wd->contents.left) return NULL;
355 Evas_Object *content = wd->contents.left;
356 elm_widget_sub_object_del(obj, content);
357 edje_object_part_unswallow(wd->panes, content);
358 wd->contents.left = NULL;
363 * Unset the right content used for the panes
365 * Unparent and return the right content object which was set for this widget.
367 * @param obj The panes object
368 * @return The right content object that was being used
373 elm_panes_content_right_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.right) return NULL;
379 Evas_Object *content = wd->contents.right;
380 elm_widget_sub_object_del(obj, content);
381 edje_object_part_unswallow(wd->panes, content);
382 wd->contents.right = NULL;
387 elm_panes_content_left_size_get(const Evas_Object *obj)
389 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
390 Widget_Data *wd = elm_widget_data_get(obj);
393 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
394 if (wd->horizontal) return h;
399 elm_panes_content_left_size_set(Evas_Object *obj, double size)
401 ELM_CHECK_WIDTYPE(obj, widtype);
402 Widget_Data *wd = elm_widget_data_get(obj);
404 if (size < 0.0) size = 0.0;
405 else if (size > 1.0) size = 1.0;
407 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
409 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
413 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
415 ELM_CHECK_WIDTYPE(obj, widtype);
416 Widget_Data *wd = elm_widget_data_get(obj);
418 wd->horizontal = horizontal;
420 elm_panes_content_left_size_set(obj, 0.5);
424 elm_panes_horizontal_get(const Evas_Object *obj)
426 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
427 Widget_Data *wd = elm_widget_data_get(obj);
428 return wd->horizontal;