1 #include <Elementary.h>
5 * @defgroup Conformant Conformant
8 * The aim is to provide a widget that can be used in elementary apps to
9 * account for space taken up by the indicator & softkey windows when running
10 * the illume2 module of E17.
13 typedef struct _Widget_Data Widget_Data;
17 Evas_Object *shelf, *panel;
19 Ecore_Event_Handler *prop_hdl;
21 Ecore_Animator *animator; // animaton timer
22 double start; // time started
23 Evas_Coord auto_x, auto_y; // desired delta
24 Evas_Coord x, y; // current delta
28 /* local function prototypes */
29 static const char *widtype = NULL;
30 static void _del_hook(Evas_Object *obj);
31 static void _theme_hook(Evas_Object *obj);
32 static void _sizing_eval(Evas_Object *obj);
33 static int _prop_change(void *data, int type, void *event);
37 _del_hook(Evas_Object *obj)
39 Widget_Data *wd = elm_widget_data_get(obj);
41 if (wd->prop_hdl) ecore_event_handler_del(wd->prop_hdl);
46 _theme_hook(Evas_Object *obj)
48 Widget_Data *wd = elm_widget_data_get(obj);
50 _elm_theme_object_set(obj, wd->base, "conformant", "base", elm_widget_style_get(obj));
52 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->content);
53 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
58 _sizing_eval(Evas_Object *obj)
60 Widget_Data *wd = elm_widget_data_get(obj);
61 Evas_Coord mw = -1, mh = -1;
63 edje_object_size_min_calc(wd->base, &mw, &mh);
64 evas_object_size_hint_min_set(obj, mw, mh);
65 evas_object_size_hint_max_set(obj, -1, -1);
69 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
71 Widget_Data *wd = elm_widget_data_get(data);
77 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
79 Widget_Data *wd = elm_widget_data_get(obj);
80 Evas_Object *sub = event_info;
82 if (sub == wd->content)
84 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
85 _changed_size_hints, obj);
91 /* unused now - but meant to be for making sure the focused widget is always
92 * visible when the vkbd comes and goes by moving the conformant obj (and thus
93 * its children) to show the focused widget (and if focus changes follow)
96 _focus_object_get(const Evas_Object *obj)
98 Evas_Object *win, *foc;
100 win = elm_widget_top_get(obj);
101 if (!win) return NULL;
102 foc = elm_widget_top_get(win);
106 _focus_object_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
108 evas_object_geometry_get(obj, x, y, w, h);
112 _focus_change_del(void *data, Evas_Object *obj, void *event_info)
114 // called from toplevel when the focused window shanges
118 _autoscroll_move(Evas_Object *obj)
120 // move conformant edje by delta to show focused widget
124 _autoscroll_mode_enable(Evas_Object *obj)
126 // called when autoscroll mode should be on - content area smaller than
128 // 1. get focused object
129 // 2. if not in visible conformant area calculate delta needed to
131 // 3. store delta and call _autoscroll_move() which either asanimates
132 // or jumps right there
136 _autoscroll_mode_disable(Evas_Object *obj)
138 // called when autoscroll mode should be off - set delta to 0 and
139 // call _autoscroll_move()
144 _prop_change(void *data, int type __UNUSED__, void *event)
146 #ifdef HAVE_ELEMENTARY_X
147 Ecore_X_Event_Window_Property *ev;
148 Widget_Data *wd = elm_widget_data_get(data);
151 if (ev->atom == ECORE_X_ATOM_E_ILLUME_ZONE)
156 zone = ecore_x_e_illume_zone_get(ev->win);
157 ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
159 evas_object_size_hint_min_set(wd->shelf, -1, sh);
160 evas_object_size_hint_max_set(wd->shelf, -1, sh);
162 ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
164 evas_object_size_hint_min_set(wd->panel, -1, sh);
165 evas_object_size_hint_max_set(wd->panel, -1, sh);
167 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY)
172 zone = ecore_x_e_illume_zone_get(ev->win);
173 ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
175 evas_object_size_hint_min_set(wd->shelf, -1, sh);
176 evas_object_size_hint_max_set(wd->shelf, -1, sh);
178 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY)
183 zone = ecore_x_e_illume_zone_get(ev->win);
184 ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
186 evas_object_size_hint_min_set(wd->panel, -1, sh);
187 evas_object_size_hint_max_set(wd->panel, -1, sh);
189 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY)
194 printf("Keyboard Geometry Changed\n");
195 zone = ecore_x_e_illume_zone_get(ev->win);
196 ecore_x_e_illume_keyboard_geometry_get(zone, NULL, &ky, NULL, NULL);
197 printf("\tGeom: %d\n", ky);
205 * Add a new Conformant object
207 * @param parent The parent object
208 * @return The new conformant object or NULL if it cannot be created
210 * @ingroup Conformant
213 elm_conformant_add(Evas_Object *parent)
219 wd = ELM_NEW(Widget_Data);
221 evas = evas_object_evas_get(parent);
223 obj = elm_widget_add(evas);
224 ELM_SET_WIDTYPE(widtype, "conformant");
225 elm_widget_type_set(obj, "conformant");
226 elm_widget_sub_object_add(parent, obj);
227 elm_widget_data_set(obj, wd);
228 elm_widget_del_hook_set(obj, _del_hook);
229 elm_widget_theme_hook_set(obj, _theme_hook);
231 wd->base = edje_object_add(evas);
232 _elm_theme_object_set(obj, wd->base, "conformant", "base", "default");
233 elm_widget_resize_object_set(obj, wd->base);
235 #ifdef HAVE_ELEMENTARY_X
236 Ecore_X_Window zone, xwin;
239 xwin = elm_win_xwindow_get(parent);
240 zone = ecore_x_e_illume_zone_get(xwin);
242 ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
244 wd->shelf = evas_object_rectangle_add(evas);
245 evas_object_color_set(wd->shelf, 0, 0, 0, 0);
246 evas_object_size_hint_min_set(wd->shelf, -1, sh);
247 evas_object_size_hint_max_set(wd->shelf, -1, sh);
248 edje_object_part_swallow(wd->base, "elm.swallow.shelf", wd->shelf);
251 ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
253 wd->panel = evas_object_rectangle_add(evas);
254 evas_object_color_set(wd->panel, 0, 0, 0, 0);
255 evas_object_size_hint_min_set(wd->panel, -1, sh);
256 evas_object_size_hint_max_set(wd->panel, -1, sh);
257 edje_object_part_swallow(wd->base, "elm.swallow.panel", wd->panel);
259 wd->prop_hdl = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
261 // FIXME: get kbd region prop
264 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
271 * Set the content of the conformant widget
273 * @param obj The conformant object
274 * @param content The content that will be used inside this conformant object
276 * @ingroup Conformant
279 elm_conformant_content_set(Evas_Object *obj, Evas_Object *content)
281 ELM_CHECK_WIDTYPE(obj, widtype);
282 Widget_Data *wd = elm_widget_data_get(obj);
284 if ((wd->content != content) && (wd->content))
285 elm_widget_sub_object_del(obj, wd->content);
286 wd->content = content;
289 elm_widget_sub_object_add(obj, content);
290 evas_object_event_callback_add(content,
291 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
292 _changed_size_hints, obj);
293 edje_object_part_swallow(wd->base, "elm.swallow.content", content);