1 #include <Elementary.h>
6 * Update the minimun height of the bar in the theme.
7 * No minimun should be set in the vertical theme
8 * Add events (move, start ...)
11 typedef struct _Widget_Data Widget_Data;
30 Eina_Bool clicked_double;
35 static const char *widtype = NULL;
36 static void _del_hook(Evas_Object *obj);
37 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
38 static void _theme_hook(Evas_Object *obj);
39 static void _sizing_eval(Evas_Object *obj);
40 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
42 static const char SIG_CLICKED[] = "clicked";
43 static const char SIG_PRESS[] = "press";
44 static const char SIG_UNPRESS[] = "unpress";
45 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
47 static const Evas_Smart_Cb_Description _signals[] = {
51 {SIG_CLICKED_DOUBLE, ""},
56 _del_hook(Evas_Object *obj)
58 Widget_Data *wd = elm_widget_data_get(obj);
64 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
66 Widget_Data *wd = elm_widget_data_get(obj);
68 edje_object_mirrored_set(wd->panes, rtl);
72 _theme_hook(Evas_Object *obj)
74 Widget_Data *wd = elm_widget_data_get(obj);
75 const char *style = elm_widget_style_get(obj);
79 _elm_widget_mirrored_reload(obj);
80 _mirrored_set(obj, elm_widget_mirrored_get(obj));
81 size = elm_panes_content_left_size_get(obj);
84 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
86 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
88 if (wd->contents.left)
89 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.left);
90 if (wd->contents.right)
91 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
92 if(wd->contents.left && wd->contents.right)
93 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
95 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
97 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
100 elm_panes_content_left_size_set(obj, size);
104 _elm_panes_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
106 Widget_Data *wd = elm_widget_data_get(obj);
107 if (!wd) return EINA_FALSE;
110 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
111 if (((wd->horizontal) && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
112 return elm_widget_focus_next_get(wd->contents.right, dir, next);
114 Evas_Object *chain[2];
117 if (dir == ELM_FOCUS_PREVIOUS)
119 chain[0] = wd->contents.right;
120 chain[1] = wd->contents.left;
122 else if (dir == ELM_FOCUS_NEXT)
124 chain[0] = wd->contents.left;
125 chain[1] = wd->contents.right;
130 unsigned char i = elm_widget_focus_get(chain[1]);
132 if (elm_widget_focus_next_get(chain[i], dir, next))
137 Evas_Object *to_focus;
138 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
148 _sizing_eval(Evas_Object *obj)
150 Widget_Data *wd = elm_widget_data_get(obj);
155 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
161 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
163 Widget_Data *wd = elm_widget_data_get(obj);
164 Evas_Object *sub = event_info;
167 if (sub == wd->contents.left)
169 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
170 _changed_size_hints, obj);
171 wd->contents.left = NULL;
174 else if (sub == wd->contents.right)
176 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
177 _changed_size_hints, obj);
178 wd->contents.right= NULL;
184 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
186 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
190 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
192 Widget_Data *wd = elm_widget_data_get(data);
194 wd->clicked_double = EINA_TRUE;
198 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
200 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
204 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
206 Widget_Data *wd = elm_widget_data_get(data);
207 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
209 if (wd->clicked_double)
211 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
212 wd->clicked_double = EINA_FALSE;
217 _content_left_set(Evas_Object *obj, Evas_Object *content)
219 Widget_Data *wd = elm_widget_data_get(obj);
220 if (wd->contents.left)
222 evas_object_del(wd->contents.left);
223 wd->contents.left = NULL;
224 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
228 wd->contents.left = content;
229 elm_widget_sub_object_add(obj, content);
230 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
231 if (wd->contents.right)
232 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
237 _content_right_set(Evas_Object *obj, Evas_Object *content)
239 Widget_Data *wd = elm_widget_data_get(obj);
240 if (wd->contents.right)
242 evas_object_del(wd->contents.right);
243 wd->contents.right = NULL;
244 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
248 wd->contents.right = content;
249 elm_widget_sub_object_add(obj, content);
250 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
251 if (wd->contents.left)
252 edje_object_signal_emit(wd->panes, "elm.panes.pair", "elm");
257 _content_left_unset(Evas_Object *obj)
259 Widget_Data *wd = elm_widget_data_get(obj);
260 if (!wd->contents.left) return NULL;
261 Evas_Object *content = wd->contents.left;
262 elm_widget_sub_object_del(obj, content);
263 edje_object_part_unswallow(wd->panes, content);
264 wd->contents.left = NULL;
265 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
270 _content_right_unset(Evas_Object *obj)
272 Widget_Data *wd = elm_widget_data_get(obj);
273 if (!wd->contents.right) return NULL;
274 Evas_Object *content = wd->contents.right;
275 elm_widget_sub_object_del(obj, content);
276 edje_object_part_unswallow(wd->panes, content);
277 wd->contents.right = NULL;
278 edje_object_signal_emit(wd->panes, "elm.panes.unpair", "elm");
283 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
285 ELM_CHECK_WIDTYPE(obj, widtype);
286 Widget_Data *wd = elm_widget_data_get(obj);
288 if (!part || !strcmp(part, "right"))
289 _content_right_set(obj, content);
290 else if(!strcmp(part, "left"))
291 _content_left_set(obj, content);
295 _content_get_hook(const Evas_Object *obj, const char *part)
297 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
298 Widget_Data *wd = elm_widget_data_get(obj);
299 if (!wd) return NULL;
300 if (!part || !strcmp(part, "right"))
301 return wd->contents.right;
302 else if (!strcmp(part, "left"))
303 return wd->contents.left;
308 _content_unset_hook(Evas_Object *obj, const char *part)
310 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
311 Widget_Data *wd = elm_widget_data_get(obj);
312 if (!wd) return NULL;
313 if (!part || !strcmp(part, "right"))
314 return _content_right_unset(obj);
315 else if (!strcmp(part, "left"))
316 return _content_left_unset(obj);
321 elm_panes_add(Evas_Object *parent)
327 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
329 ELM_SET_WIDTYPE(widtype, "panes");
330 elm_widget_type_set(obj, "panes");
331 elm_widget_sub_object_add(parent, obj);
332 elm_widget_data_set(obj, wd);
333 elm_widget_del_hook_set(obj, _del_hook);
334 elm_widget_theme_hook_set(obj, _theme_hook);
335 elm_widget_focus_next_hook_set(obj, _elm_panes_focus_next_hook);
336 elm_widget_content_set_hook_set(obj, _content_set_hook);
337 elm_widget_content_get_hook_set(obj, _content_get_hook);
338 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
339 elm_widget_can_focus_set(obj, EINA_FALSE);
341 wd->panes = edje_object_add(e);
342 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
343 elm_widget_resize_object_set(obj, wd->panes);
344 evas_object_show(wd->panes);
346 elm_panes_content_left_size_set(obj, 0.5);
348 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
350 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
351 _clicked_double, obj);
352 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
354 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
357 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
358 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
359 _changed_size_hints, obj);
361 evas_object_smart_callbacks_descriptions_set(obj, _signals);
363 _mirrored_set(obj, elm_widget_mirrored_get(obj));
369 elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
371 _content_set_hook(obj, "left", content);
375 elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
377 _content_set_hook(obj, "right", content);
381 elm_panes_content_left_get(const Evas_Object *obj)
383 return _content_get_hook(obj, "left");
387 elm_panes_content_right_get(const Evas_Object *obj)
389 return _content_get_hook(obj, "right");
393 elm_panes_content_left_unset(Evas_Object *obj)
395 return _content_unset_hook(obj, "left");
399 elm_panes_content_right_unset(Evas_Object *obj)
401 return _content_unset_hook(obj, "right");
405 elm_panes_content_left_size_get(const Evas_Object *obj)
407 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
408 Widget_Data *wd = elm_widget_data_get(obj);
412 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
413 if (wd->horizontal) return h;
418 elm_panes_content_left_size_set(Evas_Object *obj, double size)
420 ELM_CHECK_WIDTYPE(obj, widtype);
421 Widget_Data *wd = elm_widget_data_get(obj);
424 if (size < 0.0) size = 0.0;
425 else if (size > 1.0) size = 1.0;
427 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
429 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
433 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
435 ELM_CHECK_WIDTYPE(obj, widtype);
436 Widget_Data *wd = elm_widget_data_get(obj);
439 wd->horizontal = horizontal;
441 elm_panes_content_left_size_set(obj, 0.5);
445 elm_panes_horizontal_get(const Evas_Object *obj)
447 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
448 Widget_Data *wd = elm_widget_data_get(obj);
449 if (!wd) return EINA_FALSE;
450 return wd->horizontal;
454 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
456 ELM_CHECK_WIDTYPE(obj, widtype);
457 Widget_Data *wd = elm_widget_data_get(obj);
460 if (wd->fixed == EINA_TRUE)
461 edje_object_signal_emit(wd->panes, "elm.panes.fixed", "elm");
463 edje_object_signal_emit(wd->panes, "elm.panes.unfixed", "elm");
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);
471 if (!wd) return EINA_FALSE;