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 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
58 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
60 if (wd->contents.left)
61 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.right);
62 if (wd->contents.right)
63 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
65 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
71 _sizing_eval(Evas_Object *obj)
73 Widget_Data *wd = elm_widget_data_get(obj);
78 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
86 Widget_Data *wd = elm_widget_data_get(obj);
87 Evas_Object *sub = event_info;
90 if (sub == wd->contents.left)
92 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
93 _changed_size_hints, obj);
94 wd->contents.left = NULL;
97 else if (sub == wd->contents.right)
99 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
100 _changed_size_hints, obj);
101 wd->contents.right= NULL;
107 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
109 evas_object_smart_callback_call(data, "clicked", NULL);
113 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
115 Widget_Data *wd = elm_widget_data_get(data);
117 wd->clicked_double = EINA_TRUE;
121 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
123 evas_object_smart_callback_call(data, "press", NULL);
127 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
129 Widget_Data *wd = elm_widget_data_get(data);
130 evas_object_smart_callback_call(data, "unpress", NULL);
132 if (wd->clicked_double)
134 evas_object_smart_callback_call(data, "clicked,double", NULL);
135 wd->clicked_double = EINA_FALSE;
140 * Add a new panes to the parent
142 * @param parent The parent object
143 * @return The new object or NULL if it cannot be created
148 elm_panes_add(Evas_Object *parent)
154 wd = ELM_NEW(Widget_Data);
155 e = evas_object_evas_get(parent);
156 obj = elm_widget_add(e);
157 ELM_SET_WIDTYPE(widtype, "panes");
158 elm_widget_type_set(obj, widtype);
159 elm_widget_sub_object_add(parent, obj);
160 elm_widget_data_set(obj, wd);
161 elm_widget_del_hook_set(obj, _del_hook);
162 elm_widget_theme_hook_set(obj, _theme_hook);
163 wd->contents.left = NULL;
164 wd->contents.right = NULL;
166 wd->panes = edje_object_add(e);
167 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
168 elm_widget_resize_object_set(obj, wd->panes);
169 evas_object_show(wd->panes);
171 elm_panes_content_left_size_set(obj, 0.5);
173 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
175 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
176 _clicked_double, obj);
177 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
179 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
182 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
183 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
184 _changed_size_hints, obj);
191 * Set a control as a left/top content of the pane
193 * @param obj The pane object
194 * @param content The object to be set as content
198 EAPI void elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
200 Widget_Data *wd = elm_widget_data_get(obj);
202 if (wd->contents.left)
204 evas_object_del(wd->contents.left);
205 wd->contents.left = NULL;
210 wd->contents.left = content;
211 elm_widget_sub_object_add(obj, content);
212 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
217 * Set a control as a right/bottom content of the pane
219 * @param obj The pane object
220 * @param content The object to be set as content
224 EAPI void elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
226 Widget_Data *wd = elm_widget_data_get(obj);
228 if (wd->contents.right)
230 evas_object_del(wd->contents.right);
231 wd->contents.right = NULL;
236 wd->contents.right = content;
237 elm_widget_sub_object_add(obj, content);
238 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
239 edje_object_signal_emit(wd->panes, "panes_pair", "elm");
244 * Get the left/top content of the pane
246 * @param obj The pane object
247 * @return The Evas Object set as a left/top content of the pane
252 *elm_panes_content_left_get(const Evas_Object *obj)
254 Widget_Data *wd = elm_widget_data_get(obj);
255 return wd->contents.left;
259 * Get the right/bottom content of the pane
261 * @param obj The pane object
262 * @return The Evas Object set as a right/bottom content of the pane
267 *elm_panes_content_right_get(const Evas_Object *obj)
269 Widget_Data *wd = elm_widget_data_get(obj);
270 return wd->contents.right;
274 * Unset a control from a left/top content of the pane
276 * @param obj The pane object
277 * @return The content being unset
282 elm_panes_content_left_unset(Evas_Object *obj)
284 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
286 Evas_Object *content;
288 wd = elm_widget_data_get(obj);
290 content = edje_object_part_swallow_get(wd->panes, "elm.swallow.left");
291 if(!content) return NULL;
292 edje_object_part_unswallow(wd->panes, content);
293 elm_widget_sub_object_del(obj, content);
294 evas_object_hide(content);
295 wd->contents.left = NULL;
296 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
301 * Unset a control from a right/bottom content of the pane
303 * @param obj The pane object
304 * @return The content being unset
309 elm_panes_content_right_unset(Evas_Object *obj)
311 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
313 Evas_Object *content;
315 wd = elm_widget_data_get(obj);
317 content = edje_object_part_swallow_get(wd->panes, "elm.swallow.right");
318 if(!content) return NULL;
319 edje_object_part_unswallow(wd->panes, content);
320 elm_widget_sub_object_del(obj, content);
321 evas_object_hide(content);
322 wd->contents.right = NULL;
323 edje_object_signal_emit(wd->panes, "panes_unpair", "elm");
328 * Get the relative normalized size of left/top content of the pane
330 * @param obj The pane object
331 * @return The value of type double in the range [0.0,1.0]
336 elm_panes_content_left_size_get(const Evas_Object *obj)
338 Widget_Data *wd = elm_widget_data_get(obj);
341 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
350 * Set a size of the left content with a relative normalized double value
352 * @param obj The pane object
353 * @param size The value of type double in the range [0.0,1.0]
358 elm_panes_content_left_size_set(Evas_Object *obj, double size)
360 Widget_Data *wd = elm_widget_data_get(obj);
363 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
365 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
369 * Set the type of an existing pane object to horizontal/vertical
371 * @param obj The pane object
372 * @param horizontal Boolean value. If true, then the type is set to horizontal else vertical
377 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
379 Widget_Data *wd = elm_widget_data_get(obj);
381 wd->horizontal = horizontal;
383 elm_panes_content_left_size_set(obj, 0.5);
387 * Indicate if the type of pane object is horizontal or not
389 * @param obj The pane object
390 * @return true if it is of horizontal type else false
395 elm_panes_horizontal_is(const Evas_Object *obj)
397 Widget_Data *wd = elm_widget_data_get(obj);
399 return wd->horizontal;
403 * Set a handler of the pane object non-movable or movable
405 * @param obj The pane object
406 * @param fixed If set to true then the views size can't be changed using handler otherwise using handler they can be resized
411 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
413 Widget_Data *wd = elm_widget_data_get(obj);
415 if(wd->fixed == EINA_TRUE)
416 edje_object_signal_emit(wd->panes, "elm.fixed", "movement.decider");
418 edje_object_signal_emit(wd->panes, "elm.unfixed", "movement.decider");
422 * Indicate if the handler of the pane object can be moved with user interaction
424 * @param obj The pane object
425 * @return false if the views can be resized using handler else true
430 elm_panes_fixed_is(const Evas_Object *obj)
432 Widget_Data *wd = elm_widget_data_get(obj);