#include <app_debug.h>
#include <stdbool.h>
#include <app.h>
+#include <inputmgr.h>
#include "utils.h"
#include "defs.h"
return box;
}
+Evas_Object *utils_add_table(Evas_Object *base, bool homo, const char *part)
+{
+ Evas_Object *table;
+
+ table = elm_table_add(base);
+ if (!table) {
+ _ERR("failed to add table");
+ return NULL;
+ }
+
+ if (homo)
+ elm_table_homogeneous_set(table, EINA_TRUE);
+
+ if (part)
+ elm_object_part_content_set(base, part, table);
+
+ return table;
+}
+
Evas_Object *utils_add_button(Evas_Object *base, char *text, const char *part)
{
Evas_Object *btn;
return btn;
}
+static void _entry_focused(int id, void *data, Evas_Object *obj,
+ Elm_Object_Item *item)
+{
+ elm_object_signal_emit(data, SIG_FOCUS, SRC_PROG);
+}
+
+static void _entry_unfocused(int id, void *data, Evas_Object *obj,
+ Elm_Object_Item *item)
+{
+ elm_object_signal_emit(data, SIG_UNFOCUS, SRC_PROG);
+}
+
+static input_handler entry_handle = {
+ .focused = _entry_focused,
+ .unfocused = _entry_unfocused
+};
+
Evas_Object *utils_add_entry(Evas_Object *base, char *text, bool password,
const char *part)
{
elm_entry_entry_set(entry, text);
elm_object_part_content_set(ly, PART_USER_EDIT_ENTRY, entry);
+ inputmgr_add_callback(entry, 0, &entry_handle, ly);
evas_object_show(entry);
return entry;
Evas_Object *pin;
Evas_Object *lock;
Evas_Object *icon;
+ Evas_Object *focus_icon;
+ Evas_Object *done;
+ Evas_Object *cancel;
struct datamgr *dm;
};
-static bool _add_btns(Evas_Object *base)
+static void _done_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
{
- Evas_Object *btn;
+ if (!strcmp(ev->keyname, KEY_ENTER)) {
+ /* check state of user edit */
+ viewmgr_pop_view();
+ }
+}
+
+static input_handler done_handler = {
+ .key_down = _done_key_down
+};
+
+static void _cancel_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ if (!strcmp(ev->keyname, KEY_ENTER)) {
+ viewmgr_pop_view();
+ }
+}
+
+static input_handler cancel_handler = {
+ .key_down = _cancel_key_down
+};
- btn = utils_add_button(base, MESSAGE_BTN_DONE, PART_USER_EDIT_BTN_DONE);
- if (!btn) {
+static bool _add_btns(struct _priv *priv)
+{
+ Evas_Object *done, *cancel;
+
+ done = utils_add_button(priv->base, MESSAGE_BTN_DONE,
+ PART_USER_EDIT_BTN_DONE);
+ if (!done) {
_ERR("failed to add done btn");
return false;
}
+ inputmgr_add_callback(done, 0, &done_handler, NULL);
- btn = utils_add_button(base, MESSAGE_BTN_CANCEL,
+ cancel = utils_add_button(priv->base, MESSAGE_BTN_CANCEL,
PART_USER_EDIT_BTN_CANCEL);
- if (!btn) {
+ if (!cancel) {
_ERR("failed to add cancel btn");
+ evas_object_del(done);
return false;
}
+ inputmgr_add_callback(cancel, 0, &cancel_handler, NULL);
+
+ priv->cancel = cancel;
+ priv->done = done;
return true;
}
+static void _focused(int id, void *data, Evas_Object *obj,
+ Elm_Object_Item *item)
+{
+ elm_object_signal_emit(obj, SIG_FOCUS, SRC_PROG);
+}
+
+static void _unfocused(int id, void *data, Evas_Object *obj,
+ Elm_Object_Item *item)
+{
+ elm_object_signal_emit(obj, SIG_UNFOCUS, SRC_PROG);
+}
+
+static void _photo_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ /* It should be implemented later to drawing icon list */
+}
+
+static input_handler photo_handler = {
+ .focused = _focused,
+ .unfocused = _unfocused,
+ .key_down = _photo_key_down
+};
+
static Evas_Object *_add_layout(struct _priv *priv)
{
Evas_Object *ly, *photo, *name, *pin, *account, *lock;
if (!lock)
goto err;
+ inputmgr_add_callback(photo, 0, &photo_handler, priv);
+
priv->photo = photo;
priv->name = name;
priv->account = account;
return false;
}
- if (!_add_btns(priv->base)) {
+ if (!_add_btns(priv)) {
_ERR("failed to add buttons");
evas_object_del(ly);
return false;
static void _load_user_edit(struct _priv *priv)
{
- Evas_Object *icon;
+ Evas_Object *icon, *focus_icon;
/* check state of user edit */
if (!icon)
_ERR("failed to add icon");
+ focus_icon = utils_add_icon(priv->photo,
+ IMAGE_USER_CURRENT_DEFAULT_FOCUS,
+ PART_USER_EDIT_PHOTO_FOCUS);
+ if (!focus_icon)
+ _ERR("failed to add focus icon");
+
priv->icon = icon;
+ priv->focus_icon = focus_icon;
}
static void _show(void *data)
priv = data;
+ inputmgr_remove_callback(priv->photo, &photo_handler);
+ inputmgr_remove_callback(priv->done, &done_handler);
+ inputmgr_remove_callback(priv->cancel, &cancel_handler);
evas_object_del(priv->base);
free(priv);
}