'everything' readd smooth scroll option
authorHannes Janetzek <hannes.janetzek@gmail.com>
Sun, 11 Apr 2010 02:34:18 +0000 (02:34 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Sun, 11 Apr 2010 02:34:18 +0000 (02:34 +0000)
SVN revision: 47911

src/modules/everything/Evry.h
src/modules/everything/e_mod_main.c
src/modules/everything/evry_config.c
src/modules/everything/evry_plug_view_thumb.c

index 862d818..d5ed569 100644 (file)
@@ -225,49 +225,6 @@ struct _Evry_State
   Evry_View *view;
 };
 
-struct _Config
-{
-  int version;
-  /* position */
-  double rel_x, rel_y;
-  /* size */
-  int width, height;
-
-  Eina_List *modules;
-  
-  /* generic plugin config */
-  Eina_List *conf_subjects;
-  Eina_List *conf_actions;
-  Eina_List *conf_objects;
-  Eina_List *conf_views;
-
-  int scroll_animate;
-  double scroll_speed;
-
-  int hide_input;
-  int hide_list;
-
-  int quick_nav;
-
-  const char *cmd_terminal;
-  const char *cmd_sudo;
-
-  int view_mode;
-  int view_zoom;
-
-  int history_sort_mode;
-  
-  /* use up/down keys for prev/next in thumb view */
-  int cycle_mode;
-
-  /* not saved data */
-  Eina_List *plugins;
-  Eina_List *actions;
-  Eina_List *views;
-
-  int min_w, min_h;
-};
-
 struct _Evry_View
 {
   Evry_View  *id;
@@ -315,6 +272,49 @@ struct _Evry_Action
   int priority;
 };
 
+struct _Config
+{
+  int version;
+  /* position */
+  double rel_x, rel_y;
+  /* size */
+  int width, height;
+
+  Eina_List *modules;
+  
+  /* generic plugin config */
+  Eina_List *conf_subjects;
+  Eina_List *conf_actions;
+  Eina_List *conf_objects;
+  Eina_List *conf_views;
+
+  int scroll_animate;
+  double scroll_speed;
+
+  int hide_input;
+  int hide_list;
+
+  int quick_nav;
+
+  const char *cmd_terminal;
+  const char *cmd_sudo;
+
+  int view_mode;
+  int view_zoom;
+
+  int history_sort_mode;
+  
+  /* use up/down keys for prev/next in thumb view */
+  int cycle_mode;
+
+  /* not saved data */
+  Eina_List *plugins;
+  Eina_List *actions;
+  Eina_List *views;
+
+  int min_w, min_h;
+};
+
 struct _History_Entry
 {
   Eina_List *items;
index 32b9879..e9d0de3 100644 (file)
@@ -12,7 +12,7 @@
 /* #undef DBG
  * #define DBG(...) ERR(__VA_ARGS__) */
 
-#define CONFIG_VERSION 7
+#define CONFIG_VERSION 8
 
 /* actual module specifics */
 static void _e_mod_action_cb(E_Object *obj, const char *params);
@@ -216,7 +216,13 @@ _config_init()
 #undef T
 #undef D
    evry_conf = e_config_domain_load("module.everything", conf_edd);
-   
+
+   if (evry_conf && evry_conf->version == 7)
+     {
+       evry_conf->scroll_speed = 10.0;
+       evry_conf->version = CONFIG_VERSION;
+     }
+
    if (evry_conf && evry_conf->version != CONFIG_VERSION)
      {
        _config_free();
@@ -232,7 +238,7 @@ _config_init()
        evry_conf->width = 0;
        evry_conf->height = 0;
        evry_conf->scroll_animate = 0;
-       evry_conf->scroll_speed = 0.08;
+       evry_conf->scroll_speed = 10.0;
        evry_conf->hide_input = 0;
        evry_conf->hide_list = 0;
        evry_conf->quick_nav = 1;
index 0f37441..162a546 100644 (file)
@@ -16,7 +16,8 @@ struct _E_Config_Dialog_Data
   int width, height;
   double rel_x, rel_y;
   int scroll_animate;
-
+  double scroll_speed;
+  
   char *cmd_terminal;
   char *cmd_sudo;
 
@@ -76,6 +77,8 @@ _fill_data(E_Config_Dialog_Data *cfdata)
    C(view_zoom);
    C(cycle_mode);
    C(history_sort_mode);
+   C(scroll_animate);
+   C(scroll_speed);
 #undef C
    
    EINA_LIST_FOREACH(evry_conf->plugins, l, p)
@@ -138,6 +141,8 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
   C(view_zoom);
   C(cycle_mode);
   C(history_sort_mode);
+  C(scroll_animate);
+  C(scroll_speed);
 #undef C
 
    evry_conf->plugins = eina_list_sort(evry_conf->plugins, -1,
@@ -261,6 +266,13 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
    ob = e_widget_radio_add(evas, "Icons", 1, rg);
    e_widget_radio_toggle_set(ob, (cfdata->view_mode == 1));
    e_widget_framelist_object_append(of, ob);
+
+   ob = e_widget_check_add(evas, _("Animate scrolling"),
+                          &(cfdata->scroll_animate));
+   e_widget_framelist_object_append(of, ob);
+   ob = e_widget_slider_add(evas, 1, 0, _("%1.1f"),
+                           5, 20, 0.1, 0, &(cfdata->scroll_speed), NULL, 10);
+   e_widget_framelist_object_append(of, ob);
    
    ob = e_widget_check_add(evas, _("Up/Down select next item in icon view"),
                           &(cfdata->cycle_mode));
index 678995a..08e9576 100644 (file)
@@ -30,7 +30,6 @@ struct _Smart_Data
   Ecore_Idle_Enterer *idle_enter;
   Ecore_Idle_Enterer *thumb_idler;
   Ecore_Idle_Enterer *update_idler;
-  Ecore_Animator *animator;
   Evas_Coord   x, y, w, h;
   Evas_Coord   cx, cy, cw, ch;
   Evas_Coord   sx, sy;
@@ -38,6 +37,11 @@ struct _Smart_Data
   Eina_Bool    update : 1;
   Eina_Bool    switch_mode : 1;
   Eina_List *queue;
+
+  double scroll_align;
+  double scroll_align_to;
+  int scroll_to;
+  Ecore_Animator *animator;
 };
 
 struct _Item
@@ -313,6 +317,9 @@ _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))
@@ -323,9 +330,10 @@ _e_smart_reconfigure_do(void *data)
             evas_object_move(it->frame, xx, yy);
             evas_object_resize(it->frame, it->w, it->h);
 
+
             /* if (sd->update || it->changed)
              *   {
-             *           if (it->selected && sd->view->zoom < 2)
+             *           if (it->selected
              *             edje_object_signal_emit(it->frame, "e,state,selected", "e");
              *           else
              *             edje_object_signal_emit(it->frame, "e,state,unselected", "e");
@@ -392,7 +400,9 @@ _e_smart_del(Evas_Object *obj)
      ecore_idle_enterer_del(sd->idle_enter);
    if (sd->thumb_idler)
      ecore_idle_enterer_del(sd->thumb_idler);
-
+   if (sd->animator)
+     ecore_animator_del(sd->animator); 
+   
    // sd->view is just referenced
    // sd->child_obj is unused
    EINA_LIST_FREE(sd->items, it)
@@ -564,11 +574,40 @@ _pan_item_remove(Evas_Object *obj, Item *it)
    _e_smart_reconfigure(obj);
 }
 
+static int
+_animator(void *data)
+{
+   Smart_Data *sd = data;
+   
+   if (sd->scroll_to)
+     {
+       double da;
+
+       double spd = 10.0 / e_config->framerate;
+       
+       sd->scroll_align = (sd->scroll_align * (1.0 - spd)) + (sd->scroll_align_to * spd);
+       
+       da = sd->scroll_align - sd->scroll_align_to;
+       if (da < 0.0) da = -da;
+       if (da < 0.01)
+         {
+            sd->scroll_align = sd->scroll_align_to;
+            sd->scroll_to = 0;
+         }
+       e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align);
+
+       /* e_box_align_set(eap_list_object, 0.5, eap_scroll_align); */
+     }
+   if (sd->scroll_to) return 1;
+   sd->animator = NULL;
+   return 0;
+}
+
 static void
 _pan_item_select(Evas_Object *obj, Item *it)
 {
    Smart_Data *sd = evas_object_smart_data_get(obj);
-   int align = -1;
+   double align = -1;
 
    if (sd->cur_item)
      {
@@ -590,9 +629,24 @@ _pan_item_select(Evas_Object *obj, Item *it)
        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)
-         e_scrollframe_child_pos_set(sd->view->sframe, 0, align);
-
+         {
+            if (!evry_conf->scroll_animate)
+              {
+                 if (align >= 0)
+                   e_scrollframe_child_pos_set(sd->view->sframe, 0, align);
+              }
+            else
+              {
+                 sd->scroll_align_to = align;
+                 sd->scroll_to = 1;
+                 if (!sd->animator)
+                   sd->animator = ecore_animator_add(_animator, sd);
+              }
+         }
+       
        if (sd->view->zoom < 2)
          edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e");
 
@@ -608,6 +662,10 @@ _clear_items(Evas_Object *obj)
    Eina_List *l;
    Item *it;
 
+   if (sd->animator)
+     ecore_animator_del(sd->animator);
+   sd->animator = NULL;
+   
    EINA_LIST_FOREACH(sd->items, l, it)
      {
        if (it->do_thumb)
@@ -666,11 +724,13 @@ static int
 _update_frame(Evas_Object *obj)
 {
    Smart_Data *sd = evas_object_smart_data_get(obj);
-   //sd->switch_mode = EINA_TRUE;
+   /* sd->switch_mode = EINA_TRUE; */
    _e_smart_reconfigure_do(obj);
-   //sd->switch_mode = EINA_FALSE;
+   /* sd->switch_mode = EINA_FALSE; */
+   int tmp = evry_conf->scroll_animate;
+   evry_conf->scroll_animate = 0;
    _pan_item_select(obj, sd->cur_item); 
-
+   evry_conf->scroll_animate = tmp;
    return 0;
 }
 
@@ -1034,7 +1094,7 @@ _view_destroy(Evry_View *view)
    VIEW(v, view);
 
    Ecore_Event_Handler *h;
-   
+
    evas_object_del(v->bg);
    evas_object_del(v->sframe);
    evas_object_del(v->span);