parent
97622d3d34
commit
6391d192df
|
@ -1,36 +1,39 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
#include "elm_widget_layout.h"
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) < (b)) ? (a) : (b)
|
||||
# define MIN(a, b) ((a) < (b)) ? (a) : (b)
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) ((a) < (b)) ? (b) : (a)
|
||||
# define MAX(a, b) ((a) < (b)) ? (b) : (a)
|
||||
#endif
|
||||
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
struct _Widget_Data
|
||||
static const char CONFORM_SMART_NAME[] = "elm_conform";
|
||||
|
||||
typedef struct _Elm_Conform_Smart_Data Elm_Conform_Smart_Data;
|
||||
struct _Elm_Conform_Smart_Data
|
||||
{
|
||||
Evas_Object *base;
|
||||
Evas_Object *indicator;
|
||||
Evas_Object *softkey;
|
||||
Evas_Object *virtualkeypad;
|
||||
Evas_Object *clipboard;
|
||||
Evas_Object *content;
|
||||
Evas_Object *scroller;
|
||||
Elm_Layout_Smart_Data base;
|
||||
|
||||
Evas_Object *indicator;
|
||||
Evas_Object *softkey;
|
||||
Evas_Object *virtualkeypad;
|
||||
Evas_Object *clipboard;
|
||||
Evas_Object *scroller;
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
Ecore_Event_Handler *prop_hdl;
|
||||
Ecore_Event_Handler *prop_hdl;
|
||||
Ecore_X_Virtual_Keyboard_State vkb_state;
|
||||
#endif
|
||||
struct
|
||||
{
|
||||
Ecore_Animator *animator; // animaton timer
|
||||
double start; // time started
|
||||
Evas_Coord auto_x, auto_y; // desired delta
|
||||
Evas_Coord x, y; // current delta
|
||||
double start; // time started
|
||||
Evas_Coord auto_x, auto_y; // desired delta
|
||||
Evas_Coord x, y; // current delta
|
||||
} delta;
|
||||
Ecore_Job *show_region_job;
|
||||
Ecore_Job *show_region_job;
|
||||
};
|
||||
|
||||
/* Enum to identify conformant swallow parts */
|
||||
|
@ -45,162 +48,58 @@ enum _Conformant_Part_Type
|
|||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
#define SUB_TYPE_COUNT 2
|
||||
/* FIXME: change the smart names once those two are ported to new classes */
|
||||
static char *sub_type[SUB_TYPE_COUNT] = { "scroller", "genlist" };
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static const char *widtype = NULL;
|
||||
static void _del_pre_hook(Evas_Object *obj);
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
|
||||
static void _theme_hook(Evas_Object *obj);
|
||||
static void _content_set_hook(Evas_Object *obj,
|
||||
const char *part,
|
||||
Evas_Object *content);
|
||||
static Evas_Object *_content_get_hook(const Evas_Object *obj,
|
||||
const char *part);
|
||||
static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
|
||||
static void _swallow_conformant_parts(Evas_Object *obj);
|
||||
static void _conformant_part_size_set(Evas_Object *obj,
|
||||
Evas_Object *sobj,
|
||||
Evas_Coord sx,
|
||||
Evas_Coord sy,
|
||||
Evas_Coord sw,
|
||||
Evas_Coord sh);
|
||||
static void _conformant_part_sizing_eval(Evas_Object *obj,
|
||||
Conformant_Part_Type part_type);
|
||||
static void _conformant_move_resize_event_cb(void *data,
|
||||
Evas *e,
|
||||
Evas_Object *obj,
|
||||
void *event_info);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _show_region_job(void *data);
|
||||
static void _changed_size_hints(void *data, Evas *e,
|
||||
Evas_Object *obj,
|
||||
void *event_info);
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_del_pre_hook(Evas_Object *obj)
|
||||
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
{"icon", "elm.swallow.content"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
if (wd->prop_hdl) ecore_event_handler_del(wd->prop_hdl);
|
||||
#endif
|
||||
}
|
||||
/* Inheriting from elm_layout. Besides, we need no more than what is
|
||||
* there */
|
||||
EVAS_SMART_SUBCLASS_NEW
|
||||
(CONFORM_SMART_NAME, _elm_conform, Elm_Layout_Smart_Class,
|
||||
Elm_Layout_Smart_Class, elm_layout_smart_class_get, NULL);
|
||||
|
||||
static void
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
#define ELM_CONFORM_DATA_GET(o, sd) \
|
||||
Elm_Conform_Smart_Data * sd = evas_object_smart_data_get(o)
|
||||
|
||||
if (wd->show_region_job) ecore_job_del(wd->show_region_job);
|
||||
free(wd);
|
||||
}
|
||||
#define ELM_CONFORM_DATA_GET_OR_RETURN(o, ptr) \
|
||||
ELM_CONFORM_DATA_GET(o, ptr); \
|
||||
if (!ptr) \
|
||||
{ \
|
||||
CRITICAL("No widget data for object %p (%s)", \
|
||||
o, evas_object_type_get(o)); \
|
||||
return; \
|
||||
}
|
||||
|
||||
static void
|
||||
_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
#define ELM_CONFORM_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
||||
ELM_CONFORM_DATA_GET(o, ptr); \
|
||||
if (!ptr) \
|
||||
{ \
|
||||
CRITICAL("No widget data for object %p (%s)", \
|
||||
o, evas_object_type_get(o)); \
|
||||
return val; \
|
||||
}
|
||||
|
||||
edje_object_mirrored_set(wd->base, rtl);
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
_elm_widget_mirrored_reload(obj);
|
||||
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
||||
_elm_theme_object_set(obj, wd->base, "conformant", "base",
|
||||
elm_widget_style_get(obj));
|
||||
_swallow_conformant_parts(obj);
|
||||
|
||||
if (wd->content)
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.content", wd->content);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd;
|
||||
|
||||
if (part && strcmp(part, "default")) return;
|
||||
wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if (wd->content == content) return;
|
||||
if (wd->content) evas_object_del(wd->content);
|
||||
wd->content = content;
|
||||
if (content)
|
||||
{
|
||||
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);
|
||||
}
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_content_get_hook(const Evas_Object *obj, const char *part)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd;
|
||||
|
||||
if (part && strcmp(part, "default")) return NULL;
|
||||
wd = elm_widget_data_get(obj);
|
||||
if (!wd) return NULL;
|
||||
return wd->content;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_content_unset_hook(Evas_Object *obj, const char *part)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd;
|
||||
Evas_Object *content;
|
||||
if (part && strcmp(part, "default")) return NULL;
|
||||
wd = elm_widget_data_get(obj);
|
||||
if ((!wd) || (!wd->content)) return NULL;
|
||||
|
||||
content = wd->content;
|
||||
elm_widget_sub_object_del(obj, wd->content);
|
||||
evas_object_event_callback_del_full(content,
|
||||
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
edje_object_part_unswallow(wd->base, content);
|
||||
wd->content = NULL;
|
||||
return content;
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord mw = -1, mh = -1;
|
||||
if (!wd) return;
|
||||
|
||||
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);
|
||||
}
|
||||
#define ELM_CONFORM_CHECK(obj) \
|
||||
if (!obj || !elm_widget_type_check((obj), CONFORM_SMART_NAME, __func__)) \
|
||||
return
|
||||
|
||||
/* Example of env vars:
|
||||
* ILLUME_KBD="0, 0, 800, 301"
|
||||
* ILLUME_IND=0,0,800,32
|
||||
* ILLUME_STK="0,568,800,32
|
||||
* ILLUME_IND="0, 0, 800, 32"
|
||||
* ILLUME_STK="0, 568, 800, 32"
|
||||
*/
|
||||
static Eina_Bool
|
||||
_conformant_part_geometry_env_get(const char *part, int *sx, int *sy, int *sw, int *sh)
|
||||
_conformant_part_geometry_get_from_env(const char *part,
|
||||
int *sx,
|
||||
int *sy,
|
||||
int *sw,
|
||||
int *sh)
|
||||
{
|
||||
const char delimiters[] = " ,;";
|
||||
char *env_val, *token;
|
||||
|
@ -236,8 +135,12 @@ _conformant_part_geometry_env_get(const char *part, int *sx, int *sy, int *sw, i
|
|||
}
|
||||
|
||||
static void
|
||||
_conformant_part_size_set(Evas_Object *obj, Evas_Object *sobj, Evas_Coord sx,
|
||||
Evas_Coord sy, Evas_Coord sw, Evas_Coord sh)
|
||||
_conformant_part_size_hints_set(Evas_Object *obj,
|
||||
Evas_Object *sobj,
|
||||
Evas_Coord sx,
|
||||
Evas_Coord sy,
|
||||
Evas_Coord sw,
|
||||
Evas_Coord sh)
|
||||
{
|
||||
Evas_Coord cx, cy, cw, ch;
|
||||
Evas_Coord part_height = 0, part_width = 0;
|
||||
|
@ -246,7 +149,7 @@ _conformant_part_size_set(Evas_Object *obj, Evas_Object *sobj, Evas_Coord sx,
|
|||
|
||||
/* Part overlapping with conformant */
|
||||
if ((cx < (sx + sw)) && ((cx + cw) > sx)
|
||||
&& (cy < (sy + sh)) && ((cy + ch) > sy))
|
||||
&& (cy < (sy + sh)) && ((cy + ch) > sy))
|
||||
{
|
||||
part_height = MIN((cy + ch), (sy + sh)) - MAX(cy, sy);
|
||||
part_width = MIN((cx + cw), (sx + sw)) - MAX(cx, sx);
|
||||
|
@ -257,270 +160,248 @@ _conformant_part_size_set(Evas_Object *obj, Evas_Object *sobj, Evas_Coord sx,
|
|||
}
|
||||
|
||||
static void
|
||||
_conformant_part_sizing_eval(Evas_Object *obj, Conformant_Part_Type part_type)
|
||||
_conformant_part_sizing_eval(Evas_Object *obj,
|
||||
Conformant_Part_Type part_type)
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
Ecore_X_Window zone = 0;
|
||||
Evas_Object *top;
|
||||
#endif
|
||||
Ecore_X_Window xwin;
|
||||
int sx = -1, sy = -1, sw = -1, sh = -1;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
Ecore_X_Window xwin;
|
||||
|
||||
ELM_CONFORM_DATA_GET(obj, sd);
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
top = elm_widget_top_get(obj);
|
||||
xwin = elm_win_xwindow_get(top);
|
||||
|
||||
if (xwin)
|
||||
zone = ecore_x_e_illume_zone_get(xwin);
|
||||
#endif
|
||||
|
||||
if (part_type & ELM_CONFORM_INDICATOR_PART)
|
||||
{
|
||||
if ((!_conformant_part_geometry_env_get("ILLUME_IND",
|
||||
&sx, &sy, &sw, &sh)) && (xwin))
|
||||
if ((!_conformant_part_geometry_get_from_env
|
||||
("ILLUME_IND", &sx, &sy, &sw, &sh)) && (xwin))
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
//No information of the indicator geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_indicator_geometry_get(zone, &sx, &sy, &sw, &sh))
|
||||
//No information of the indicator geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_indicator_geometry_get
|
||||
(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
_conformant_part_size_set(obj, wd->indicator, sx, sy, sw, sh);
|
||||
_conformant_part_size_hints_set(obj, sd->indicator, sx, sy, sw, sh);
|
||||
}
|
||||
|
||||
if (part_type & ELM_CONFORM_VIRTUAL_KEYPAD_PART)
|
||||
{
|
||||
if ((!_conformant_part_geometry_env_get("ILLUME_KBD",
|
||||
&sx, &sy, &sw, &sh)) && (xwin))
|
||||
if ((!_conformant_part_geometry_get_from_env
|
||||
("ILLUME_KBD", &sx, &sy, &sw, &sh)) && (xwin))
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
//No information of the keyboard geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_keyboard_geometry_get(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
//No information of the keyboard geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_keyboard_geometry_get
|
||||
(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
_conformant_part_size_set(obj, wd->virtualkeypad, sx, sy, sw, sh);
|
||||
_conformant_part_size_hints_set
|
||||
(obj, sd->virtualkeypad, sx, sy, sw, sh);
|
||||
}
|
||||
|
||||
if (part_type & ELM_CONFORM_SOFTKEY_PART)
|
||||
{
|
||||
if ((!_conformant_part_geometry_env_get("ILLUME_STK",
|
||||
&sx, &sy, &sw, &sh)) && (xwin))
|
||||
if ((!_conformant_part_geometry_get_from_env
|
||||
("ILLUME_STK", &sx, &sy, &sw, &sh)) && (xwin))
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
//No information of the softkey geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_softkey_geometry_get(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
//No information of the softkey geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_softkey_geometry_get
|
||||
(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
_conformant_part_size_set(obj, wd->softkey, sx, sy, sw, sh);
|
||||
_conformant_part_size_hints_set(obj, sd->softkey, sx, sy, sw, sh);
|
||||
}
|
||||
if (part_type & ELM_CONFORM_CLIPBOARD_PART)
|
||||
{
|
||||
if ((!_conformant_part_geometry_env_get("ILLUME_CB",
|
||||
&sx, &sy, &sw, &sh)) && (xwin))
|
||||
if ((!_conformant_part_geometry_get_from_env
|
||||
("ILLUME_CB", &sx, &sy, &sw, &sh)) && (xwin))
|
||||
{
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
//No information of the clipboard geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_clipboard_geometry_get(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
//No information of the clipboard geometry, reset the geometry.
|
||||
if (!ecore_x_e_illume_clipboard_geometry_get
|
||||
(zone, &sx, &sy, &sw, &sh))
|
||||
sx = sy = sw = sh = 0;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
_conformant_part_size_set(obj, wd->clipboard, sx, sy, sw, sh);
|
||||
_conformant_part_size_hints_set(obj, sd->clipboard, sx, sy, sw, sh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_swallow_conformant_parts(Evas_Object *obj)
|
||||
_conformant_parts_swallow(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas *e = evas_object_evas_get(obj);
|
||||
if (!wd || !e) return;
|
||||
Evas *e;
|
||||
|
||||
wd->scroller = NULL;
|
||||
ELM_CONFORM_DATA_GET(obj, sd);
|
||||
|
||||
e = evas_object_evas_get(obj);
|
||||
|
||||
sd->scroller = NULL;
|
||||
|
||||
//Indicator
|
||||
if (!wd->indicator)
|
||||
if (!sd->indicator)
|
||||
{
|
||||
wd->indicator = evas_object_rectangle_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->indicator);
|
||||
evas_object_size_hint_min_set(wd->indicator, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->indicator, -1, 0);
|
||||
sd->indicator = evas_object_rectangle_add(e);
|
||||
evas_object_size_hint_min_set(sd->indicator, -1, 0);
|
||||
evas_object_size_hint_max_set(sd->indicator, -1, 0);
|
||||
}
|
||||
else
|
||||
_conformant_part_sizing_eval(obj, ELM_CONFORM_INDICATOR_PART);
|
||||
evas_object_color_set(wd->indicator, 0, 0, 0, 0);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.indicator", wd->indicator);
|
||||
|
||||
evas_object_color_set(sd->indicator, 0, 0, 0, 0);
|
||||
elm_layout_content_set(obj, "elm.swallow.indicator", sd->indicator);
|
||||
|
||||
//Virtual Keyboard
|
||||
if (!wd->virtualkeypad)
|
||||
if (!sd->virtualkeypad)
|
||||
{
|
||||
wd->virtualkeypad = evas_object_rectangle_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->virtualkeypad);
|
||||
evas_object_size_hint_min_set(wd->virtualkeypad, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->virtualkeypad, -1, 0);
|
||||
sd->virtualkeypad = evas_object_rectangle_add(e);
|
||||
elm_widget_sub_object_add(obj, sd->virtualkeypad);
|
||||
evas_object_size_hint_max_set(sd->virtualkeypad, -1, 0);
|
||||
}
|
||||
else
|
||||
_conformant_part_sizing_eval(obj, ELM_CONFORM_VIRTUAL_KEYPAD_PART);
|
||||
evas_object_color_set(wd->virtualkeypad, 0, 0, 0, 0);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.virtualkeypad",
|
||||
wd->virtualkeypad);
|
||||
|
||||
evas_object_color_set(sd->virtualkeypad, 0, 0, 0, 0);
|
||||
elm_layout_content_set(obj, "elm.swallow.virtualkeypad", sd->virtualkeypad);
|
||||
|
||||
//Clipboard
|
||||
if (!wd->clipboard)
|
||||
if (!sd->clipboard)
|
||||
{
|
||||
wd->clipboard = evas_object_rectangle_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->clipboard);
|
||||
evas_object_size_hint_min_set(wd->clipboard, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->clipboard, -1, 0);
|
||||
sd->clipboard = evas_object_rectangle_add(e);
|
||||
evas_object_size_hint_min_set(sd->clipboard, -1, 0);
|
||||
evas_object_size_hint_max_set(sd->clipboard, -1, 0);
|
||||
}
|
||||
else
|
||||
_conformant_part_sizing_eval(obj, ELM_CONFORM_CLIPBOARD_PART);
|
||||
evas_object_color_set(wd->clipboard, 0, 0, 0, 0);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.clipboard",
|
||||
wd->clipboard);
|
||||
|
||||
evas_object_color_set(sd->clipboard, 0, 0, 0, 0);
|
||||
elm_layout_content_set(obj, "elm.swallow.clipboard", sd->clipboard);
|
||||
|
||||
//Softkey
|
||||
if (!wd->softkey)
|
||||
if (!sd->softkey)
|
||||
{
|
||||
wd->softkey = evas_object_rectangle_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->softkey);
|
||||
evas_object_size_hint_min_set(wd->softkey, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->softkey, -1, 0);
|
||||
sd->softkey = evas_object_rectangle_add(e);
|
||||
evas_object_size_hint_min_set(sd->softkey, -1, 0);
|
||||
evas_object_size_hint_max_set(sd->softkey, -1, 0);
|
||||
}
|
||||
else
|
||||
_conformant_part_sizing_eval(obj, ELM_CONFORM_SOFTKEY_PART);
|
||||
evas_object_color_set(wd->softkey, 0, 0, 0, 0);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.softkey", wd->softkey);
|
||||
|
||||
evas_object_color_set(sd->softkey, 0, 0, 0, 0);
|
||||
elm_layout_content_set(obj, "elm.swallow.softkey", sd->softkey);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_size_hints(void *data, Evas *e __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
static Eina_Bool
|
||||
_elm_conform_smart_theme(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
if (!ELM_WIDGET_CLASS(_elm_conform_parent_sc)->theme(obj))
|
||||
return EINA_FALSE;
|
||||
|
||||
_sizing_eval(data);
|
||||
_conformant_parts_swallow(obj);
|
||||
|
||||
elm_layout_sizing_eval(obj);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Object *sub = event_info;
|
||||
if (!wd) return;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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_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()
|
||||
}
|
||||
static void
|
||||
_autoscroll_mode_disable(Evas_Object *obj)
|
||||
{
|
||||
// called when autoscroll mode should be off - set delta to 0 and
|
||||
// call _autoscroll_move()
|
||||
}
|
||||
*/
|
||||
|
||||
static void
|
||||
_conformant_move_resize_event_cb(void *data __UNUSED__, Evas *e __UNUSED__,
|
||||
Evas_Object *obj, void *event_info __UNUSED__)
|
||||
_move_resize_cb(void *data __UNUSED__,
|
||||
Evas *e __UNUSED__,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Conformant_Part_Type part_type;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
part_type = (ELM_CONFORM_INDICATOR_PART |
|
||||
ELM_CONFORM_SOFTKEY_PART |
|
||||
ELM_CONFORM_VIRTUAL_KEYPAD_PART |
|
||||
ELM_CONFORM_CLIPBOARD_PART);
|
||||
part_type = (ELM_CONFORM_INDICATOR_PART |
|
||||
ELM_CONFORM_SOFTKEY_PART |
|
||||
ELM_CONFORM_VIRTUAL_KEYPAD_PART |
|
||||
ELM_CONFORM_CLIPBOARD_PART);
|
||||
|
||||
_conformant_part_sizing_eval(obj, part_type);
|
||||
}
|
||||
|
||||
// showing the focused/important region.
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
static void
|
||||
_content_resize_event_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj
|
||||
__UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *conformant = (Evas_Object *)data;
|
||||
Widget_Data *wd = elm_widget_data_get(conformant);
|
||||
if (!wd) return;
|
||||
|
||||
if (wd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF) return;
|
||||
|
||||
if (wd->show_region_job) ecore_job_del(wd->show_region_job);
|
||||
wd->show_region_job = ecore_job_add(_show_region_job, conformant);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_show_region_job(void *data)
|
||||
{
|
||||
Evas_Object *focus_obj;
|
||||
Evas_Object *conformant = (Evas_Object *)data;
|
||||
Widget_Data *wd = elm_widget_data_get(conformant);
|
||||
if (!wd) return;
|
||||
|
||||
focus_obj = elm_widget_focused_object_get(conformant);
|
||||
ELM_CONFORM_DATA_GET(data, sd);
|
||||
|
||||
focus_obj = elm_widget_focused_object_get(data);
|
||||
if (focus_obj)
|
||||
{
|
||||
Evas_Coord x, y, w, h;
|
||||
|
@ -533,27 +414,46 @@ _show_region_job(void *data)
|
|||
elm_widget_show_region_set(focus_obj, x, y, w, h, EINA_TRUE);
|
||||
}
|
||||
|
||||
wd->show_region_job = NULL;
|
||||
sd->show_region_job = NULL;
|
||||
}
|
||||
|
||||
// showing the focused/important region.
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
static void
|
||||
_on_content_resize(void *data,
|
||||
Evas *e __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
ELM_CONFORM_DATA_GET(data, sd);
|
||||
|
||||
if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF) return;
|
||||
|
||||
if (sd->show_region_job) ecore_job_del(sd->show_region_job);
|
||||
sd->show_region_job = ecore_job_add(_show_region_job, data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
static void
|
||||
_update_autoscroll_objs(void *data)
|
||||
_autoscroll_objects_update(void *data)
|
||||
{
|
||||
const char *type;
|
||||
int i;
|
||||
const char *type;
|
||||
Evas_Object *sub, *top_scroller = NULL;
|
||||
Evas_Object *conformant = (Evas_Object *)data;
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
|
||||
sub = elm_widget_focused_object_get(conformant);
|
||||
//Look up for Top most scroller in the Focus Object hierarchy inside Conformant.
|
||||
ELM_CONFORM_DATA_GET(data, sd);
|
||||
|
||||
sub = elm_widget_focused_object_get(data);
|
||||
//Look up for top most scroller in the focus object hierarchy
|
||||
//inside Conformant.
|
||||
|
||||
while (sub)
|
||||
{
|
||||
type = elm_widget_type_get(sub);
|
||||
if (!strcmp(type, "conformant")) break;
|
||||
if (!strcmp(type, CONFORM_SMART_NAME)) break;
|
||||
|
||||
for (i = 0; i < SUB_TYPE_COUNT; i++)
|
||||
if (!strcmp(type, sub_type[i]))
|
||||
{
|
||||
|
@ -564,35 +464,37 @@ _update_autoscroll_objs(void *data)
|
|||
}
|
||||
|
||||
//If the scroller got changed by app, replace it.
|
||||
if (top_scroller != wd->scroller)
|
||||
if (top_scroller != sd->scroller)
|
||||
{
|
||||
if (wd->scroller) evas_object_event_callback_del(wd->scroller,
|
||||
EVAS_CALLBACK_RESIZE,
|
||||
_content_resize_event_cb);
|
||||
wd->scroller = top_scroller;
|
||||
if (wd->scroller) evas_object_event_callback_add(wd->scroller,
|
||||
EVAS_CALLBACK_RESIZE,
|
||||
_content_resize_event_cb,
|
||||
data);
|
||||
if (sd->scroller)
|
||||
evas_object_event_callback_del
|
||||
(sd->scroller, EVAS_CALLBACK_RESIZE, _on_content_resize);
|
||||
sd->scroller = top_scroller;
|
||||
|
||||
if (sd->scroller)
|
||||
evas_object_event_callback_add
|
||||
(sd->scroller, EVAS_CALLBACK_RESIZE, _on_content_resize, data);
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_prop_change(void *data, int type __UNUSED__, void *event)
|
||||
_on_prop_change(void *data,
|
||||
int type __UNUSED__,
|
||||
void *event)
|
||||
{
|
||||
Ecore_X_Event_Window_Property *ev;
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
Ecore_X_Event_Window_Property *ev = event;
|
||||
|
||||
ELM_CONFORM_DATA_GET(data, sd);
|
||||
|
||||
if (!wd) return ECORE_CALLBACK_PASS_ON;
|
||||
ev = event;
|
||||
if (ev->atom == ECORE_X_ATOM_E_ILLUME_ZONE)
|
||||
{
|
||||
Conformant_Part_Type part_type;
|
||||
|
||||
part_type = (ELM_CONFORM_INDICATOR_PART |
|
||||
ELM_CONFORM_SOFTKEY_PART |
|
||||
ELM_CONFORM_VIRTUAL_KEYPAD_PART |
|
||||
ELM_CONFORM_CLIPBOARD_PART);
|
||||
part_type = (ELM_CONFORM_INDICATOR_PART |
|
||||
ELM_CONFORM_SOFTKEY_PART |
|
||||
ELM_CONFORM_VIRTUAL_KEYPAD_PART |
|
||||
ELM_CONFORM_CLIPBOARD_PART);
|
||||
|
||||
_conformant_part_sizing_eval(data, part_type);
|
||||
}
|
||||
else if (ev->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY)
|
||||
|
@ -607,16 +509,15 @@ _prop_change(void *data, int type __UNUSED__, void *event)
|
|||
{
|
||||
Ecore_X_Window zone;
|
||||
|
||||
printf("Keyboard Geometry Changed\n");
|
||||
DBG("Keyboard Geometry Changed\n");
|
||||
zone = ecore_x_e_illume_zone_get(ev->win);
|
||||
wd->vkb_state = ecore_x_e_virtual_keyboard_state_get(zone);
|
||||
if (wd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
|
||||
sd->vkb_state = ecore_x_e_virtual_keyboard_state_get(zone);
|
||||
if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
|
||||
{
|
||||
evas_object_size_hint_min_set(wd->virtualkeypad, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->virtualkeypad, -1, 0);
|
||||
evas_object_size_hint_min_set(sd->virtualkeypad, -1, 0);
|
||||
evas_object_size_hint_max_set(sd->virtualkeypad, -1, 0);
|
||||
}
|
||||
else
|
||||
_update_autoscroll_objs(data);
|
||||
else _autoscroll_objects_update(data);
|
||||
}
|
||||
else if (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
|
||||
{
|
||||
|
@ -628,43 +529,76 @@ _prop_change(void *data, int type __UNUSED__, void *event)
|
|||
|
||||
if (state != ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
|
||||
{
|
||||
evas_object_size_hint_min_set(wd->clipboard, -1, 0);
|
||||
evas_object_size_hint_max_set(wd->clipboard, -1, 0);
|
||||
evas_object_size_hint_min_set(sd->clipboard, -1, 0);
|
||||
evas_object_size_hint_max_set(sd->clipboard, -1, 0);
|
||||
}
|
||||
else
|
||||
_update_autoscroll_objs(data);
|
||||
else _autoscroll_objects_update(data);
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
_elm_conform_smart_add(Evas_Object *obj)
|
||||
{
|
||||
EVAS_SMART_DATA_ALLOC(obj, Elm_Conform_Smart_Data);
|
||||
|
||||
ELM_WIDGET_CLASS(_elm_conform_parent_sc)->base.add(obj);
|
||||
|
||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||
|
||||
elm_layout_theme_set(obj, "conformant", "base", elm_widget_style_get(obj));
|
||||
|
||||
_conformant_parts_swallow(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_conform_smart_del(Evas_Object *obj)
|
||||
{
|
||||
ELM_CONFORM_DATA_GET(obj, sd);
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
if (sd->prop_hdl) ecore_event_handler_del(sd->prop_hdl);
|
||||
#endif
|
||||
|
||||
if (sd->show_region_job) ecore_job_del(sd->show_region_job);
|
||||
|
||||
ELM_WIDGET_CLASS(_elm_conform_parent_sc)->base.del(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_conform_smart_set_user(Elm_Layout_Smart_Class *sc)
|
||||
{
|
||||
ELM_WIDGET_CLASS(sc)->base.add = _elm_conform_smart_add;
|
||||
ELM_WIDGET_CLASS(sc)->base.del = _elm_conform_smart_del;
|
||||
|
||||
ELM_WIDGET_CLASS(sc)->theme = _elm_conform_smart_theme;
|
||||
|
||||
/* not a 'focus chain manager' */
|
||||
ELM_WIDGET_CLASS(sc)->focus_next = NULL;
|
||||
ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
|
||||
|
||||
sc->content_aliases = _content_aliases;
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_conformant_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
Evas_Object *obj;
|
||||
|
||||
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
||||
|
||||
ELM_SET_WIDTYPE(widtype, "conformant");
|
||||
elm_widget_type_set(obj, "conformant");
|
||||
elm_widget_sub_object_add(parent, obj);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_theme_hook_set(obj, _theme_hook);
|
||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||
elm_widget_content_set_hook_set(obj, _content_set_hook);
|
||||
elm_widget_content_get_hook_set(obj, _content_get_hook);
|
||||
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
|
||||
e = evas_object_evas_get(parent);
|
||||
if (!e) return NULL;
|
||||
|
||||
wd->base = edje_object_add(e);
|
||||
_elm_theme_object_set(obj, wd->base, "conformant", "base", "default");
|
||||
elm_widget_resize_object_set(obj, wd->base);
|
||||
obj = evas_object_smart_add(e, _elm_conform_smart_class_new());
|
||||
|
||||
_swallow_conformant_parts(obj);
|
||||
/* NB: we got to sub-object-add before we probe for the top widget */
|
||||
if (!elm_widget_sub_object_add(parent, obj))
|
||||
ERR("could not add %p as sub object of %p", obj, parent);
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
Evas_Object *top = elm_widget_top_get(obj);
|
||||
|
@ -672,21 +606,21 @@ elm_conformant_add(Evas_Object *parent)
|
|||
|
||||
if ((xwin) && (!elm_win_inlined_image_object_get(top)))
|
||||
{
|
||||
wd->prop_hdl = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
|
||||
_prop_change, obj);
|
||||
wd->vkb_state = ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF;
|
||||
ELM_CONFORM_DATA_GET(obj, sd);
|
||||
|
||||
sd->prop_hdl = ecore_event_handler_add
|
||||
(ECORE_X_EVENT_WINDOW_PROPERTY, _on_prop_change, obj);
|
||||
sd->vkb_state = ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF;
|
||||
}
|
||||
// FIXME: get kbd region prop
|
||||
#endif
|
||||
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
|
||||
_conformant_move_resize_event_cb, obj);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
|
||||
_conformant_move_resize_event_cb, obj);
|
||||
evas_object_event_callback_add
|
||||
(obj, EVAS_CALLBACK_RESIZE, _move_resize_cb, obj);
|
||||
evas_object_event_callback_add
|
||||
(obj, EVAS_CALLBACK_MOVE, _move_resize_cb, obj);
|
||||
|
||||
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||
elm_layout_sizing_eval(obj);
|
||||
|
||||
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
* space required for such stuff, and when they popup, as a keyboard
|
||||
* shows when an entry is selected, conformant content won't change.
|
||||
*
|
||||
* This widget inherits from the @ref Layout one, so that all the
|
||||
* functions acting on it also work for conformant objects.
|
||||
*
|
||||
* This widget emits the same signals sent from @ref Layout:
|
||||
*
|
||||
* Available styles for it:
|
||||
* - @c "default"
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue