#include <assert.h>
+#include <fnmatch.h>
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include "elm_priv.h"
Eina_Bool swipe : 1;
Eina_Bool reorder_mode : 1;
Eina_Bool reorder_pan_move : 1;
- Eina_List *dragging_queue;
struct
{
Evas_Coord x, y;
Eina_Bool effect_mode : 1;
Eina_Bool auto_scrolled : 1;
Eina_Bool pan_changed : 1;
+ Eina_Bool drag_started : 1;
int edit_mode;
Ecore_Animator *item_moving_effect_timer;
Evas_Object *alpha_bg;
Evas_Coord expand_item_gap;
int move_effect_mode;
Ecore_Job *changed_job;
- Elm_Genlist_Item *rename_it;
+ Elm_Genlist_Item *focused_rename_it;
+ Evas_Coord current_scrl_x;
+ Evas_Coord current_scrl_y;
};
struct _Item_Block
static const char SIG_DRAG_STOP[] = "drag,stop";
static const char SIG_DRAG[] = "drag";
static const char SIG_LONGPRESSED[] = "longpressed";
+static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
+static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
+static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
+static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
{SIG_DRAG_STOP, ""},
{SIG_DRAG, ""},
{SIG_LONGPRESSED, ""},
+ {SIG_SCROLL_ANIM_START, ""},
+ {SIG_SCROLL_ANIM_STOP, ""},
+ {SIG_SCROLL_DRAG_START, ""},
+ {SIG_SCROLL_DRAG_STOP, ""},
{SIG_SCROLL_EDGE_TOP, ""},
{SIG_SCROLL_EDGE_BOTTOM, ""},
{SIG_SCROLL_EDGE_LEFT, ""},
{
elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
evas_object_focus_set(wd->obj, EINA_TRUE);
- if ((wd->selected) && (!wd->last_selected_item))
+ if ((wd->items) && (wd->selected) && (!wd->last_selected_item))
wd->last_selected_item = eina_list_data_get(wd->selected);
}
else
{
Widget_Data *wd = elm_widget_data_get(data);
Evas_Coord x, y, w, h;
+ Evas_Coord px, py, pw, ph;
+ Evas_Coord new_x, new_y;
if (!wd) return;
elm_widget_show_region_get(obj, &x, &y, &w, &h);
+ evas_object_geometry_get(wd->pan_smart, &px, &py, &pw, &ph);
+
//x & y are screen coordinates, Add with pan coordinates
- x += wd->pan_x;
- y += wd->pan_y;
- elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
+ new_x = wd->current_scrl_x + x - pw + w;
+ new_y = wd->current_scrl_y + y - ph + h;
+
+ if (((new_y > 0) && wd->pan_changed && (y > ph)) || ((new_x > 0) && wd->pan_changed && (x > pw)))
+ elm_smart_scroller_child_pos_set(wd->scr, new_x, new_y);
+ else
+ elm_smart_scroller_child_pos_set(wd->scr, wd->current_scrl_x, wd->current_scrl_y);
}
static void
if ((adx > minw) || (ady > minh))
{
it->dragging = EINA_TRUE;
- it->wd->dragging_queue = eina_list_append(it->wd->dragging_queue, it);
if (it->long_timer)
{
ecore_timer_del(it->long_timer);
_item_unselect(it);
if (dy < 0)
{
- if (ady > adx)
+ if ((ady > adx) && (!it->wd->drag_started))
evas_object_smart_callback_call(it->base.widget,
SIG_DRAG_START_UP, it);
else
}
else
{
- if (ady > adx)
+ if ((ady > adx) && (!it->wd->drag_started))
evas_object_smart_callback_call(it->base.widget,
SIG_DRAG_START_DOWN, it);
else
Eina_List *list, *l;
it->long_timer = NULL;
- if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
+ if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->focused_rename_it))
return ECORE_CALLBACK_CANCEL;
it->wd->longpressed = EINA_TRUE;
evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
ecore_timer_del(it->long_timer);
it->long_timer = NULL;
}
- while (it->wd->dragging_queue)
+ if (it->dragging)
{
- Elm_Genlist_Item *dragging_it = NULL;
- dragging_it = eina_list_data_get(it->wd->dragging_queue);
- dragging_it->dragging = EINA_FALSE;
- evas_object_smart_callback_call(dragging_it->base.widget, SIG_DRAG_STOP, dragging_it);
- if (dragging_it->want_unrealize)
- {
- _item_unrealize(dragging_it, EINA_FALSE);
- if (dragging_it->block->want_unrealize)
- _item_block_unrealize(it->block);
- }
- it->wd->dragging_queue = eina_list_remove_list(it->wd->dragging_queue,it->wd->dragging_queue);
+ it->dragging = EINA_FALSE;
+ evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
dragged = 1;
}
if (it->swipe_timer)
it->wd->wasselected = EINA_FALSE;
return;
}
+ if (dragged)
+ {
+ if (it->want_unrealize)
+ {
+ _item_unrealize(it, EINA_FALSE);
+ if (it->block->want_unrealize)
+ _item_block_unrealize(it->block);
+ }
+ }
if ((it->disabled) || (dragged) || (it->display_only)) return;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
if (it->wd->multi)
}
static void
+_mouse_down_scroller(void *data,
+ Evas *evas __UNUSED__,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return;
+ wd->drag_started = EINA_FALSE;
+}
+
+static void
+_mouse_up_scroller(void *data,
+ Evas *evas __UNUSED__,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return;
+ wd->drag_started = EINA_FALSE;
+}
+
+static void
+_mouse_move_scroller(void *data,
+ Evas *evas __UNUSED__,
+ Evas_Object *obj __UNUSED__,
+ void *event_info)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Evas_Event_Mouse_Move *ev = event_info;
+ Evas_Coord minw = 0, minh = 0, dx, dy, adx, ady;
+
+ if (!wd) return;
+ if (wd->drag_started) return;
+
+ elm_coords_finger_size_adjust(1, &minw, 1, &minh);
+ dx = ev->cur.canvas.x - ev->prev.canvas.x;
+ dy = ev->cur.canvas.y - ev->prev.canvas.y;
+ adx = dx;
+ ady = dy;
+ if (adx < 0) adx = -dx;
+ if (ady < 0) ady = -dy;
+ if (((ady < minh) && (ady > minh / 2)) && (ady > adx))
+ {
+ if (dy < 0)
+ {
+ evas_object_smart_callback_call(data, SIG_DRAG_START_UP, NULL);
+ wd->drag_started = EINA_TRUE;
+ }
+ else
+ {
+ evas_object_smart_callback_call(data, SIG_DRAG_START_DOWN, NULL);
+ wd->drag_started = EINA_TRUE;
+ }
+ }
+}
+
+static void
_signal_expand_toggle(void *data,
Evas_Object *obj __UNUSED__,
const char *emission __UNUSED__,
evas_event_freeze(te);
it->nocache = EINA_FALSE;
_mode_item_unrealize(it);
+ if (it->group_item)
+ evas_object_raise(it->group_item->base.view);
snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
evas_event_thaw(te);
{
Elm_Genlist_Item *it = data;
if (it) it->defer_unrealize = EINA_TRUE;
+ if (it->renamed && (it->wd->focused_rename_it != it)) it->wd->focused_rename_it = it;
}
static void
{
Elm_Genlist_Item *it = data;
if (it) it->defer_unrealize = EINA_FALSE;
+ if (it->renamed && (it->wd->focused_rename_it == it)) it->wd->focused_rename_it = NULL;
+}
+
+static void
+_item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ Elm_Genlist_Item *it = event_info;
+ if (!it) return;
+ if (it->wd->last_selected_item == it)
+ it->wd->last_selected_item = NULL;
}
static void
_item_label_realize(Elm_Genlist_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
if (it->itc->func.label_get)
{
*source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
char *s = it->itc->func.label_get
((void *)it->base.data, it->base.widget, key);
{
edje_object_part_text_set(target, key, "");
}
+
}
}
}
static Eina_List *
+_item_icon_unrealize(Elm_Genlist_Item *it,
+ Evas_Object *target,
+ Eina_List **source,
+ const char *parts)
+{
+ Eina_List *res = it->icon_objs;
+
+ if (it->itc->func.icon_get)
+ {
+ const Eina_List *l;
+ const char *key;
+ Evas_Object *ic = NULL;
+
+ EINA_LIST_FOREACH(*source, l, key)
+ {
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
+ ic = edje_object_part_swallow_get(target, key);
+ if (ic)
+ {
+ res = eina_list_remove(res, ic);
+ edje_object_part_unswallow(target, ic);
+ evas_object_del(ic);
+ }
+ }
+ }
+
+ return res;
+}
+
+static Eina_List *
_item_icon_realize(Elm_Genlist_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
Eina_List *res = NULL;
const char *key;
*source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
+ if (parts && (eina_list_count(*source) != eina_list_count(it->icon_objs)))
+ res = it->icon_objs;
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
Evas_Object *ic = it->itc->func.icon_get
((void *)it->base.data, it->base.widget, key);
static void
_item_state_realize(Elm_Genlist_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
if (it->itc->func.state_get)
{
*source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
Eina_Bool on = it->itc->func.state_get
((void *)it->base.data, it->base.widget, key);
}
else
{
- _item_label_realize(it, it->base.view, &it->labels);
- it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
- _item_state_realize(it, it->base.view, &it->states);
+ _item_label_realize(it, it->base.view, &it->labels, NULL);
+ it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons, NULL);
+ _item_state_realize(it, it->base.view, &it->states, NULL);
if (it->itc->func.icon_get) // for rename mode
{
const Eina_List *l;
const char *key;
if (it->renamed)
{
+ edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
it->icons =
elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
EINA_LIST_FOREACH(it->icons, l, key)
evas_event_freeze(evas_object_evas_get(itb->wd->obj));
EINA_LIST_FOREACH(itb->items, l, it)
{
- if (it->flags != ELM_GENLIST_ITEM_GROUP)
+ if (itb->must_recalc || it->flags != ELM_GENLIST_ITEM_GROUP)
{
if (it->dragging)
{
if (vis)
{
if (!it->realized) _item_realize(it, in, EINA_FALSE);
- if (it->renamed)
- {
- if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
- edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
- }
}
}
if (it->realized)
}
else
{
- if (!it->dragging) _item_unrealize(it, EINA_FALSE);
+ if (!it->dragging && (!it->wd->item_moving_effect_timer)) _item_unrealize(it, EINA_FALSE);
}
}
in++;
if (it->mincalcd) it->mincalcd = EINA_FALSE;
itb->changed = EINA_TRUE;
if (itb->must_recalc) did_must_recalc = EINA_TRUE;
- itb->must_recalc = EINA_FALSE;
if (itb->realized) _item_block_unrealize(itb);
+ itb->must_recalc = EINA_FALSE;
}
showme = _item_block_recalc(itb, in, EINA_FALSE);
chb = itb;
Pan *sd = evas_object_smart_data_get(obj);
Item_Block *itb;
Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
+ Evas_Coord scr_x, scr_y;
int in = 0;
Elm_Genlist_Item *git;
Eina_List *l;
if (!sd) return;
evas_event_freeze(evas_object_evas_get(obj));
-
+ elm_smart_scroller_child_pos_get(sd->wd->scr, &scr_x, &scr_y);
+ sd->wd->current_scrl_x = scr_x;
+ sd->wd->current_scrl_y = scr_y;
if (sd->wd->pan_changed)
{
_calc_job(sd->wd);
}
static void
+_scr_anim_start(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
+}
+
+static void
+_scr_anim_stop(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
+}
+
+static void
+_scr_drag_start(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
+}
+
+static void
+_scr_drag_stop(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
+}
+
+static void
_scroll_edge_left(void *data,
Evas_Object *scr __UNUSED__,
void *event_info __UNUSED__)
_mouse_move, it);
/* label_get, icon_get, state_get */
- _item_label_realize(it, it->mode_view, &it->mode_labels);
+ _item_label_realize(it, it->mode_view, &it->mode_labels, NULL);
if (it->itc->func.icon_get)
{
const Eina_List *l;
}
}
}
- _item_state_realize(it, it->mode_view, &it->mode_states);
+ _item_state_realize(it, it->mode_view, &it->mode_states, NULL);
edje_object_part_swallow(it->mode_view,
edje_object_data_get(it->mode_view, "mode_part"),
it->base.view);
evas_event_freeze(evas_object_evas_get(it->wd->obj));
_mode_item_realize(it);
+ if (it->group_item)
+ evas_object_raise(it->group_item->base.view);
_item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
evas_event_thaw(evas_object_evas_get(it->wd->obj));
evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
wd->scr = elm_smart_scroller_add(e);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_DOWN,
+ _mouse_down_scroller, obj);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_UP,
+ _mouse_up_scroller, obj);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOUSE_MOVE,
+ _mouse_move_scroller, obj);
elm_smart_scroller_widget_set(wd->scr, obj);
elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
elm_widget_style_get(obj));
_elm_config->thumbscroll_bounce_enable);
elm_widget_resize_object_set(obj, wd->scr);
+ evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
+ evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
+ evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
+ evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
obj);
it->mouse_cursor = NULL;
it->expanded_depth = 0;
elm_widget_item_text_get_hook_set(it, _item_label_hook);
+ elm_widget_item_del_cb_set(it, _item_del_hook);
if (it->parent)
{
{
showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
it->block->changed = 0;
+ if(wd->pan_changed)
+ {
+ if (wd->calc_job) ecore_job_del(wd->calc_job);
+ wd->calc_job = NULL;
+ _calc_job(wd);
+ wd->pan_changed = EINA_FALSE;
+ }
}
if (showme) it->block->showme = EINA_TRUE;
if (eina_inlist_count(wd->blocks) > 1)
if (!wd) return NULL;
Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
func_data);
+
if (!it) return NULL;
if (!it->parent)
{
if (itb->items) eina_list_free(itb->items);
free(itb);
}
+ wd->pan_changed = EINA_TRUE;
if (wd->calc_job)
{
ecore_job_del(wd->calc_job);
}
EAPI void
+elm_genlist_item_fields_update(Elm_Genlist_Item *it,
+ const char *parts,
+ Elm_Genlist_Item_Field_Flags itf)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+ if (!it->block) return;
+ if (it->delete_me) return;
+
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
+ _item_label_realize(it, it->base.view, &it->labels, parts);
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_ICON))
+ {
+ it->icon_objs = _item_icon_unrealize(it, it->base.view,
+ &it->icons, parts);
+ it->icon_objs = _item_icon_realize(it, it->base.view,
+ &it->icons, parts);
+ }
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
+ _item_state_realize(it, it->base.view, &it->states, parts);
+}
+
+EAPI void
elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
const Elm_Genlist_Item_Class *itc)
{
}
static Evas_Object *
_elm_genlist_item_label_create(void *data,
- Evas_Object *obj __UNUSED__,
- Evas_Object *tooltip,
+ Evas_Object *obj,
void *item __UNUSED__)
{
- Evas_Object *label = elm_label_add(tooltip);
+ Evas_Object *label = elm_label_add(obj);
if (!label)
return NULL;
elm_object_style_set(label, "tooltip");
_item_auto_scroll(wd);
evas_object_lower(wd->alpha_bg);
evas_object_hide(wd->alpha_bg);
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
+ evas_object_smart_changed(wd->pan_smart);
return ECORE_CALLBACK_CANCEL;
}
return ECORE_CALLBACK_RENEW;
const Eina_List *l;
const char *key;
+ if (it->renamed) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
EINA_LIST_FOREACH(it->icons, l, key)
{
{
_item_unrealize(it, EINA_FALSE);
it->renamed = EINA_TRUE;
- it->wd->rename_it = it;
it->nocache = EINA_TRUE;
if (it->selected) _item_unselect(it);
{
it->renamed = EINA_FALSE;
it->nocache = EINA_TRUE;
- it->wd->rename_it = NULL;
_item_cache_zero(it->wd);
elm_genlist_item_update(it);
}