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"},
33 EVAS_SMART_SUBCLASS_NEW
34 (ELM_PANES_SMART_NAME, _elm_panes, Elm_Panes_Smart_Class,
35 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
38 _elm_panes_smart_theme(Evas_Object *obj)
42 ELM_PANES_DATA_GET(obj, sd);
45 eina_stringshare_replace(&(ELM_LAYOUT_DATA(sd)->group), "horizontal");
47 eina_stringshare_replace(&(ELM_LAYOUT_DATA(sd)->group), "vertical");
49 if (!ELM_WIDGET_CLASS(_elm_panes_parent_sc)->theme(obj)) return EINA_FALSE;
51 size = elm_panes_content_left_size_get(obj);
53 if (sd->fixed) elm_layout_signal_emit(obj, "elm.panes.fixed", "elm");
55 elm_layout_sizing_eval(obj);
57 elm_panes_content_left_size_set(obj, size);
63 _elm_panes_smart_focus_next(const Evas_Object *obj,
64 Elm_Focus_Direction dir,
69 Evas_Object *to_focus;
70 Evas_Object *chain[2];
71 Evas_Object *left, *right;
73 ELM_PANES_DATA_GET(obj, sd);
75 edje_object_part_drag_value_get
76 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", &w, &h);
78 left = elm_layout_content_get(obj, "left");
79 right = elm_layout_content_get(obj, "right");
81 if (((sd->horizontal) && (h == 0.0)) || ((!sd->horizontal) && (w == 0.0)))
82 return elm_widget_focus_next_get(right, dir, next);
85 if (dir == ELM_FOCUS_PREVIOUS)
90 else if (dir == ELM_FOCUS_NEXT)
95 else return EINA_FALSE;
97 i = elm_widget_focus_get(chain[1]);
99 if (elm_widget_focus_next_get(chain[i], dir, next)) return EINA_TRUE;
103 if (elm_widget_focus_next_get(chain[i], dir, &to_focus))
113 _on_clicked(void *data,
114 Evas_Object *obj __UNUSED__,
115 const char *emission __UNUSED__,
116 const char *source __UNUSED__)
118 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
122 _double_clicked(void *data,
123 Evas_Object *obj __UNUSED__,
124 const char *emission __UNUSED__,
125 const char *source __UNUSED__)
127 ELM_PANES_DATA_GET(data, sd);
129 sd->double_clicked = EINA_TRUE;
133 _on_pressed(void *data,
134 Evas_Object *obj __UNUSED__,
135 const char *emission __UNUSED__,
136 const char *source __UNUSED__)
138 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
142 _on_unpressed(void *data,
143 Evas_Object *obj __UNUSED__,
144 const char *emission __UNUSED__,
145 const char *source __UNUSED__)
147 ELM_PANES_DATA_GET(data, sd);
148 evas_object_smart_callback_call(data, SIG_UNPRESS, NULL);
150 if (sd->double_clicked)
152 evas_object_smart_callback_call(data, SIG_DOUBLE_CLICKED, NULL);
153 sd->double_clicked = EINA_FALSE;
158 _elm_panes_smart_add(Evas_Object *obj)
160 EVAS_SMART_DATA_ALLOC(obj, Elm_Panes_Smart_Data);
162 ELM_WIDGET_CLASS(_elm_panes_parent_sc)->base.add(obj);
164 elm_layout_theme_set(obj, "panes", "vertical", elm_widget_style_get(obj));
166 elm_panes_content_left_size_set(obj, 0.5);
168 edje_object_signal_callback_add
169 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,click", "",
171 edje_object_signal_callback_add
172 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,click,double", "",
173 _double_clicked, obj);
174 edje_object_signal_callback_add
175 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,press", "",
177 edje_object_signal_callback_add
178 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,unpress", "",
181 elm_widget_can_focus_set(obj, EINA_FALSE);
183 elm_layout_sizing_eval(obj);
187 _elm_panes_smart_set_user(Elm_Panes_Smart_Class *sc)
189 ELM_WIDGET_CLASS(sc)->base.add = _elm_panes_smart_add;
191 ELM_WIDGET_CLASS(sc)->theme = _elm_panes_smart_theme;
192 ELM_WIDGET_CLASS(sc)->focus_next = _elm_panes_smart_focus_next;
194 ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
197 EAPI const Elm_Panes_Smart_Class *
198 elm_panes_smart_class_get(void)
200 static Elm_Panes_Smart_Class _sc =
201 ELM_PANES_SMART_CLASS_INIT_NAME_VERSION(ELM_PANES_SMART_NAME);
202 static const Elm_Panes_Smart_Class *class = NULL;
203 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
208 _elm_panes_smart_set(&_sc);
209 esc->callbacks = _smart_callbacks;
216 elm_panes_add(Evas_Object *parent)
220 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
222 obj = elm_widget_add(_elm_panes_smart_class_new(), parent);
223 if (!obj) return NULL;
225 if (!elm_widget_sub_object_add(parent, obj))
226 ERR("could not add %p as sub object of %p", obj, parent);
231 EINA_DEPRECATED EAPI void
232 elm_panes_content_left_set(Evas_Object *obj,
233 Evas_Object *content)
235 elm_layout_content_set(obj, "left", content);
238 EINA_DEPRECATED EAPI void
239 elm_panes_content_right_set(Evas_Object *obj,
240 Evas_Object *content)
242 elm_layout_content_set(obj, "right", content);
245 EINA_DEPRECATED EAPI Evas_Object *
246 elm_panes_content_left_get(const Evas_Object *obj)
248 return elm_layout_content_get(obj, "left");
251 EINA_DEPRECATED EAPI Evas_Object *
252 elm_panes_content_right_get(const Evas_Object *obj)
254 return elm_layout_content_get(obj, "right");
257 EINA_DEPRECATED EAPI Evas_Object *
258 elm_panes_content_left_unset(Evas_Object *obj)
260 return elm_layout_content_unset(obj, "left");
263 EINA_DEPRECATED EAPI Evas_Object *
264 elm_panes_content_right_unset(Evas_Object *obj)
266 return elm_layout_content_unset(obj, "right");
270 elm_panes_content_left_size_get(const Evas_Object *obj)
274 ELM_PANES_CHECK(obj) 0.0;
275 ELM_PANES_DATA_GET(obj, sd);
277 edje_object_part_drag_value_get
278 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", &w, &h);
280 if (sd->horizontal) return h;
285 elm_panes_content_left_size_set(Evas_Object *obj,
288 ELM_PANES_CHECK(obj);
289 ELM_PANES_DATA_GET(obj, sd);
291 if (size < 0.0) size = 0.0;
295 edje_object_part_drag_value_set
296 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", 0.0, size);
298 edje_object_part_drag_value_set
299 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.bar", size, 0.0);
303 elm_panes_content_right_size_get(const Evas_Object *obj)
305 return 1.0 - elm_panes_content_left_size_get(obj);
309 elm_panes_content_right_size_set(Evas_Object *obj,
312 elm_panes_content_left_size_set(obj, (1.0 - size));
316 elm_panes_horizontal_set(Evas_Object *obj,
317 Eina_Bool horizontal)
319 ELM_PANES_CHECK(obj);
320 ELM_PANES_DATA_GET(obj, sd);
322 sd->horizontal = horizontal;
323 _elm_panes_smart_theme(obj);
325 elm_panes_content_left_size_set(obj, 0.5);
329 elm_panes_horizontal_get(const Evas_Object *obj)
331 ELM_PANES_CHECK(obj) EINA_FALSE;
332 ELM_PANES_DATA_GET(obj, sd);
334 return sd->horizontal;
338 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
340 ELM_PANES_CHECK(obj);
341 ELM_PANES_DATA_GET(obj, sd);
344 if (sd->fixed == EINA_TRUE)
345 elm_layout_signal_emit(obj, "elm.panes.fixed", "elm");
347 elm_layout_signal_emit(obj, "elm.panes.unfixed", "elm");
351 elm_panes_fixed_get(const Evas_Object *obj)
353 ELM_PANES_CHECK(obj) EINA_FALSE;
354 ELM_PANES_DATA_GET(obj, sd);