}
} // programs
} // group
+
+ group {
+ name: "elm/check/base/extended/imagegrid";
+ images {
+ image: "05_delete.png" COMP;
+ }
+
+ parts {
+ part {
+ name: "bg";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel2.relative: 0.0 1.0;
+ align: 0.0 0.5;
+ min: 100 100;
+ max: 100 100;
+ color: 0 0 0 0;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ visible: 1;
+ }
+ description {
+ state: "pressed" 0.0;
+ inherit: "default" 0.0;
+ }
+ description {
+ state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ }
+ }
+ part {
+ name: "bg2";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel2.relative: 1.0 1.0;
+ align: 0.95 0.5;
+ min: 33 33;
+ max: 33 33;
+ color: 0 0 0 0;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ visible: 1;
+ }
+ description {
+ state: "pressed" 0.0;
+ inherit: "default" 0.0;
+ }
+ description {
+ state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part {
+ name: "check";
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1.to: "bg2";
+ rel2.to: "bg2";
+ visible: 0;
+ image.normal: "05_delete.png";
+ }
+ description {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ description {
+ state: "pressed" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ description {
+ state: "disabled_visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part {
+ name: "elm.swallow.content";
+ type: SWALLOW;
+ description {
+ state: "default" 0.0;
+ fixed: 1 0;
+ visible: 0;
+ color: 255 255 255 255;
+ align: 0.0 0.5;
+ rel1.to_x: "bg2";
+ rel1.relative: 1.0 0.0;
+ rel1.offset: 1 1;
+ rel2.to_x: "bg2";
+ rel2.relative: 1.0 1.0;
+ rel2.offset: 2 -2;
+ }
+ description {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ fixed: 1 1;
+ visible: 1;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ }
+ description {
+ state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ color: 128 128 128 128;
+ }
+ description {
+ state: "disabled_visible" 0.0;
+ inherit: "default" 0.0;
+ color: 128 128 128 128;
+ fixed: 1 1;
+ visible: 1;
+ aspect: 1.0 1.0;
+ }
+ }
+ part {
+ name: "elm.text";
+ type: TEXTBLOCK;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ rel1 { relative: 1.0 0.5; offset: 1 1; to_x: "elm.swallow.content"; }
+ rel2 { relative: 1.0 0.5; offset: -2 -2; }
+ color: 255 255 255 255;
+ align: 0.0 0.5;
+ text {
+ style: "check_label_textblock_style";
+ min: 0 0;
+ }
+ }
+ description {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ text.min: 1 1;
+ }
+ description {
+ state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ }
+ description {
+ state: "disabled_visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ text {
+ style: "check_label_textblock_disabled_style";
+ min: 1 1;
+ }
+ }
+ }
+ part {
+ name: "events";
+ type: RECT;
+ ignore_flags: ON_HOLD;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ }
+ }
+ part {
+ name: "disabler";
+ type: RECT;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ //visible: 0;
+ visible: 1;
+ }
+ description {
+ state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ }
+
+ programs {
+ program {
+ name: "click";
+ signal: "mouse,up,1";
+ source: "events";
+ action: SIGNAL_EMIT "elm,action,check,toggle" "";
+ after: "bg_normal";
+ }
+ program {
+ name: "bg_normal";
+ script {
+ set_state(PART:"bg", "default", 0.0);
+ set_state(PART:"bg2", "default", 0.0);
+ }
+ }
+ program {
+ name: "mouseout";
+ signal: "mouse,out";
+ source: "events";
+ after: "bg_check_normal";
+ }
+ program {
+ name: "bg_check_normal";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"check", st, 30, vl);
+ if (!strcmp(st, "pressed"))
+ set_state(PART:"check", "visible", 0.0);
+ set_state(PART:"bg", "default", 0.0);
+ set_state(PART:"bg2", "default", 0.0);
+ }
+ }
+ program {
+ name: "pressed";
+ signal: "mouse,down,1";
+ source: "events";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"check", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"check", "pressed", 0.0);
+ set_state(PART:"bg", "pressed", 0.0);
+ set_state(PART:"bg2", "pressed", 0.0);
+ }
+ }
+ program {
+ name: "check_on";
+ signal: "elm,state,check,on";
+ source: "elm";
+ action: STATE_SET "visible" 0.0;
+ target: "check";
+ }
+ program {
+ name: "check_off";
+ signal: "elm,state,check,off";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "check";
+ }
+ program {
+ name: "text_show";
+ signal: "elm,state,text,visible";
+ source: "elm";
+ action: STATE_SET "visible" 0.0;
+ target: "elm.text";
+ }
+ program {
+ name: "text_hide";
+ signal: "elm,state,text,hidden";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.text";
+ }
+ program {
+ name: "icon_show";
+ signal: "elm,state,icon,visible";
+ source: "elm";
+ action: STATE_SET "visible" 0.0;
+ target: "elm.swallow.content";
+ }
+ program {
+ name: "icon_hide";
+ signal: "elm,state,icon,hidden";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.swallow.content";
+ }
+ program {
+ name: "disable";
+ signal: "elm,state,disabled";
+ source: "elm";
+ action: STATE_SET "disabled" 0.0;
+ target: "disabler";
+ target: "bg";
+ target: "bg2";
+ after: "disable_text";
+ }
+ program {
+ name: "disable_text";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"elm.text", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"elm.text", "disabled_visible", 0.0);
+ else
+ set_state(PART:"elm.text", "disabled", 0.0);
+
+ get_state(PART:"elm.swallow.content", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"elm.swallow.content", "disabled_visible", 0.0);
+ else
+ set_state(PART:"elm.swallow.content", "disabled", 0.0);
+
+ get_state(PART:"check", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"check", "disabled_visible", 0.0);
+ }
+ }
+ program {
+ name: "enable";
+ signal: "elm,state,enabled";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "disabler";
+ target: "bg";
+ target: "bg2";
+ after: "enable_text";
+ }
+ program {
+ name: "enable_text";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"elm.text", st, 30, vl);
+ if (!strcmp(st, "disabled_visible"))
+ set_state(PART:"elm.text", "visible", 0.0);
+ else
+ set_state(PART:"elm.text", "default", 0.0);
+
+ get_state(PART:"elm.swallow.content", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"elm.swallow.content", "visible", 0.0);
+ else
+ set_state(PART:"elm.swallow.content", "default", 0.0);
+
+ get_state(PART:"check", st, 30, vl);
+ if (!strcmp(st, "disabled_visible"))
+ set_state(PART:"check", "visible", 0.0);
+ }
+ }
+ }
+ }
+
};
#define N_IMAGES (1)
+#define GRID_ITEM_SIZE 100
+
+static int g_clipdrawer_mode = 0;
// gic should live at gengrid callback functions
Elm_Gengrid_Item_Class gic;
{
Elm_Gengrid_Item *item;
const char *path;
+ Evas_Object *delbtn;
} gridimgitem_t;
-static void _list_click( void *data, Evas_Object *obj, void *event_info )
+static int toggle_clipdrawer_mode()
+{
+ g_clipdrawer_mode = !g_clipdrawer_mode;
+ return g_clipdrawer_mode;
+}
+
+static int get_clipdrawer_mode()
+{
+ return g_clipdrawer_mode;
+}
+
+static void _list_longpress(void *data, Evas_Object *obj, void *event_info)
+{
+ struct appdata *ad = data;
+
+ clipdrawer_change_mode(ad);
+}
+
+static void _list_click_paste(void *data, Evas_Object *obj, void *event_info)
{
struct appdata *ad = data;
Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
// clipdrawer_lower_view(ad);
}
+static void _list_del_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_List_Item *it = (Elm_List_Item *)data;
+ evas_object_del(obj);
+
+ if((int)event_info == ELM_POPUP_RESPONSE_OK)
+ elm_list_item_del(it);
+}
+
+static void _list_click_delete(void *data, Evas_Object *obj, void *event_info)
+{
+ struct appdata *ad = data;
+ Elm_List_Item *it = (Elm_List_Item *) elm_list_selected_item_get(obj);
+ if (it == NULL)
+ return;
+
+ elm_list_item_selected_set(it, 0);
+
+ Evas_Object *popup = elm_popup_add(ad->win_main);
+ elm_popup_timeout_set(popup, 3);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_popup_desc_set(popup, "Are you sure delete this?");
+ elm_popup_buttons_add(popup, 2,
+ "Yes", ELM_POPUP_RESPONSE_OK,
+ "No", ELM_POPUP_RESPONSE_CANCEL,
+ NULL);
+ evas_object_smart_callback_add(popup, "response", _list_del_response_cb, it);
+ evas_object_show(popup);
+
+// char *slabel = NULL;
+// slabel = elm_list_item_label_get(it);
+}
+
int clipdrawer_update_contents(void *data)
{
struct appdata *ad = data;
return elm_entry_markup_to_utf8(escstr);
}
-Evas_Object* grid_icon_get(const void *data, Evas_Object *obj, const char *part)
+Evas_Object* _grid_icon_get(const void *data, Evas_Object *obj, const char *part)
{
+ int delete_mode = get_clipdrawer_mode();
gridimgitem_t *ti = (gridimgitem_t *)data;
if (!strcmp(part, "elm.swallow.icon"))
{
evas_object_show(icon);
return icon;
}
+ else if (!strcmp(part, "elm.swallow.end") && delete_mode)
+ {
+ ti->delbtn = elm_check_add(obj);
+ elm_object_style_set(ti->delbtn, "extended/imagegrid");
+ elm_check_state_set(ti->delbtn, 1);
+ evas_object_show(ti->delbtn);
+ return ti->delbtn;
+ }
+
return NULL;
}
-static void grid_selected(void *data, Evas_Object *obj, void *event_info)
+static void _grid_longpress(void *data, Evas_Object *obj, void *event_info)
+{
+ struct appdata *ad = data;
+ clipdrawer_change_mode(ad);
+}
+
+
+static void _grid_click_paste(void *data, Evas_Object *obj, void *event_info)
{
struct appdata *ad = data;
char *file, *p;
elm_gengrid_item_selected_set(sgobj, EINA_FALSE);
}
-void grid_del(const void *data, Evas_Object *obj)
+static void _grid_del_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Gengrid_Item *it = (Elm_Gengrid_Item *)data;
+ evas_object_del(obj);
+
+ if((int)event_info == ELM_POPUP_RESPONSE_OK)
+ elm_gengrid_item_del(it);
+}
+
+static void _grid_click_delete(void *data, Evas_Object *obj, void *event_info)
+{
+ struct appdata *ad = data;
+ Elm_Gengrid_Item *sgobj = NULL;
+ sgobj = elm_gengrid_selected_item_get(ad->imggrid);
+ gridimgitem_t *ti = NULL;
+ ti = elm_gengrid_item_data_get(sgobj);
+
+ if (!sgobj || !ti)
+ {
+ DTRACE("ERR: cbhm can't get the clicked del image\n");
+ return;
+ }
+
+ Evas_Object *popup = elm_popup_add(ad->win_main);
+ elm_popup_timeout_set(popup, 3);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_popup_desc_set(popup, "Are you sure delete this?");
+ elm_popup_buttons_add(popup, 2,
+ "Yes", ELM_POPUP_RESPONSE_OK,
+ "No", ELM_POPUP_RESPONSE_CANCEL,
+ NULL);
+ evas_object_smart_callback_add(popup, "response", _grid_del_response_cb, sgobj);
+ evas_object_show(popup);
+}
+
+void _grid_del(const void *data, Evas_Object *obj)
{
gridimgitem_t *ti = (gridimgitem_t *)data;
eina_stringshare_del(ti->path);
free(ti);
}
-// FIXME: how to remove main_ad?
+int clipdrawer_refresh_imghistory_item(void *data, int delete_mode)
+{
+ struct appdata *ad = data;
+ Eina_List *oldlist = NULL;
+ const Eina_List *l;
+ Elm_Gengrid_Item *lgrid;
+ gridimgitem_t *lgitem;
+ Evas_Object *ngg;
+ Evas_Object *oldgg;
+
+ oldlist = elm_gengrid_items_get(ad->imggrid);
+ elm_layout_content_unset(ad->ly_main, "imagehistory/list");
+ ngg = elm_gengrid_add(ad->win_main);
+ elm_layout_content_set(ad->ly_main, "imagehistory/list", ngg);
+ oldgg = ad->imggrid;
+ ad->imggrid = ngg;
+ elm_gengrid_item_size_set(ad->imggrid, GRID_ITEM_SIZE, GRID_ITEM_SIZE+3);
+ elm_gengrid_align_set(ad->imggrid, 0.0, 0.0);
+ elm_gengrid_horizontal_set(ad->imggrid, EINA_TRUE);
+ elm_gengrid_bounce_set(ad->imggrid, EINA_TRUE, EINA_FALSE);
+ elm_gengrid_multi_select_set(ad->imggrid, EINA_FALSE);
+ if (delete_mode)
+ evas_object_smart_callback_add(ad->imggrid, "selected", _grid_click_delete, ad);
+ else
+ evas_object_smart_callback_add(ad->imggrid, "selected", _grid_click_paste, ad);
+ evas_object_smart_callback_add(ad->imggrid, "longpressed", _grid_longpress, ad);
+ evas_object_size_hint_weight_set(ad->imggrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ gic.item_style = "default_grid";
+ gic.func.label_get = NULL;
+ gic.func.icon_get = _grid_icon_get;
+ gic.func.state_get = NULL;
+ gic.func.del = _grid_del;
+
+ EINA_LIST_REVERSE_FOREACH(oldlist, l, lgrid)
+ {
+ lgitem = elm_gengrid_item_data_get(lgrid);
+ clipdrawer_add_image_item(lgitem->path);
+ }
+
+ evas_object_show (ad->imggrid);
+
+ elm_gengrid_clear(oldgg);
+ evas_object_hide(oldgg);
+ evas_object_del(oldgg);
+
+ return 0;
+}
+
+int clipdrawer_refresh_txthistory_item(void *data, int delete_mode)
+{
+ struct appdata *ad = data;
+ Eina_List *oldlist = NULL;
+ const Eina_List *l;
+ Elm_List_Item *litem;
+ const char *ltext;
+ Evas_Object *ntl = NULL;
+// Evas_Object *ci = NULL;
+
+ oldlist = elm_list_items_get(ad->txtlist);
+ elm_layout_content_unset(ad->ly_main, "texthistory/list");
+ ntl = elm_list_add(ad->win_main);
+ elm_layout_content_set(ad->ly_main, "texthistory/list", ntl);
+ elm_object_style_set(ntl, "extended/historylist");
+
+ EINA_LIST_FOREACH(oldlist, l, litem)
+ {
+ ltext = elm_list_item_label_get(litem);
+ if (delete_mode)
+ {
+ Evas_Object *ci = elm_icon_add(ad->win_main);
+ elm_icon_file_set(ci, "/usr/share/icon/cbhm/05_delete.png", NULL);
+ evas_object_size_hint_min_set(ci, 33 * elm_scale_get(), 33 * elm_scale_get());
+// evas_object_size_hint_aspect_set(ci, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ evas_object_show(ci);
+ elm_list_item_append(ntl, ltext, NULL, ci, NULL, ad);
+ }
+ else
+ {
+ elm_list_item_append(ntl, ltext, NULL, NULL, NULL, ad);
+ }
+ }
+
+ elm_list_clear(ad->txtlist);
+ evas_object_hide(ad->txtlist);
+ evas_object_del(ad->txtlist);
+
+ ad->txtlist = ntl;
+ evas_object_size_hint_weight_set(ad->txtlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ if (delete_mode)
+ evas_object_smart_callback_add(ad->txtlist, "selected", _list_click_delete, ad);
+ else
+ evas_object_smart_callback_add(ad->txtlist, "selected", _list_click_paste, ad);
+ evas_object_smart_callback_add(ad->txtlist, "longpressed", _list_longpress, ad);
+
+ elm_list_go(ad->txtlist);
+
+ return 0;
+}
+
+int clipdrawer_change_mode(void *data)
+{
+ struct appdata *ad = data;
+
+ toggle_clipdrawer_mode();
+
+ DTRACE("clipdrawer delete mode = %d\n", get_clipdrawer_mode());
+
+ clipdrawer_refresh_imghistory_item(ad, get_clipdrawer_mode());
+ clipdrawer_refresh_txthistory_item(ad, get_clipdrawer_mode());
+
+ return 0;
+}
+
+// FIXME: how to remove calling g_get_main_appdata()?
// it's mainly used at 'clipdrawer_add_image_item'
int clipdrawer_add_image_item(char *imagepath)
{
igl_counter = eina_list_count(igl);
if (igl_counter >= HISTORY_QUEUE_MAX_IMG_ITEMS)
{
- elm_gengrid_item_del(eina_list_nth(igl, 0));
- //elm_gengrid_item_del(eina_list_last(igl));
+ elm_gengrid_item_del(eina_list_data_get(eina_list_last(igl)));
}
newgenimg = malloc(sizeof(gridimgitem_t));
newgenimg->path = eina_stringshare_add(imagepath);
- newgenimg->item = elm_gengrid_item_append(ad->imggrid, &gic, newgenimg, NULL, NULL);
-
+ newgenimg->item = elm_gengrid_item_prepend(ad->imggrid, &gic, newgenimg, NULL, NULL);
+
return TRUE;
}
struct appdata *ad = data;
double cdy, cdw;
+ // for elm_check, elm_list
+ elm_theme_extension_add(NULL, APP_EDJ_FILE);
+
cdy = (1.0*CLIPDRAWER_HEIGHT/800)*ad->root_h;
cdw = (1.0*CLIPDRAWER_POS_Y/800*1.0)*ad->root_h;
ad->imggrid = NULL;
ad->imggrid = elm_gengrid_add(ad->win_main);
elm_layout_content_set(ad->ly_main, "imagehistory/list", ad->imggrid);
- elm_gengrid_item_size_set(ad->imggrid, 100, 100+3);
+ elm_gengrid_item_size_set(ad->imggrid, GRID_ITEM_SIZE, GRID_ITEM_SIZE+3);
elm_gengrid_align_set(ad->imggrid, 0.0, 0.0);
elm_gengrid_horizontal_set(ad->imggrid, EINA_TRUE);
elm_gengrid_bounce_set(ad->imggrid, EINA_TRUE, EINA_FALSE);
elm_gengrid_multi_select_set(ad->imggrid, EINA_FALSE);
- evas_object_smart_callback_add(ad->imggrid, "selected", grid_selected, ad);
+ evas_object_smart_callback_add(ad->imggrid, "selected", _grid_click_paste, ad);
+ evas_object_smart_callback_add(ad->imggrid, "longpressed", _grid_longpress, ad);
evas_object_size_hint_weight_set(ad->imggrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_gengrid_clear(ad->imggrid);
gic.item_style = "default_grid";
gic.func.label_get = NULL;
- gic.func.icon_get = grid_icon_get;
+ gic.func.icon_get = _grid_icon_get;
gic.func.state_get = NULL;
- gic.func.del = grid_del;
+ gic.func.del = _grid_del;
int i;
gridimgitem_t *newgenimg;
ad->txtlist = elm_list_add(ad->win_main);
elm_layout_content_set(ad->ly_main, "texthistory/list", ad->txtlist);
- elm_theme_extension_add(NULL, APP_EDJ_FILE);
elm_object_style_set(ad->txtlist, "extended/historylist");
evas_object_size_hint_weight_set(ad->txtlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_smart_callback_add(ad->txtlist, "selected", _list_click, ad);
+ evas_object_smart_callback_add(ad->txtlist, "selected", _list_click_paste, ad);
+ evas_object_smart_callback_add(ad->txtlist, "longpressed", _list_longpress, ad);
elm_list_item_append(ad->txtlist, "default", NULL, NULL, NULL, ad);
elm_list_go(ad->txtlist);
// for debug
// at starting, showing app view
- //clipdrawer_activate_view(ad);
+ clipdrawer_activate_view(ad);
return 0;
}
{
evas_object_hide(ad->win_main);
elm_win_lower(ad->win_main);
+
+ // if delete mode, then back to normal mode
+ if (get_clipdrawer_mode())
+ clipdrawer_change_mode(ad);
}
}