1 #include <Elementary.h>
3 #include "elm_widget_panes.h"
7 * Update the minimun height of the bar in the theme.
8 * No minimun should be set in the vertical theme
9 * Add events (move, start ...)
12 EAPI const char ELM_PANES_SMART_NAME[] = "elm_panes";
14 static const char SIG_CLICKED[] = "clicked";
15 static const char SIG_PRESS[] = "press";
16 static const char SIG_UNPRESS[] = "unpress";
17 static const char SIG_DOUBLE_CLICKED[] = "clicked,double";
18 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
22 {SIG_DOUBLE_CLICKED, ""},
26 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
28 {"left", "elm.swallow.left"},
29 {"right", "elm.swallow.right"},
30 {"top", "elm.swallow.left"},
31 {"bottom", "elm.swallow.right"},
35 EVAS_SMART_SUBCLASS_NEW
36 (ELM_PANES_SMART_NAME, _elm_panes, Elm_Panes_Smart_Class,
37 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
40 _elm_panes_smart_theme(Evas_Object *obj)
44 ELM_PANES_DATA_GET(obj, sd);
47 eina_stringshare_replace(&(ELM_LAYOUT_DATA(sd)->group), "horizontal");
49 eina_stringshare_replace(&(ELM_LAYOUT_DATA(sd)->group), "vertical");
51 if (!ELM_WIDGET_CLASS(_elm_panes_parent_sc)->theme(obj)) return EINA_FALSE;
53 size = elm_panes_content_left_size_get(obj);
55 if (sd->fixed) elm_layout_signal_emit(obj, "elm.panes.fixed", "elm");
57 elm_layout_sizing_eval(obj);
59 elm_panes_content_left_size_set(obj, size);
65 _elm_panes_smart_focus_next(const Evas_Object *obj,
66 Elm_Focus_Direction dir,
71 Evas_Object *to_focus;
72 Evas_Object *chain[2];
73 Evas_Object *left, *right;
75 ELM_PANES_DATA_GET(obj, sd);
77 edje_object_part_drag_value_get
78 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", &w, &h);
80 left = elm_layout_content_get(obj, "left");
81 right = elm_layout_content_get(obj, "right");
83 if (((sd->horizontal) && (h == 0.0)) || ((!sd->horizontal) && (w == 0.0)))
84 return elm_widget_focus_next_get(right, dir, next);
87 if (dir == ELM_FOCUS_PREVIOUS)
92 else if (dir == ELM_FOCUS_NEXT)
97 else return EINA_FALSE;
99 i = elm_widget_focus_get(chain[1]);
101 if (elm_widget_focus_next_get(chain[i], dir, next)) return EINA_TRUE;
105 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
115 _on_clicked(void *data,
116 Evas_Object *obj __UNUSED__,
117 const char *emission __UNUSED__,
118 const char *source __UNUSED__)
120 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
124 _double_clicked(void *data,
125 Evas_Object *obj __UNUSED__,
126 const char *emission __UNUSED__,
127 const char *source __UNUSED__)
129 ELM_PANES_DATA_GET(data, sd);
131 sd->double_clicked = EINA_TRUE;
135 _on_pressed(void *data,
136 Evas_Object *obj __UNUSED__,
137 const char *emission __UNUSED__,
138 const char *source __UNUSED__)
140 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
144 _on_unpressed(void *data,
145 Evas_Object *obj __UNUSED__,
146 const char *emission __UNUSED__,
147 const char *source __UNUSED__)
149 ELM_PANES_DATA_GET(data, sd);
150 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
152 if (sd->double_clicked)
154 evas_object_smart_callback_call(data, SIG_DOUBLE_CLICKED, NULL);
155 sd->double_clicked = EINA_FALSE;
160 _elm_panes_smart_add(Evas_Object *obj)
162 EVAS_SMART_DATA_ALLOC(obj, Elm_Panes_Smart_Data);
164 ELM_WIDGET_CLASS(_elm_panes_parent_sc)->base.add(obj);
169 _elm_panes_smart_set_user(Elm_Panes_Smart_Class *sc)
171 ELM_WIDGET_CLASS(sc)->base.add = _elm_panes_smart_add;
173 ELM_WIDGET_CLASS(sc)->theme = _elm_panes_smart_theme;
174 ELM_WIDGET_CLASS(sc)->focus_next = _elm_panes_smart_focus_next;
176 ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
179 EAPI const Elm_Panes_Smart_Class *
180 elm_panes_smart_class_get(void)
182 static Elm_Panes_Smart_Class _sc =
183 ELM_PANES_SMART_CLASS_INIT_NAME_VERSION(ELM_PANES_SMART_NAME);
184 static const Elm_Panes_Smart_Class *class = NULL;
185 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
190 _elm_panes_smart_set(&_sc);
191 esc->callbacks = _smart_callbacks;
198 elm_panes_add(Evas_Object *parent)
202 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
204 obj = elm_widget_add(_elm_panes_smart_class_new(), parent);
205 if (!obj) return NULL;
207 if (!elm_widget_sub_object_add(parent, obj))
208 ERR("could not add %p as sub object of %p", obj, parent);
210 elm_layout_theme_set(obj, "panes", "vertical", elm_widget_style_get(obj));
212 elm_panes_content_left_size_set(obj, 0.5);
214 ELM_WIDGET_DATA_GET(obj, wsd);
216 edje_object_signal_callback_add
217 (wsd->resize_obj, "elm,action,click", "",
219 edje_object_signal_callback_add
220 (wsd->resize_obj, "elm,action,click,double", "",
221 _double_clicked, obj);
222 edje_object_signal_callback_add
223 (wsd->resize_obj, "elm,action,press", "",
225 edje_object_signal_callback_add
226 (wsd->resize_obj, "elm,action,unpress", "",
229 elm_widget_can_focus_set(obj, EINA_FALSE);
231 elm_layout_sizing_eval(obj);
233 //Tizen Only: This should be removed when eo is applied.
234 wsd->on_create = EINA_FALSE;
239 EINA_DEPRECATED EAPI void
240 elm_panes_content_left_set(Evas_Object *obj,
241 Evas_Object *content)
243 elm_layout_content_set(obj, "left", content);
246 EINA_DEPRECATED EAPI void
247 elm_panes_content_right_set(Evas_Object *obj,
248 Evas_Object *content)
250 elm_layout_content_set(obj, "right", content);
253 EINA_DEPRECATED EAPI Evas_Object *
254 elm_panes_content_left_get(const Evas_Object *obj)
256 return elm_layout_content_get(obj, "left");
259 EINA_DEPRECATED EAPI Evas_Object *
260 elm_panes_content_right_get(const Evas_Object *obj)
262 return elm_layout_content_get(obj, "right");
265 EINA_DEPRECATED EAPI Evas_Object *
266 elm_panes_content_left_unset(Evas_Object *obj)
268 return elm_layout_content_unset(obj, "left");
271 EINA_DEPRECATED EAPI Evas_Object *
272 elm_panes_content_right_unset(Evas_Object *obj)
274 return elm_layout_content_unset(obj, "right");
278 elm_panes_content_left_size_get(const Evas_Object *obj)
282 ELM_PANES_CHECK(obj) 0.0;
283 ELM_PANES_DATA_GET(obj, sd);
285 edje_object_part_drag_value_get
286 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", &w, &h);
288 if (sd->horizontal) return h;
293 elm_panes_content_left_size_set(Evas_Object *obj,
296 ELM_PANES_CHECK(obj);
297 ELM_PANES_DATA_GET(obj, sd);
299 if (size < 0.0) size = 0.0;
303 edje_object_part_drag_value_set
304 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", 0.0, size);
306 edje_object_part_drag_value_set
307 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", size, 0.0);
311 elm_panes_content_right_size_get(const Evas_Object *obj)
313 return 1.0 - elm_panes_content_left_size_get(obj);
317 elm_panes_content_right_size_set(Evas_Object *obj,
320 elm_panes_content_left_size_set(obj, (1.0 - size));
324 elm_panes_horizontal_set(Evas_Object *obj,
325 Eina_Bool horizontal)
327 ELM_PANES_CHECK(obj);
328 ELM_PANES_DATA_GET(obj, sd);
330 sd->horizontal = horizontal;
331 _elm_panes_smart_theme(obj);
333 elm_panes_content_left_size_set(obj, 0.5);
337 elm_panes_horizontal_get(const Evas_Object *obj)
339 ELM_PANES_CHECK(obj) EINA_FALSE;
340 ELM_PANES_DATA_GET(obj, sd);
342 return sd->horizontal;
346 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
348 ELM_PANES_CHECK(obj);
349 ELM_PANES_DATA_GET(obj, sd);
352 if (sd->fixed == EINA_TRUE)
353 elm_layout_signal_emit(obj, "elm.panes.fixed", "elm");
355 elm_layout_signal_emit(obj, "elm.panes.unfixed", "elm");
359 elm_panes_fixed_get(const Evas_Object *obj)
361 ELM_PANES_CHECK(obj) EINA_FALSE;
362 ELM_PANES_DATA_GET(obj, sd);