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 _theme_hook(Evas_Object *obj);
37 static void _sizing_eval(Evas_Object *obj);
38 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
41 _del_hook(Evas_Object *obj)
43 Widget_Data *wd = elm_widget_data_get(obj);
45 if (wd->panes) evas_object_del(wd->panes);
50 _theme_hook(Evas_Object *obj)
52 Widget_Data *wd = elm_widget_data_get(obj);
53 const char *style = elm_widget_style_get(obj);
57 size = elm_panes_content_left_size_get(obj);
60 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
62 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
64 if (wd->contents.left)
65 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
66 if (wd->contents.right)
67 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
69 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
72 elm_panes_content_left_size_set(obj, size);
76 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
78 Widget_Data *wd = elm_widget_data_get(obj);
84 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
85 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
86 return elm_widget_focus_next_get(wd->contents.right, dir, next);
88 Evas_Object *chain[2];
91 if (dir == ELM_FOCUS_PREVIOUS)
93 chain[0] = wd->contents.right;
94 chain[1] = wd->contents.left;
96 else if (dir == ELM_FOCUS_NEXT)
98 chain[0] = wd->contents.left;
99 chain[1] = wd->contents.right;
104 unsigned char i = elm_widget_focus_get(chain[1]);
106 if (elm_widget_focus_next_get(chain[i], dir, next))
111 Evas_Object *to_focus;
112 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
122 _sizing_eval(Evas_Object *obj)
124 Widget_Data *wd = elm_widget_data_get(obj);
129 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
135 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
137 Widget_Data *wd = elm_widget_data_get(obj);
138 Evas_Object *sub = event_info;
141 if (sub == wd->contents.left)
143 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
144 _changed_size_hints, obj);
145 wd->contents.left = NULL;
148 else if (sub == wd->contents.right)
150 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
151 _changed_size_hints, obj);
152 wd->contents.right= NULL;
158 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
160 evas_object_smart_callback_call(data, "clicked", NULL);
164 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
166 Widget_Data *wd = elm_widget_data_get(data);
168 wd->clicked_double = EINA_TRUE;
172 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
174 evas_object_smart_callback_call(data, "press", NULL);
178 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
180 Widget_Data *wd = elm_widget_data_get(data);
181 evas_object_smart_callback_call(data, "unpress", NULL);
183 if (wd->clicked_double)
185 evas_object_smart_callback_call(data, "clicked,double", NULL);
186 wd->clicked_double = EINA_FALSE;
191 * Add a new panes to the parent
193 * @param[in] parent The parent object
194 * @return The new object or NULL if it cannot be created
199 elm_panes_add(Evas_Object *parent)
205 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
207 wd = ELM_NEW(Widget_Data);
208 e = evas_object_evas_get(parent);
210 obj = elm_widget_add(e);
211 ELM_SET_WIDTYPE(widtype, "panes");
212 elm_widget_type_set(obj, "panes");
213 elm_widget_can_focus_set(obj, EINA_FALSE);
214 elm_widget_sub_object_add(parent, obj);
215 elm_widget_data_set(obj, wd);
216 elm_widget_del_hook_set(obj, _del_hook);
217 elm_widget_theme_hook_set(obj, _theme_hook);
218 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
219 wd->contents.left = NULL;
220 wd->contents.right = NULL;
222 wd->panes = edje_object_add(e);
223 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
224 elm_widget_resize_object_set(obj, wd->panes);
225 evas_object_show(wd->panes);
227 elm_panes_content_left_size_set(obj, 0.5);
229 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
231 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
232 _clicked_double, obj);
233 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
235 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
238 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
239 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
240 _changed_size_hints, obj);
247 * Set the left/top content of the panes widget
249 * Once the content object is set, a previously set one will be deleted.
250 * If you want to keep that old content object, use the
251 * elm_panes_content_left_unset() function.
253 * @param[in] obj The panes object
254 * @param[in] content The new left/top content object
259 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
261 ELM_CHECK_WIDTYPE(obj, widtype);
262 Widget_Data *wd = elm_widget_data_get(obj);
263 if (wd->contents.left)
265 evas_object_del(wd->contents.left);
266 wd->contents.left = NULL;
270 wd->contents.left = content;
271 elm_widget_sub_object_add(obj, content);
272 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
273 if (wd->contents.right)
274 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
277 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
281 * Set the right/bottom 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[in] obj The panes object
288 * @param[in] content The new right/bottom 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);
307 if (wd->contents.left)
308 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
311 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
315 * Get the left/top content used for the panes
317 * Return the left/top content object which is set for this widget.
319 * @param[in] obj The panes object
320 * @return The left/top 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/bottom content used for the panes
335 * Return the right/bottom content object which is set for this widget.
337 * @param[in] obj The panes object
338 * @return The right/bottom 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/top content used for the panes
353 * Unparent and return the left content object which was set for this widget.
355 * @param[in] obj The panes object
356 * @return The left/top 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 edje_object_part_unswallow(wd->panes, content);
369 elm_widget_sub_object_del(obj, content);
370 evas_object_hide(content);
371 wd->contents.left = NULL;
372 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
377 * Unset the right/bottom content used for the panes
379 * Unparent and return the right content object which was set for this widget.
381 * @param[in] obj The panes object
382 * @return The right/bottom content object that was being used
387 elm_panes_content_right_unset(Evas_Object *obj)
389 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
390 Widget_Data *wd = elm_widget_data_get(obj);
391 if (!wd) return NULL;
392 if (!wd->contents.right) return NULL;
393 Evas_Object *content = wd->contents.right;
394 edje_object_part_unswallow(wd->panes, content);
395 elm_widget_sub_object_del(obj, content);
396 evas_object_hide(content);
397 wd->contents.right = NULL;
398 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
403 * Get the relative normalized size of left/top content of the pane
405 * @param[in] obj The panes object
406 * @return The value of type double in the range [0.0,1.0]
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 * Set a size of the left/top content with a relative normalized double value
425 * @param[in] obj The panes object
426 * @param[in] size The value of type double in the range [0.0,1.0]
431 elm_panes_content_left_size_set(Evas_Object *obj, double size)
433 ELM_CHECK_WIDTYPE(obj, widtype);
434 Widget_Data *wd = elm_widget_data_get(obj);
436 if (size < 0.0) size = 0.0;
437 else if (size > 1.0) size = 1.0;
439 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
441 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
445 * Set the type of an existing panes object to horizontal/vertical
447 * By default the panes is of vertical type
449 * @param[in] obj The panes object
450 * @param[in] horizontal Boolean value. If true, then the type is set to horizontal else vertical
455 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
457 ELM_CHECK_WIDTYPE(obj, widtype);
458 Widget_Data *wd = elm_widget_data_get(obj);
460 wd->horizontal = horizontal;
462 elm_panes_content_left_size_set(obj, 0.5);
466 * Indicate if the type of pane object is horizontal or not
468 * @param[in] obj The panes object
469 * @return true if it is of horizontal type else false
474 elm_panes_horizontal_get(const Evas_Object *obj)
476 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
477 Widget_Data *wd = elm_widget_data_get(obj);
478 return wd->horizontal;
482 * Set a handler of the pane object non-movable or movable
484 * @param[in] obj The panes object
485 * @param[in] fixed If set to true then the views size can't be changed using handler otherwise using handler they can be resized
490 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
492 ELM_CHECK_WIDTYPE(obj, widtype);
493 Widget_Data *wd = elm_widget_data_get(obj);
495 if (wd->fixed == EINA_TRUE)
496 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
498 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
502 * Indicate if the handler of the panes object can be moved with user interaction
504 * @param[in] obj The panes object
505 * @return false if the views can be resized using handler else true
510 elm_panes_fixed_get(const Evas_Object *obj)
512 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
513 Widget_Data *wd = elm_widget_data_get(obj);