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);
49 _theme_hook(Evas_Object *obj)
51 Widget_Data *wd = elm_widget_data_get(obj);
52 const char *style = elm_widget_style_get(obj);
56 size = elm_panes_content_left_size_get(obj);
59 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
61 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
63 if (wd->contents.left)
64 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
65 if (wd->contents.right)
66 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
68 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
71 elm_panes_content_left_size_set(obj, size);
75 _sizing_eval(Evas_Object *obj)
77 Widget_Data *wd = elm_widget_data_get(obj);
82 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
88 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
90 Widget_Data *wd = elm_widget_data_get(obj);
91 Evas_Object *sub = event_info;
94 if (sub == wd->contents.left)
96 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
97 _changed_size_hints, obj);
98 wd->contents.left = NULL;
101 else if (sub == wd->contents.right)
103 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
104 _changed_size_hints, obj);
105 wd->contents.right= NULL;
111 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
113 evas_object_smart_callback_call(data, "clicked", NULL);
117 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
119 Widget_Data *wd = elm_widget_data_get(data);
121 wd->clicked_double = EINA_TRUE;
125 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
127 evas_object_smart_callback_call(data, "press", NULL);
131 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
133 Widget_Data *wd = elm_widget_data_get(data);
134 evas_object_smart_callback_call(data, "unpress", NULL);
136 if (wd->clicked_double)
138 evas_object_smart_callback_call(data, "clicked,double", NULL);
139 wd->clicked_double = EINA_FALSE;
144 * Add a new panes to the parent
146 * @param[in] parent The parent object
147 * @return The new object or NULL if it cannot be created
152 elm_panes_add(Evas_Object *parent)
158 wd = ELM_NEW(Widget_Data);
159 e = evas_object_evas_get(parent);
160 obj = elm_widget_add(e);
161 ELM_SET_WIDTYPE(widtype, "panes");
162 elm_widget_type_set(obj, widtype);
163 elm_widget_can_focus_set(obj, EINA_FALSE);
164 elm_widget_sub_object_add(parent, obj);
165 elm_widget_data_set(obj, wd);
166 elm_widget_del_hook_set(obj, _del_hook);
167 elm_widget_theme_hook_set(obj, _theme_hook);
168 wd->contents.left = NULL;
169 wd->contents.right = NULL;
171 wd->panes = edje_object_add(e);
172 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
173 elm_widget_resize_object_set(obj, wd->panes);
174 evas_object_show(wd->panes);
176 elm_panes_content_left_size_set(obj, 0.5);
178 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
180 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
181 _clicked_double, obj);
182 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
184 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
187 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
188 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
189 _changed_size_hints, obj);
196 * Set the left/top content of the panes widget
198 * Once the content object is set, a previously set one will be deleted.
199 * If you want to keep that old content object, use the
200 * elm_panes_content_left_unset() function.
202 * @param[in] obj The panes object
203 * @param[in] content The new left/top content object
208 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
210 ELM_CHECK_WIDTYPE(obj, widtype);
211 Widget_Data *wd = elm_widget_data_get(obj);
212 if (wd->contents.left)
214 evas_object_del(wd->contents.left);
215 wd->contents.left = NULL;
219 elm_widget_sub_object_add(obj, content);
220 wd->contents.left = content;
221 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
222 if (wd->contents.right)
223 edje_object_signal_emit(wd->panes, "panes_pair", "elm");
226 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
230 * Set the right/bottom content of the panes widget
232 * Once the content object is set, a previously set one will be deleted.
233 * If you want to keep that old content object, use the
234 * elm_panes_content_right_unset() function.
236 * @param[in] obj The panes object
237 * @param[in] content The new right/bottom content object
242 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
244 ELM_CHECK_WIDTYPE(obj, widtype);
245 Widget_Data *wd = elm_widget_data_get(obj);
246 if (wd->contents.right)
248 evas_object_del(wd->contents.right);
249 wd->contents.right = NULL;
253 elm_widget_sub_object_add(obj, content);
254 wd->contents.right = content;
255 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
256 if (wd->contents.left)
257 edje_object_signal_emit(wd->panes, "panes_pair", "elm");
260 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
264 * Get the left/top content used for the panes
266 * Return the left/top content object which is set for this widget.
268 * @param[in] obj The pane object
269 * @return The left/top content object that is being used
274 elm_panes_content_left_get(const Evas_Object *obj)
276 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
277 Widget_Data *wd = elm_widget_data_get(obj);
278 return wd->contents.left;
282 * Get the right/bottom content used for the panes
284 * Return the right/bottom content object which is set for this widget.
286 * @param[in] obj The pane object
287 * @return The Evas Object set as a right/bottom content of the pane
292 elm_panes_content_right_get(const Evas_Object *obj)
294 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
295 Widget_Data *wd = elm_widget_data_get(obj);
296 return wd->contents.right;
300 * Unset the left/top content used for the panes
302 * Unparent and return the left content object which was set for this widget.
304 * @param[in] obj The panes object
305 * @return The left/top content object that was being used
310 elm_panes_content_left_unset(Evas_Object *obj)
312 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
313 Widget_Data *wd = NULL;
314 Evas_Object *content = NULL;
316 wd = elm_widget_data_get(obj);
318 content = edje_object_part_swallow_get(wd->panes, "elm.swallow.left");
321 edje_object_part_unswallow(wd->panes, content);
322 elm_widget_sub_object_del(obj, content);
323 evas_object_hide(content);
324 wd->contents.left = NULL;
325 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
330 * Unset the right/bottom content used for the panes
332 * Unparent and return the right content object which was set for this widget.
334 * @param[in] obj The panes object
335 * @return The right/bottom content object that was being used
340 elm_panes_content_right_unset(Evas_Object *obj)
342 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
343 Widget_Data *wd = NULL;
344 Evas_Object *content = NULL;
346 wd = elm_widget_data_get(obj);
348 content = edje_object_part_swallow_get(wd->panes, "elm.swallow.right");
351 edje_object_part_unswallow(wd->panes, content);
352 elm_widget_sub_object_del(obj, content);
353 evas_object_hide(content);
354 wd->contents.right = NULL;
355 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
360 * Get the relative normalized size of left/top content of the pane
362 * @param[in] obj The panes object
363 * @return The value of type double in the range [0.0,1.0]
368 elm_panes_content_left_size_get(const Evas_Object *obj)
370 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
371 Widget_Data *wd = elm_widget_data_get(obj);
374 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
375 if (wd->horizontal) return h;
380 * Set a size of the left/top content with a relative normalized double value
382 * @param[in] obj The panes object
383 * @param[in] size The value of type double in the range [0.0,1.0]
388 elm_panes_content_left_size_set(Evas_Object *obj, double size)
390 ELM_CHECK_WIDTYPE(obj, widtype);
391 Widget_Data *wd = elm_widget_data_get(obj);
393 if (size < 0.0) size = 0.0;
394 else if (size > 1.0) size = 1.0;
396 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
398 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
402 * Set the type of an existing panes object to horizontal/vertical
404 * By default the panes is of vertical type
406 * @param[in] obj The panes object
407 * @param[in] horizontal Boolean value. If true, then the type is set to horizontal else vertical
412 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
414 ELM_CHECK_WIDTYPE(obj, widtype);
415 Widget_Data *wd = elm_widget_data_get(obj);
417 wd->horizontal = horizontal;
419 elm_panes_content_left_size_set(obj, 0.5);
423 * Indicate if the type of pane object is horizontal or not
425 * @param[in] obj The panes object
426 * @return true if it is of horizontal type else false
431 elm_panes_horizontal_get(const Evas_Object *obj)
433 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
434 Widget_Data *wd = elm_widget_data_get(obj);
435 return wd->horizontal;
439 * Set a handler of the pane object non-movable or movable
441 * @param[in] obj The panes object
442 * @param[in] fixed If set to true then the views size can't be changed using handler otherwise using handler they can be resized
447 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
449 ELM_CHECK_WIDTYPE(obj, widtype);
450 Widget_Data *wd = elm_widget_data_get(obj);
452 if (wd->fixed == EINA_TRUE)
453 edje_object_signal_emit(wd->panes, "elm.fixed", "movement.decider");
455 edje_object_signal_emit(wd->panes, "elm.unfixed", "movement.decider");
459 * Indicate if the handler of the panes object can be moved with user interaction
461 * @param[in] obj The panes object
462 * @return false if the views can be resized using handler else true
467 elm_panes_fixed_get(const Evas_Object *obj)
469 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
470 Widget_Data *wd = elm_widget_data_get(obj);