typedef struct _Pan Pan;
#define PRELOAD 1
+#define REORDER_EFFECT_TIME 0.5
struct _Elm_Gengrid_Item
{
Evas_Object *spacer;
const Elm_Gengrid_Item_Class *gic;
Ecore_Timer *long_timer;
+ Ecore_Animator *item_moving_effect_timer;
Widget_Data *wd;
Eina_List *labels, *icons, *states, *icon_objs;
struct
const void *data;
} func;
- Evas_Coord x, y, dx, dy;
- int relcount;
- int walking;
+ Evas_Coord x, y, dx, dy, ox, oy, tx, ty, rx, ry;
+ unsigned int moving_effect_start_time;
+ int relcount;
+ int walking;
struct
{
Eina_Bool disabled : 1;
Eina_Bool selected : 1;
Eina_Bool hilighted : 1;
+ Eina_Bool moving : 1;
};
struct _Widget_Data
Elm_Gengrid_Item *last_selected_item, *reorder_item;
double align_x, align_y;
- Evas_Coord pan_x, pan_y;
+ Evas_Coord pan_x, pan_y, old_pan_x, old_pan_y;
Evas_Coord item_width, item_height; /* Each item size */
Evas_Coord minw, minh; /* Total obj size */
Evas_Coord reorder_item_x, reorder_item_y;
Eina_Bool v_bounce : 1;
Eina_Bool reorder_mode : 1;
Eina_Bool reorder_item_changed : 1;
+ Eina_Bool move_effect_enabled : 1;
};
#define ELM_GENGRID_ITEM_FROM_INLIST(item) \
static const char SIG_SCROLL[] = "scroll";
static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
+static const char SIG_MOVED[] = "moved";
static const Evas_Smart_Cb_Description _signals[] = {
{SIG_CLICKED_DOUBLE, ""},
{SIG_SCROLL, ""},
{SIG_SCROLL_DRAG_START, ""},
{SIG_SCROLL_DRAG_STOP, ""},
+ {SIG_MOVED, ""},
{NULL, NULL}
};
evas_object_raise(item->base.view);
elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
- edje_object_signal_emit(item->base.view, "elm,state,reorder_enabled", "elm");
+ edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
}
return ECORE_CALLBACK_CANCEL;
}
if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
- evas_object_smart_callback_call(item->wd->self, "moved", item->wd->reorder_item);
+ evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
item->wd->reorder_item = NULL;
elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
- edje_object_signal_emit(item->base.view, "elm,state,reorder_disabled", "elm");
+ edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
}
if (item->wd->longpressed)
{
item->want_unrealize = EINA_FALSE;
}
+static Eina_Bool
+_reorder_item_moving_effect_timer_cb(void *data)
+{
+ Elm_Gengrid_Item *item = data;
+ double time, t;
+ Evas_Coord dx, dy;
+
+ time = REORDER_EFFECT_TIME;
+ t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
+ dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
+ dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
+
+ if (t <= time)
+ {
+ item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
+ item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
+ }
+ else
+ {
+ item->rx += dx;
+ item->ry += dy;
+ }
+
+ if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
+ (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
+ {
+ evas_object_move(item->base.view, item->tx, item->ty);
+ evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
+ item->moving = EINA_FALSE;
+ item->item_moving_effect_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ evas_object_move(item->base.view, item->rx, item->ry);
+ evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
static void
_item_place(Elm_Gengrid_Item *item,
Evas_Coord cx,
evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
if ((item->wd->reorder_mode) && (item->wd->reorder_item))
{
+ if (item->moving) return;
+
+ if (!item->wd->move_effect_enabled)
+ {
+ item->ox = x;
+ item->oy = y;
+ }
if (item->wd->reorder_item == item)
{
evas_object_move(item->base.view,
}
else
{
+ if (item->wd->move_effect_enabled)
+ {
+ if ((item->ox != x) || (item->oy != y))
+ {
+ if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
+ ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
+ ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
+ {
+ item->tx = x;
+ item->ty = y;
+ item->rx = item->ox;
+ item->ry = item->oy;
+ item->moving = EINA_TRUE;
+ item->moving_effect_start_time = ecore_loop_time_get();
+ item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
+ return;
+ }
+ }
+ }
+
if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
item->wd->item_width, item->wd->item_height,
x+(item->wd->item_width/2), y+(item->wd->item_height/2),
EINA_INLIST_GET(item));
item->wd->reorder_item_changed = EINA_TRUE;
-
+ item->wd->move_effect_enabled = EINA_TRUE;
if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
if (!cx) cy++;
}
}
+
+ if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
+ {
+ if (!sd->wd->reorder_item_changed)
+ {
+ sd->wd->old_pan_x = sd->wd->pan_x;
+ sd->wd->old_pan_y = sd->wd->pan_y;
+ }
+ sd->wd->move_effect_enabled = EINA_FALSE;
+ }
evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
}
wd->self = obj;
wd->align_x = 0.5;
wd->align_y = 0.5;
+ wd->h_bounce = bounce;
+ wd->v_bounce = bounce;
wd->no_select = EINA_FALSE;
evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);