'everything' keep selected item aligned to center when scrolling
SVN revision: 47984
This commit is contained in:
parent
d71da20c37
commit
6701cecab9
|
@ -1,5 +1,7 @@
|
|||
#include "e_mod_main.h"
|
||||
|
||||
/* TODO cleanup !!! */
|
||||
|
||||
typedef struct _View View;
|
||||
typedef struct _Smart_Data Smart_Data;
|
||||
typedef struct _Item Item;
|
||||
|
@ -29,14 +31,16 @@ struct _Smart_Data
|
|||
Item *cur_item;
|
||||
Ecore_Idle_Enterer *idle_enter;
|
||||
Ecore_Idle_Enterer *thumb_idler;
|
||||
|
||||
Evas_Coord x, y, w, h;
|
||||
Evas_Coord cx, cy, cw, ch;
|
||||
Evas_Coord sx, sy;
|
||||
Evas_Coord sel_pos;
|
||||
Eina_Bool update : 1;
|
||||
Eina_Bool switch_mode : 1;
|
||||
Eina_List *queue;
|
||||
|
||||
Evas_Object *selctor;
|
||||
Evas_Object *selector;
|
||||
|
||||
double scroll_align;
|
||||
double scroll_align_to;
|
||||
|
@ -149,6 +153,10 @@ _thumb_idler(void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_pan_item_select(Evas_Object *obj, Item *it, int scroll);
|
||||
|
||||
|
||||
static int
|
||||
_e_smart_reconfigure_do(void *data)
|
||||
{
|
||||
|
@ -229,10 +237,17 @@ _e_smart_reconfigure_do(void *data)
|
|||
x += ww;
|
||||
}
|
||||
|
||||
if (sd->view->list_mode)
|
||||
mh += sd->h % 32;
|
||||
|
||||
if ((mw != sd->cw) || (mh != sd->ch))
|
||||
{
|
||||
sd->cw = mw;
|
||||
sd->ch = mh;
|
||||
|
||||
/* if (sd->view->list_mode)
|
||||
* sd->ch += sd->h % 32; */
|
||||
|
||||
if (sd->cx > (sd->cw - sd->w))
|
||||
{
|
||||
sd->cx = sd->cw - sd->w;
|
||||
|
@ -280,6 +295,27 @@ _e_smart_reconfigure_do(void *data)
|
|||
if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
|
||||
if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sd->selector)
|
||||
{
|
||||
sd->selector = edje_object_add(sd->view->evas);
|
||||
e_theme_edje_object_set(sd->selector, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/list");
|
||||
|
||||
evas_object_smart_member_add(sd->selector, obj);
|
||||
evas_object_clip_set(sd->selector, evas_object_clip_get(obj));
|
||||
edje_object_signal_emit(sd->selector, "e,state,selected", "e");
|
||||
}
|
||||
|
||||
if (sd->cur_item)
|
||||
evas_object_show(sd->selector);
|
||||
else
|
||||
evas_object_hide(sd->selector);
|
||||
|
||||
evas_object_resize(sd->selector, ww, hh);
|
||||
evas_object_move(sd->selector, sd->x, sd->y + sd->sel_pos);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
{
|
||||
|
@ -317,9 +353,6 @@ _e_smart_reconfigure_do(void *data)
|
|||
edje_object_signal_emit(it->frame, "e,state,browseable", "e");
|
||||
|
||||
it->visible = EINA_TRUE;
|
||||
|
||||
if (it->selected)
|
||||
edje_object_signal_emit(it->frame, "e,state,selected", "e");
|
||||
}
|
||||
|
||||
if (!eina_list_data_find(sd->queue, it))
|
||||
|
@ -359,6 +392,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
|
||||
if (recursion == 0)
|
||||
sd->idle_enter = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -379,7 +413,6 @@ _e_smart_add(Evas_Object *obj)
|
|||
sd->x = sd->y = sd->w = sd->h = 0;
|
||||
sd->sx = sd->sy = -1;
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
/* sd->selctor = */
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -408,6 +441,8 @@ _e_smart_del(Evas_Object *obj)
|
|||
}
|
||||
free(sd);
|
||||
evas_object_smart_data_set(obj, NULL);
|
||||
|
||||
evas_object_del(sd->selector);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -575,7 +610,7 @@ _animator(void *data)
|
|||
{
|
||||
double da;
|
||||
|
||||
double spd = evry_conf->scroll_speed / e_config->framerate;
|
||||
double spd = 30.0 / e_config->framerate;
|
||||
|
||||
sd->scroll_align = (sd->scroll_align * (1.0 - spd)) + (sd->scroll_align_to * spd);
|
||||
|
||||
|
@ -599,12 +634,19 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll)
|
|||
Smart_Data *sd = evas_object_smart_data_get(obj);
|
||||
double align = -1;
|
||||
|
||||
Item *tmp;
|
||||
|
||||
int prev = -1;
|
||||
|
||||
if (sd->cur_item)
|
||||
{
|
||||
prev = sd->cur_item->y / sd->cur_item->h;
|
||||
sd->cur_item->selected = EINA_FALSE;
|
||||
edje_object_signal_emit(sd->cur_item->frame, "e,state,unselected", "e");
|
||||
}
|
||||
|
||||
sd->cur_item = NULL;
|
||||
|
||||
if (!it) return;
|
||||
|
||||
sd->update = EINA_FALSE;
|
||||
|
@ -612,26 +654,81 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll)
|
|||
sd->cur_item = it;
|
||||
sd->cur_item->selected = EINA_TRUE;
|
||||
|
||||
e_scrollframe_child_pos_get(sd->view->sframe, 0, (Evas_Coord *)&sd->scroll_align);
|
||||
|
||||
if (sd->view->list_mode)
|
||||
{
|
||||
if (it->y < sd->h/2)
|
||||
align = 0;
|
||||
else
|
||||
align = it->y - sd->h/2;
|
||||
int rows = sd->h / it->h;
|
||||
int all = sd->ch / it->h;
|
||||
int cur = it->y /it->h;
|
||||
int mid = rows/2;
|
||||
int dist = mid;
|
||||
int align_to = -1;
|
||||
int scroll = (prev > 0 ? cur - prev : 0);
|
||||
|
||||
if (scroll >= 0)
|
||||
{
|
||||
if (cur <= dist || all < rows)
|
||||
{
|
||||
/* step down start */
|
||||
align = 0;
|
||||
align_to = cur;
|
||||
|
||||
/* align = it->y - (double)it->y / (double)sd->ch * (sd->h - it->h); */
|
||||
}
|
||||
else if ((it->y + it->h) - sd->cy > sd->h)
|
||||
else if ((all > rows) && (all - cur < rows - dist))
|
||||
{
|
||||
/* step down end */
|
||||
align = (cur - dist);
|
||||
align_to = rows - (all - cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* align */
|
||||
align = (cur - dist);
|
||||
}
|
||||
}
|
||||
else if (scroll < 0)
|
||||
{
|
||||
if (cur < (rows - dist))
|
||||
{
|
||||
/* step up start */
|
||||
align = 0;
|
||||
align_to = cur;
|
||||
}
|
||||
else if ((all > rows) && (all - cur <= (rows - dist)))
|
||||
{
|
||||
/* step up end */
|
||||
align = (cur - dist);
|
||||
align_to = rows - (all - cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* align */
|
||||
align = (cur - dist);
|
||||
}
|
||||
}
|
||||
|
||||
if (align_to >= 0)
|
||||
sd->sel_pos = align_to * it->h;
|
||||
|
||||
align *= it->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sd->view->zoom < 2)
|
||||
edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e");
|
||||
|
||||
if ((it->y + it->h) - sd->cy > sd->h)
|
||||
align = it->y - (2 - sd->view->zoom) * it->h;
|
||||
else if (it->y < sd->cy)
|
||||
align = it->y;
|
||||
|
||||
e_scrollframe_child_pos_get(sd->view->sframe, 0, (Evas_Coord *)&sd->scroll_align);
|
||||
}
|
||||
|
||||
if (align >= 0)
|
||||
{
|
||||
if (!scroll || !evry_conf->scroll_animate)
|
||||
{
|
||||
sd->scroll_align_to = align;
|
||||
sd->scroll_align = align;
|
||||
e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align);
|
||||
}
|
||||
|
@ -644,9 +741,6 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll)
|
|||
}
|
||||
}
|
||||
|
||||
if (sd->view->zoom < 2)
|
||||
edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e");
|
||||
|
||||
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
|
||||
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
|
||||
}
|
||||
|
@ -726,12 +820,23 @@ _update_frame(Evas_Object *obj)
|
|||
sd->animator = NULL;
|
||||
|
||||
sd->scroll_align = 0;
|
||||
|
||||
e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align);
|
||||
|
||||
_e_smart_reconfigure_do(obj);
|
||||
|
||||
if (sd->view->list_mode)
|
||||
{
|
||||
evas_object_show(sd->selector);
|
||||
edje_object_signal_emit(sd->selector, "e,state,selected", "e");
|
||||
}
|
||||
else
|
||||
evas_object_hide(sd->selector);
|
||||
|
||||
_pan_item_select(obj, sd->cur_item, 0);
|
||||
|
||||
_e_smart_reconfigure(obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1247,3 @@ view_thumb_shutdown(void)
|
|||
E_FREE(view);
|
||||
}
|
||||
|
||||
|
||||
/* EINA_MODULE_INIT(_init);
|
||||
* EINA_MODULE_SHUTDOWN(_shutdown); */
|
||||
|
||||
|
|
Loading…
Reference in New Issue