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, _changed_size_hints, obj);
104 wd->contents.right= NULL;
110 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
112 evas_object_smart_callback_call(data, "clicked", NULL);
116 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
118 Widget_Data *wd = elm_widget_data_get(data);
120 wd->clicked_double = EINA_TRUE;
124 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
126 evas_object_smart_callback_call(data, "press", NULL);
130 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
132 Widget_Data *wd = elm_widget_data_get(data);
133 evas_object_smart_callback_call(data, "unpress", NULL);
135 if (wd->clicked_double)
137 evas_object_smart_callback_call(data, "clicked,double", NULL);
138 wd->clicked_double = EINA_FALSE;
143 * Add a new panes to the parent
145 * @param[in] parent The parent object
146 * @return The new object or NULL if it cannot be created
151 elm_panes_add(Evas_Object *parent)
157 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
159 wd = ELM_NEW(Widget_Data);
160 e = evas_object_evas_get(parent);
161 obj = elm_widget_add(e);
162 ELM_SET_WIDTYPE(widtype, "panes");
163 elm_widget_type_set(obj, widtype);
164 elm_widget_can_focus_set(obj, EINA_FALSE);
165 elm_widget_sub_object_add(parent, obj);
166 elm_widget_data_set(obj, wd);
167 elm_widget_del_hook_set(obj, _del_hook);
168 elm_widget_theme_hook_set(obj, _theme_hook);
169 wd->contents.left = NULL;
170 wd->contents.right = NULL;
172 wd->panes = edje_object_add(e);
173 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
174 elm_widget_resize_object_set(obj, wd->panes);
175 evas_object_show(wd->panes);
177 elm_panes_content_left_size_set(obj, 0.5);
179 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
181 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
182 _clicked_double, obj);
183 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
185 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
188 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
189 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
190 _changed_size_hints, obj);
197 * Set the left/top content of the panes widget
199 * Once the content object is set, a previously set one will be deleted.
200 * If you want to keep that old content object, use the
201 * elm_panes_content_left_unset() function.
203 * @param[in] obj The panes object
204 * @param[in] content The new left/top content object
209 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
211 ELM_CHECK_WIDTYPE(obj, widtype);
212 Widget_Data *wd = elm_widget_data_get(obj);
213 if (wd->contents.left)
215 evas_object_del(wd->contents.left);
216 wd->contents.left = NULL;
220 elm_widget_sub_object_add(obj, content);
221 wd->contents.left = content;
222 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
223 if (wd->contents.right)
224 edje_object_signal_emit(wd->panes, "panes_pair", "elm");
227 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
231 * Set the right/bottom content of the panes widget
233 * Once the content object is set, a previously set one will be deleted.
234 * If you want to keep that old content object, use the
235 * elm_panes_content_right_unset() function.
237 * @param[in] obj The panes object
238 * @param[in] content The new right/bottom content object
243 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
245 ELM_CHECK_WIDTYPE(obj, widtype);
246 Widget_Data *wd = elm_widget_data_get(obj);
247 if (wd->contents.right)
249 evas_object_del(wd->contents.right);
250 wd->contents.right = NULL;
254 elm_widget_sub_object_add(obj, content);
255 wd->contents.right = content;
256 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
257 if (wd->contents.left)
258 edje_object_signal_emit(wd->panes, "panes_pair", "elm");
261 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
265 * Get the left/top content used for the panes
267 * Return the left/top content object which is set for this widget.
269 * @param[in] obj The pane object
270 * @return The left/top content object that is being used
275 elm_panes_content_left_get(const Evas_Object *obj)
277 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
278 Widget_Data *wd = elm_widget_data_get(obj);
279 return wd->contents.left;
283 * Get the right/bottom content used for the panes
285 * Return the right/bottom content object which is set for this widget.
287 * @param[in] obj The pane object
288 * @return The Evas Object set as a right/bottom content of the pane
293 elm_panes_content_right_get(const Evas_Object *obj)
295 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
296 Widget_Data *wd = elm_widget_data_get(obj);
297 return wd->contents.right;
301 * Unset the left/top content used for the panes
303 * Unparent and return the left content object which was set for this widget.
305 * @param[in] obj The panes object
306 * @return The left/top content object that was being used
311 elm_panes_content_left_unset(Evas_Object *obj)
313 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
314 Widget_Data *wd = NULL;
315 Evas_Object *content = NULL;
317 wd = elm_widget_data_get(obj);
318 if (!wd) return NULL;
319 if (!wd->contents.left) return NULL;
320 content = wd->contents.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);
347 if (!wd) return NULL;
348 if (!wd->contents.right) return NULL;
350 content = wd->contents.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);