2010-01-08 10:00:33 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2010-02-08 18:46:19 -08:00
|
|
|
/**
|
|
|
|
* @defgroup Conformant Conformant
|
|
|
|
*
|
|
|
|
* The aim is to provide a widget that can be used in elementary apps to
|
|
|
|
* account for space taken up by the indicator & softkey windows when running
|
|
|
|
* the illume2 module of E17.
|
|
|
|
*/
|
|
|
|
|
2010-01-08 10:00:33 -08:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *base;
|
2010-01-13 18:45:15 -08:00
|
|
|
Evas_Object *shelf, *panel;
|
2010-01-08 10:00:33 -08:00
|
|
|
Evas_Object *content;
|
2010-01-26 17:48:18 -08:00
|
|
|
Ecore_Event_Handler *prop_hdl;
|
2010-02-04 22:14:50 -08:00
|
|
|
struct {
|
|
|
|
Ecore_Animator *animator; // animaton timer
|
|
|
|
double start; // time started
|
|
|
|
Evas_Coord auto_x, auto_y; // desired delta
|
|
|
|
Evas_Coord x, y; // current delta
|
|
|
|
} delta;
|
2010-01-08 10:00:33 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* local function prototypes */
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2010-01-08 10:00:33 -08:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _theme_hook(Evas_Object *obj);
|
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
2010-01-26 17:48:18 -08:00
|
|
|
static int _prop_change(void *data, int type, void *event);
|
2010-01-08 10:00:33 -08:00
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-01-26 17:48:18 -08:00
|
|
|
if (wd->prop_hdl) ecore_event_handler_del(wd->prop_hdl);
|
2010-01-08 10:00:33 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->base, "conformant", "base", elm_widget_style_get(obj));
|
2010-01-08 10:00:33 -08:00
|
|
|
if (wd->content)
|
|
|
|
edje_object_part_swallow(wd->base, "elm.swallow.content", wd->content);
|
|
|
|
edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord mw = -1, mh = -1;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-01-08 10:00:33 -08:00
|
|
|
edje_object_size_min_calc(wd->base, &mw, &mh);
|
|
|
|
evas_object_size_hint_min_set(obj, mw, mh);
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
|
|
|
}
|
|
|
|
|
2010-02-04 01:08:02 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2010-02-04 01:08:02 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-02-04 01:08:02 -08:00
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
2010-02-04 01:08:02 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *sub = event_info;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-02-04 01:08:02 -08:00
|
|
|
if (sub == wd->content)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
wd->content = NULL;
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-04 22:14:50 -08:00
|
|
|
/* unused now - but meant to be for making sure the focused widget is always
|
|
|
|
* visible when the vkbd comes and goes by moving the conformant obj (and thus
|
|
|
|
* its children) to show the focused widget (and if focus changes follow)
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_focus_object_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *foc;
|
|
|
|
|
|
|
|
win = elm_widget_top_get(obj);
|
|
|
|
if (!win) return NULL;
|
|
|
|
foc = elm_widget_top_get(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_focus_object_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
|
|
|
evas_object_geometry_get(obj, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_focus_change_del(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
// called from toplevel when the focused window shanges
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_autoscroll_move(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
// move conformant edje by delta to show focused widget
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_autoscroll_mode_enable(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
// called when autoscroll mode should be on - content area smaller than
|
|
|
|
// its min size
|
|
|
|
// 1. get focused object
|
|
|
|
// 2. if not in visible conformant area calculate delta needed to
|
|
|
|
// get it in
|
|
|
|
// 3. store delta and call _autoscroll_move() which either asanimates
|
|
|
|
// or jumps right there
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_autoscroll_mode_disable(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
// called when autoscroll mode should be off - set delta to 0 and
|
|
|
|
// call _autoscroll_move()
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2010-01-26 17:48:18 -08:00
|
|
|
static int
|
2010-03-09 09:51:30 -08:00
|
|
|
_prop_change(void *data, int type __UNUSED__, void *event)
|
2010-01-26 17:48:18 -08:00
|
|
|
{
|
2010-02-02 05:55:55 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2010-01-26 17:48:18 -08:00
|
|
|
Ecore_X_Event_Window_Property *ev;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return 1;
|
2010-01-26 17:48:18 -08:00
|
|
|
ev = event;
|
2010-02-18 18:33:17 -08:00
|
|
|
if (ev->atom == ECORE_X_ATOM_E_ILLUME_ZONE)
|
2010-01-26 17:48:18 -08:00
|
|
|
{
|
2010-02-18 18:33:17 -08:00
|
|
|
Ecore_X_Window zone;
|
2010-01-26 17:48:18 -08:00
|
|
|
int sh = -1;
|
|
|
|
|
2010-02-18 18:33:17 -08:00
|
|
|
zone = ecore_x_e_illume_zone_get(ev->win);
|
|
|
|
ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
|
2010-01-26 20:03:22 -08:00
|
|
|
if (sh < 0) sh = 0;
|
2010-01-26 17:48:18 -08:00
|
|
|
evas_object_size_hint_min_set(wd->shelf, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->shelf, -1, sh);
|
2010-02-18 18:33:17 -08:00
|
|
|
sh = -1;
|
|
|
|
ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
|
|
|
|
if (sh < 0) sh = 0;
|
|
|
|
evas_object_size_hint_min_set(wd->panel, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->panel, -1, sh);
|
2010-01-26 17:48:18 -08:00
|
|
|
}
|
2010-02-18 18:33:17 -08:00
|
|
|
else if (ev->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY)
|
2010-01-26 17:48:18 -08:00
|
|
|
{
|
2010-02-18 18:33:17 -08:00
|
|
|
Ecore_X_Window zone;
|
2010-01-26 17:48:18 -08:00
|
|
|
int sh = -1;
|
|
|
|
|
2010-02-18 18:33:17 -08:00
|
|
|
zone = ecore_x_e_illume_zone_get(ev->win);
|
|
|
|
ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
|
|
|
|
if (sh < 0) sh = 0;
|
|
|
|
evas_object_size_hint_min_set(wd->shelf, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->shelf, -1, sh);
|
|
|
|
}
|
|
|
|
else if (ev->atom == ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY)
|
|
|
|
{
|
|
|
|
Ecore_X_Window zone;
|
|
|
|
int sh = -1;
|
|
|
|
|
|
|
|
zone = ecore_x_e_illume_zone_get(ev->win);
|
|
|
|
ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
|
2010-01-26 20:03:22 -08:00
|
|
|
if (sh < 0) sh = 0;
|
2010-01-26 17:48:18 -08:00
|
|
|
evas_object_size_hint_min_set(wd->panel, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->panel, -1, sh);
|
|
|
|
}
|
2010-02-23 12:54:39 -08:00
|
|
|
else if (ev->atom == ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY)
|
|
|
|
{
|
|
|
|
Ecore_X_Window zone;
|
|
|
|
int ky = -1;
|
2010-02-18 18:33:17 -08:00
|
|
|
|
2010-02-23 12:54:39 -08:00
|
|
|
printf("Keyboard Geometry Changed\n");
|
|
|
|
zone = ecore_x_e_illume_zone_get(ev->win);
|
|
|
|
ecore_x_e_illume_keyboard_geometry_get(zone, NULL, &ky, NULL, NULL);
|
|
|
|
printf("\tGeom: %d\n", ky);
|
|
|
|
}
|
2010-02-02 05:55:55 -08:00
|
|
|
#endif
|
2010-01-26 17:48:18 -08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-08 18:46:19 -08:00
|
|
|
/**
|
|
|
|
* Add a new Conformant object
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new conformant object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Conformant
|
|
|
|
*/
|
2010-01-08 10:00:33 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_conformant_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *evas;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
wd = ELM_NEW(Widget_Data);
|
2010-01-26 17:48:18 -08:00
|
|
|
|
2010-01-08 10:00:33 -08:00
|
|
|
evas = evas_object_evas_get(parent);
|
2010-01-26 17:48:18 -08:00
|
|
|
|
2010-01-08 10:00:33 -08:00
|
|
|
obj = elm_widget_add(evas);
|
2010-03-13 19:48:22 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "conformant");
|
2010-01-08 10:00:33 -08:00
|
|
|
elm_widget_type_set(obj, "conformant");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
|
|
|
|
|
|
|
wd->base = edje_object_add(evas);
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->base, "conformant", "base", "default");
|
2010-01-08 10:00:33 -08:00
|
|
|
elm_widget_resize_object_set(obj, wd->base);
|
|
|
|
|
2010-01-13 00:37:56 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2010-02-18 18:33:17 -08:00
|
|
|
Ecore_X_Window zone, xwin;
|
2010-01-13 18:45:15 -08:00
|
|
|
int sh = -1;
|
|
|
|
|
2010-02-18 18:33:17 -08:00
|
|
|
xwin = elm_win_xwindow_get(parent);
|
|
|
|
zone = ecore_x_e_illume_zone_get(xwin);
|
2010-01-08 10:00:33 -08:00
|
|
|
|
2010-02-18 18:33:17 -08:00
|
|
|
ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh);
|
|
|
|
if (sh < 0) sh = 0;
|
2010-01-08 10:00:33 -08:00
|
|
|
wd->shelf = evas_object_rectangle_add(evas);
|
|
|
|
evas_object_color_set(wd->shelf, 0, 0, 0, 0);
|
2010-01-26 02:59:26 -08:00
|
|
|
evas_object_size_hint_min_set(wd->shelf, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->shelf, -1, sh);
|
2010-01-08 10:00:33 -08:00
|
|
|
edje_object_part_swallow(wd->base, "elm.swallow.shelf", wd->shelf);
|
2010-01-13 18:45:15 -08:00
|
|
|
|
|
|
|
sh = -1;
|
2010-02-18 18:33:17 -08:00
|
|
|
ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh);
|
2010-01-26 20:08:42 -08:00
|
|
|
if (sh < 0) sh = 0;
|
2010-01-13 18:45:15 -08:00
|
|
|
wd->panel = evas_object_rectangle_add(evas);
|
|
|
|
evas_object_color_set(wd->panel, 0, 0, 0, 0);
|
2010-01-26 02:59:26 -08:00
|
|
|
evas_object_size_hint_min_set(wd->panel, -1, sh);
|
|
|
|
evas_object_size_hint_max_set(wd->panel, -1, sh);
|
2010-01-13 18:45:15 -08:00
|
|
|
edje_object_part_swallow(wd->base, "elm.swallow.panel", wd->panel);
|
2010-01-08 10:00:33 -08:00
|
|
|
|
2010-01-26 17:48:18 -08:00
|
|
|
wd->prop_hdl = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
|
|
|
|
_prop_change, obj);
|
2010-02-04 22:14:50 -08:00
|
|
|
// FIXME: get kbd region prop
|
2010-02-02 05:55:55 -08:00
|
|
|
#endif
|
2010-02-18 18:33:17 -08:00
|
|
|
|
2010-02-04 01:08:02 -08:00
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
2010-02-18 18:33:17 -08:00
|
|
|
|
2010-01-08 10:00:33 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2010-02-08 18:46:19 -08:00
|
|
|
/**
|
|
|
|
* Set the content of the conformant widget
|
2010-06-16 13:58:09 -07:00
|
|
|
*
|
|
|
|
* Once the content object is set, a previously set one will be deleted.
|
|
|
|
* If you want to keep that old content object, use the
|
|
|
|
* elm_conformat_content_unset() function.
|
|
|
|
*
|
2010-02-08 18:46:19 -08:00
|
|
|
* @param obj The conformant object
|
2010-06-16 13:58:09 -07:00
|
|
|
* @return The content that was being used
|
|
|
|
*
|
2010-02-08 18:46:19 -08:00
|
|
|
* @ingroup Conformant
|
|
|
|
*/
|
2010-06-16 13:58:09 -07:00
|
|
|
EAPI void
|
|
|
|
elm_conformant_content_set(Evas_Object *obj, Evas_Object *content)
|
2010-01-08 10:00:33 -08:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2010-01-08 10:00:33 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-06-16 13:58:09 -07:00
|
|
|
if (wd->content == content) return;
|
|
|
|
if (wd->content) evas_object_del(wd->content);
|
2010-01-08 10:00:33 -08:00
|
|
|
wd->content = content;
|
2010-06-16 13:58:09 -07:00
|
|
|
if (content)
|
2010-01-08 10:00:33 -08:00
|
|
|
{
|
2010-06-16 13:58:09 -07:00
|
|
|
elm_widget_sub_object_add(obj, content);
|
|
|
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
|
2010-01-08 10:00:33 -08:00
|
|
|
}
|
2010-06-16 13:58:09 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unset the content of the conformant widget
|
|
|
|
*
|
|
|
|
* Unparent and return the content object which was set for this widget;
|
|
|
|
*
|
|
|
|
* @param obj The conformant object
|
|
|
|
* @return The content that was being used
|
|
|
|
*
|
|
|
|
* @ingroup Conformant
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_conformant_content_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *content;
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!wd->content) return NULL;
|
|
|
|
content = wd->content;
|
|
|
|
elm_widget_sub_object_del(obj, wd->content);
|
|
|
|
edje_object_part_unswallow(wd->base, wd->content);
|
|
|
|
wd->content = NULL;
|
|
|
|
return content;
|
2010-01-08 10:00:33 -08:00
|
|
|
}
|