From bdb41a6254d07d3ae10216e396333d4dcd241a7b Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sat, 17 Apr 2010 17:50:27 +0000 Subject: [PATCH] 'everything' - slide anim for browsing into folders - fix for spd when framerate is below 25fps -Wall checked SVN revision: 48077 --- src/modules/everything-apps/e_mod_main.c | 12 ++--- src/modules/everything-files/e_mod_main.c | 1 - src/modules/everything-windows/e_mod_main.c | 1 - src/modules/everything/Evry.h | 4 +- src/modules/everything/e_mod_main.c | 8 --- src/modules/everything/evry.c | 39 ++++++-------- src/modules/everything/evry_config.c | 17 +++--- src/modules/everything/evry_plug_actions.c | 4 +- src/modules/everything/evry_plug_aggregator.c | 15 ------ src/modules/everything/evry_plug_view_help.c | 4 +- src/modules/everything/evry_plug_view_thumb.c | 72 ++++++++++++++++++++++---- src/modules/everything/evry_view_plugin_tabs.c | 41 ++++++++++++--- 12 files changed, 127 insertions(+), 91 deletions(-) diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index 9bd5a4e..209659d 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -117,7 +117,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item) d = e_exehist_mime_desktop_get(mime); if (d) { - if (d2 = eina_list_data_find(p->apps_mime, d)) + if ((d2 = eina_list_data_find(p->apps_mime, d))) { p->apps_mime = eina_list_remove(p->apps_mime, d2); efreet_desktop_free(d2); @@ -296,7 +296,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match) if (!exe) return NULL; - if (app = eina_hash_find(p->added, exe)) + if ((app = eina_hash_find(p->added, exe))) { if (!desktop || (!app->desktop) || (desktop == app->desktop) || @@ -615,16 +615,12 @@ _fetch(Evry_Plugin *plugin, const char *input) Eina_List *l, *ll, *previous; Efreet_Desktop *desktop; Evry_Item *it; - char *file; - int prio = 0; - int len = input ? strlen(input) : 0; + plugin->changed = 0; previous = plugin->items; plugin->items = NULL; - /* EVRY_PLUGIN_ITEMS_CLEAR(p); */ - /* add apps for a given mimetype */ if (plugin->type == type_action) _add_desktop_list(p, p->apps_mime, input); @@ -635,7 +631,7 @@ _fetch(Evry_Plugin *plugin, const char *input) if (!p->apps_all) { Eina_List *apps = NULL; - Eina_List *cat_ss, *cat_app, *cat_sys, *cat_set; + Eina_List *cat_ss; Eina_List *l, *ll; apps = efreet_util_desktop_name_glob_list("*"); diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index ba2a926..8e1970e 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -103,7 +103,6 @@ _scan_func(void *data) { Data *d = data; Plugin *p = d->plugin; - Eina_List *files; char *filename; const char *mime; diff --git a/src/modules/everything-windows/e_mod_main.c b/src/modules/everything-windows/e_mod_main.c index c796344..3764099 100644 --- a/src/modules/everything-windows/e_mod_main.c +++ b/src/modules/everything-windows/e_mod_main.c @@ -246,7 +246,6 @@ struct _Inst static Evry_Plugin *p2 = NULL; static Inst *inst = NULL; -static Evry_Action *act = NULL; static void _act_cb_border_switch_to(E_Border *bd) diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index d1594a5..22f3989 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -277,8 +277,8 @@ struct _Evry_View Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow); void (*destroy) (Evry_View *view); int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev); - int (*update) (Evry_View *view); - void (*clear) (Evry_View *view); + int (*update) (Evry_View *view, int slide); + void (*clear) (Evry_View *view, int slide); int priority; }; diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 8e576bc..15d56fc 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -48,14 +48,6 @@ EAPI E_Module_Api e_modapi = EAPI void * e_modapi_init(E_Module *m) { - Eina_List *files; - char buf[4096], dir[4096]; - char *file; - - /* snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything", - * e_user_homedir_get(), e_config_profile_get()); - * ecore_file_mkdir(buf); */ - _e_module_evry_log_dom = eina_log_domain_register ("e_module_everything", EINA_LOG_DEFAULT_COLOR); diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index d123653..6ba8b8c 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -220,16 +220,6 @@ evry_show(E_Zone *zone, const char *params) return 1; - error3: - if (selectors && selectors[0]) - _evry_selector_free(selectors[0]); - if (selectors && selectors[1]) - _evry_selector_free(selectors[1]); - if (selectors && selectors[2]) - _evry_selector_free(selectors[2]); - - evry_history_unload(); - error2: if (win) _evry_window_free(win); @@ -357,7 +347,7 @@ evry_item_free(Evry_Item *it) } static Evry_Selector * -_selector_for_plugin_get(Evry_Plugin *p) +_evry_selector_for_plugin_get(Evry_Plugin *p) { Evry_State *s; int i; @@ -435,7 +425,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action) DBG("plugin: %s", p->name); - sel = _selector_for_plugin_get(p); + sel = _evry_selector_for_plugin_get(p); if (!sel || !sel->state) return; s = sel->state; @@ -449,7 +439,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action) if (!eina_list_data_find(s->cur_plugins, p)) return; s->cur_plugins = eina_list_remove(s->cur_plugins, p); - + if (s->plugin == p) _evry_plugin_select(s, NULL); } @@ -492,7 +482,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action) { _evry_selector_update(sel); } - + _evry_view_update(s, NULL); } else if (action == EVRY_ASYNC_UPDATE_REFRESH) @@ -658,7 +648,8 @@ _evry_window_new(E_Zone *zone) if (evry_conf->width > mw) mw = evry_conf->width; - + evry_conf->width = mw; + mw += offset_s*2; mh += offset_s*2; x = (zone->w * evry_conf->rel_x) - (mw / 2); @@ -779,7 +770,7 @@ _evry_selector_activate(Evry_Selector *sel) if (s && s->view) { - s->view->clear(s->view); + s->view->clear(s->view, 0); _evry_view_hide(s->view); } @@ -920,7 +911,7 @@ _evry_timer_cb_actions_get(void *data) { s = sel->state; if (s->view) - s->view->update(s->view); + s->view->update(s->view, 0); else _evry_view_update(s, NULL); } @@ -948,7 +939,6 @@ _evry_selector_update(Evry_Selector *sel) if (s->plugin && (!it || s->item_auto_selected)) { - Eina_List *l; it = NULL; /* get first item */ @@ -1224,7 +1214,7 @@ evry_browse_item(Evry_Selector *sel) if (s->view) { _evry_view_show(s->view); - s->view->update(s->view); + s->view->update(s->view, -1); } } @@ -1248,6 +1238,7 @@ evry_browse_back(Evry_Selector *sel) _evry_selector_update(sel); _evry_update_text_label(s); _evry_view_show(s->view); + s->view->update(s->view, 1); } static void @@ -1455,7 +1446,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) if (s->plugin == selector->aggregator) selector->aggregator->fetch(selector->aggregator, s->input); if (s->view) - s->view->update(s->view); + s->view->update(s->view, 0); } else if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) { @@ -1763,7 +1754,7 @@ _evry_view_update(Evry_State *s, Evry_Plugin *p) } if (s->view) - s->view->update(s->view); + s->view->update(s->view, 0); } static void @@ -1771,7 +1762,7 @@ _evry_view_clear(Evry_State *s) { if (!s || !s->view) return; - s->view->clear(s->view); + s->view->clear(s->view, 0); } static int @@ -1843,7 +1834,7 @@ _evry_view_toggle(Evry_State *s, const char *trigger) s->view = v; _evry_view_show(s->view); - view->update(s->view); + view->update(s->view, 0); return 1; } @@ -1988,7 +1979,7 @@ evry_plugin_select(const Evry_State *s, Evry_Plugin *p) { _evry_plugin_select((Evry_State *) s, p); - _evry_selector_update(selector); + _evry_selector_update(_evry_selector_for_plugin_get(p)); } static void diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index a2a3ddd..d151abd 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -62,9 +62,6 @@ evry_config_dialog(E_Container *con, const char *params __UNUSED__) static void _fill_data(E_Config_Dialog_Data *cfdata) { - Eina_List *l; - Evry_Plugin *p; - #define C(_name) cfdata->_name = evry_conf->_name C(height); C(width); @@ -114,13 +111,13 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) E_FREE(cfdata); } -static int -_evry_cb_plugin_sort(const void *data1, const void *data2) -{ - const Evry_Plugin *p1 = data1; - const Evry_Plugin *p2 = data2; - return p1->config->priority - p2->config->priority; -} +/* static int + * _evry_cb_plugin_sort(const void *data1, const void *data2) + * { + * const Evry_Plugin *p1 = data1; + * const Evry_Plugin *p2 = data2; + * return p1->config->priority - p2->config->priority; + * } */ static int _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) diff --git a/src/modules/everything/evry_plug_actions.c b/src/modules/everything/evry_plug_actions.c index 9c9dd81..b72db8c 100644 --- a/src/modules/everything/evry_plug_actions.c +++ b/src/modules/everything/evry_plug_actions.c @@ -45,8 +45,8 @@ _begin(Evry_Plugin *p, const Evry_Item *it) EINA_LIST_FOREACH(evry_conf->actions, l, act) { - if (!act->type_in1 || (act->type_in1 == type) && - (!act->check_item || act->check_item(act, it))) + if ((!act->type_in1) || + ((act->type_in1 == type) && (!act->check_item || act->check_item(act, it)))) { act->item1 = it; diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 0be28a8..189da16 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -4,8 +4,6 @@ typedef struct _Plugin Plugin; -static int _auto_selected; - struct _Plugin { Evry_Plugin base; @@ -51,14 +49,6 @@ _cb_sort(const void *data1, const void *data2) { const Evry_Item *it1 = data1; const Evry_Item *it2 = data2; - - if (!_auto_selected) - { - if (it1->selected) - return -1; - if (it2->selected) - return 1; - } if (it1->usage && it2->usage) return (it1->usage > it2->usage ? -1 : 1); @@ -104,8 +94,6 @@ _cb_sort(const void *data1, const void *data2) return strcasecmp(it1->label, it2->label); } -static int refs = 0; - static inline Eina_List * _add_item(Plugin *p, Eina_List *items, Evry_Item *it) { @@ -238,9 +226,6 @@ _fetch(Evry_Plugin *plugin, const char *input) if (items) eina_list_free(items); - /* XXX workaround */ - _auto_selected = p->selector->state->item_auto_selected; - if (input) { EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); diff --git a/src/modules/everything/evry_plug_view_help.c b/src/modules/everything/evry_plug_view_help.c index aa5f76c..59aaee6 100644 --- a/src/modules/everything/evry_plug_view_help.c +++ b/src/modules/everything/evry_plug_view_help.c @@ -4,7 +4,7 @@ static Evry_View *view; static Evas_Object *o_text = NULL; static void -_view_clear(Evry_View *v) +_view_clear(Evry_View *v, int slide) { v->active = 0; evas_object_del(v->o_list); @@ -14,7 +14,7 @@ _view_clear(Evry_View *v) static int -_view_update(Evry_View *v) +_view_update(Evry_View *v, int slide) { return 1; } diff --git a/src/modules/everything/evry_plug_view_thumb.c b/src/modules/everything/evry_plug_view_thumb.c index 4cde8a2..43df1c6 100644 --- a/src/modules/everything/evry_plug_view_thumb.c +++ b/src/modules/everything/evry_plug_view_thumb.c @@ -44,13 +44,17 @@ struct _Smart_Data Evas_Object *selector; + double last_select; double sel_pos_to; double sel_pos; double scroll_align; double scroll_align_to; Ecore_Animator *animator; - double last_select; + int slide_offset; + double slide; + double slide_to; + int sliding; }; struct _Item @@ -615,7 +619,10 @@ _animator(void *data) { Smart_Data *sd = evas_object_smart_data_get(data); double da; - double spd = (25.0 / (double)e_config->framerate) / (double) (1 + sd->view->zoom); + double spd = (25.0/(double)e_config->framerate) / (double) (1 + sd->view->zoom); + if (sd->sliding) spd *= 2.0; + if (spd > 0.9) spd = 0.9; + int wait = 0; if (sd->sel_pos != sd->sel_pos_to) @@ -646,6 +653,24 @@ _animator(void *data) e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align); } + if (sd->sliding) + { + sd->slide = (sd->slide * (1.0 - spd)) + (sd->slide_to * spd); + + da = sd->slide - sd->slide_to; + if (da < 0.0) da = -da; + if (da < 0.02) + { + sd->slide = sd->slide_to; + sd->sliding = 0; + } + + else + wait++; + + evas_object_move(sd->view->span, sd->slide, sd->y); + } + if (wait) return 1; sd->animator = NULL; @@ -758,11 +783,19 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) if (!scroll || !evry_conf->scroll_animate) { + sd->scroll_align = sd->scroll_align_to; + sd->sel_pos = sd->sel_pos_to; + if (align_to >= 0) - sd->sel_pos = align_to * it->h; + { + sd->sel_pos = align_to * it->h; + sd->sel_pos_to = sd->sel_pos; + } + if (align >= 0) { sd->scroll_align = align; + sd->scroll_align_to = align; e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align); } if (sd->animator) @@ -820,7 +853,7 @@ _clear_items(Evas_Object *obj) } static void -_view_clear(Evry_View *view) +_view_clear(Evry_View *view, int slide) { View *v = (View*) view; Smart_Data *sd = evas_object_smart_data_get(v->span); @@ -879,7 +912,7 @@ _update_frame(Evas_Object *obj) } static int -_view_update(Evry_View *view) +_view_update(Evry_View *view, int slide) { VIEW(v, view); Smart_Data *sd = evas_object_smart_data_get(v->span); @@ -894,7 +927,7 @@ _view_update(Evry_View *view) if (!p) { - _view_clear(view); + _view_clear(view, 0); return 1; } @@ -1000,6 +1033,7 @@ _view_update(Evry_View *view) v->plugin = p; sd->update = EINA_TRUE; + _update_frame(v->span); } @@ -1007,6 +1041,23 @@ _view_update(Evry_View *view) v->tabs->update(v->tabs); + if (evry_conf->scroll_animate) + { + if (slide) + { + if (!sd->animator) + sd->animator = ecore_animator_add(_animator, v->span); + sd->sliding = 1; + sd->slide_to = sd->x; + sd->slide = sd->x + sd->w * -slide; + } + else if (sd->sliding) + { + if (!sd->animator) + sd->animator = ecore_animator_add(_animator, v->span); + } + } + return 0; } @@ -1061,7 +1112,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (v->tabs->key_down(v->tabs, ev)) { - _view_update(view); + _view_update(view, 0); return 1; } @@ -1260,13 +1311,14 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) _pan_set, _pan_get, _pan_max_get, _pan_child_size_get); edje_object_part_swallow(v->bg, "e.swallow.list", v->sframe); + evas_object_show(v->sframe); evas_object_show(v->span); + + v->tabs = evry_tab_view_new(s, v->evas); EVRY_VIEW(v)->o_list = v->bg; - - v->tabs = evry_tab_view_new(s, v->evas); - v->view.o_bar = v->tabs->o_tabs; + EVRY_VIEW(v)->o_bar = v->tabs->o_tabs; h = ecore_event_handler_add(EVRY_EVENT_ITEM_CHANGED, _cb_item_changed, v); v->handlers = eina_list_append(v->handlers, h); diff --git a/src/modules/everything/evry_view_plugin_tabs.c b/src/modules/everything/evry_view_plugin_tabs.c index e2e368b..3f4fe60 100644 --- a/src/modules/everything/evry_view_plugin_tabs.c +++ b/src/modules/everything/evry_view_plugin_tabs.c @@ -17,7 +17,8 @@ _animator(void *data) Tab_View *v = data; double da; - double spd = (25.0 / (double)e_config->framerate); + double spd = (35.0 / (double)e_config->framerate); + if (spd > 0.9) spd = 0.9; int wait = 0; if (v->align != v->align_to) @@ -26,7 +27,7 @@ _animator(void *data) da = v->align - v->align_to; if (da < 0.0) da = -da; - if (da < 0.02) + if (da < 0.01) v->align = v->align_to; else wait++; @@ -80,6 +81,22 @@ _tab_scroll_to(Tab_View *v, Evry_Plugin *p, int animate) e_box_align_set(v->o_tabs, 0.0, 0.5); } +static Ecore_Timer *timer = NULL; + +static void +_tabs_update(Tab_View *v); + + +static int +_timer_cb(void *data) +{ + _tabs_update(data); + + timer = NULL; + return 0; + +} + static void _tabs_update(Tab_View *v) { @@ -88,12 +105,20 @@ _tabs_update(Tab_View *v) Evry_Plugin *p; const Evry_State *s = v->state; Tab *tab; - Evas_Coord w; + Evas_Coord w, x; Evas_Object *o; - /* evas_object_geometry_get(v->o_tabs, NULL, NULL, &w, NULL); */ - w = evry_conf->width - 22; + edje_object_calc_force(v->o_tabs); + evas_object_geometry_get(v->o_tabs, &x, NULL, &w, NULL); + + if (!w && !timer) + timer = ecore_timer_add(0.1, _timer_cb, v); + + /* if (w < evry_conf->width - 18) + * w = evry_conf->width - 18; */ + printf("tabs update %d %d\n", x, w); + /* remove tabs for not active plugins */ e_box_freeze(v->o_tabs); @@ -271,14 +296,14 @@ _tabs_key_down(Tab_View *v, const Ecore_Event_Key *ev) else if (!strcmp(key, "Prior")) { _plugin_prev(v); - return 1; + return -1; } else if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) { if (!strcmp(key, "Left")) { _plugin_prev(v); - return 1; + return -1; } else if (!strcmp(key, "Right")) { @@ -292,7 +317,7 @@ _tabs_key_down(Tab_View *v, const Ecore_Event_Key *ev) if (!strcmp(key, "Left")) { _plugin_prev(v); - return 1; + return -1; } else if (!strcmp(key, "Right")) { -- 2.7.4