- fix scrolling
authorcodewarrior <codewarrior>
Sun, 30 Oct 2005 08:40:37 +0000 (08:40 +0000)
committercodewarrior <codewarrior@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Oct 2005 08:40:37 +0000 (08:40 +0000)
SVN revision: 18139

src/bin/Makefile.am
src/bin/e_file_selector.c
src/bin/e_fileman.c
src/bin/e_fileman_smart.c
src/bin/e_fileman_smart.h

index 6c298a6..5a3cedd 100644 (file)
@@ -108,7 +108,7 @@ e_widget_iconsel.h \
 e_widget_fileman.h \
 e_scrollframe.h \
 e_file_selector.h \
-e_file_dialog.h 
+e_file_dialog.h
 
 enlightenment_src = \
 e_user.c \
index 29ba1c4..6c71fd7 100644 (file)
@@ -102,15 +102,17 @@ _e_smart_add(Evas_Object *obj)
    sd->view = E_FILE_SELECTOR_ICONVIEW;
    
    evas = evas_object_evas_get(obj);   
-   sd->theme = edje_object_add(evas);
+//   sd->theme = edje_object_add(evas);
+   sd->theme = e_scrollframe_add(evas);   
    evas_object_smart_member_add(sd->theme, obj);   
-   THEME_SET(sd->theme, "main");
+//   THEME_SET(sd->theme, "main");
       
    sd->files = e_fm_add(evas);
    e_fm_selector_enable(sd->files, _e_file_selector_selected_cb, sd);
    evas_object_smart_member_add(sd->files, obj);
 
-   edje_object_part_swallow(sd->theme, "items", sd->files);
+   //edje_object_part_swallow(sd->theme, "items", sd->files);
+    e_scrollframe_child_set(sd->theme, sd->files);
    
    evas_object_smart_data_set(obj, sd);
    
index 56fef66..c24d592 100644 (file)
 # define D(x)  ((void) 0)
 #endif
 
-static void _e_fileman_vscrollbar_drag_cb(Evas_Object *object, double value, void *data);
-static int _e_fileman_reconf_cb(void *data, int type, void *event);
-static int _e_fileman_dir_change_cb(void *data, int type, void *event);
-static int _e_fileman_mouse_wheel_cb(void *data, int type, void *event);
 static void _e_fileman_resize_cb(E_Win *win);
 static void _e_fileman_delete_cb(E_Win *win);
 static void _e_fileman_selector_cb(Evas_Object *object, char *file, void *data);
-static void _e_fileman_vscrollbar_show_cb(void *data, Evas *e, Evas_Object *obj, void *ev);
-static void _e_fileman_vscrollbar_hide_cb(void *data, Evas *e, Evas_Object *obj, void *ev);
 static void _e_fileman_free(E_Fileman *fileman);
-
+static void _e_fileman_scroll_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
+static void _e_fileman_scroll_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+static void _e_fileman_scroll_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+static void _e_fileman_scroll_child_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
+  
+  
 E_Fileman *
 e_fileman_new(E_Container *con)
 {
@@ -71,41 +70,23 @@ e_fileman_new(E_Container *con)
    e_win_name_class_set(fileman->win, "Efm ", "_fileman");
    e_win_title_set(fileman->win, dir);
 
-   fileman->main = edje_object_add(fileman->evas);
-   e_theme_edje_object_set(fileman->main, "base/theme/fileman/main",
-                          "fileman/main");
-
-   fileman->vscrollbar = e_scrollbar_add(fileman->evas);
-   e_scrollbar_direction_set(fileman->vscrollbar, E_SCROLLBAR_VERTICAL);
-   e_scrollbar_callback_drag_add(fileman->vscrollbar, _e_fileman_vscrollbar_drag_cb, fileman);
-   evas_object_event_callback_add(fileman->vscrollbar, EVAS_CALLBACK_SHOW, _e_fileman_vscrollbar_show_cb, fileman);
-   evas_object_event_callback_add(fileman->vscrollbar, EVAS_CALLBACK_HIDE, _e_fileman_vscrollbar_hide_cb, fileman);
-
-   e_win_resize_callback_set(fileman->win, _e_fileman_resize_cb);
-   e_win_resize(fileman->win, 640, 480);
-
    evas_event_freeze(fileman->evas);   
-   
    fileman->smart = e_fm_add(fileman->evas);
    e_fm_e_win_set(fileman->smart, fileman->win);
-   edje_object_part_swallow(fileman->main, "icon_area", fileman->smart);
-
-   ecore_x_dnd_aware_set(fileman->win->evas_win, 1);
-
-   fileman->event_handlers = evas_list_append(fileman->event_handlers,
-                                             ecore_event_handler_add(E_EVENT_FM_RECONFIGURE,
-                                                                     _e_fileman_reconf_cb,
-                                                                     fileman));
    
-   fileman->event_handlers = evas_list_append(fileman->event_handlers,
-                                             ecore_event_handler_add(E_EVENT_FM_DIRECTORY_CHANGE,
-                                                                     _e_fileman_dir_change_cb,
-                                                                     fileman));
+   fileman->main = e_scrollframe_add(fileman->evas);
+   e_scrollframe_custom_theme_set(fileman->main, "base/themes/fileman",
+                                 "fileman/main");
+   e_scrollframe_extern_pan_set(fileman->main, fileman->smart, 
+                               _e_fileman_scroll_set,
+                               _e_fileman_scroll_get,
+                               _e_fileman_scroll_max_get,
+                               _e_fileman_scroll_child_size_get);
+
+   e_win_resize_callback_set(fileman->win, _e_fileman_resize_cb);
+   e_win_resize(fileman->win, 400, 400 );
    
-   fileman->event_handlers = evas_list_append(fileman->event_handlers,
-                                             ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL,
-                                                                     _e_fileman_mouse_wheel_cb,
-                                                                     fileman));   
+   ecore_x_dnd_aware_set(fileman->win->evas_win, 1);
    
    evas_event_thaw(fileman->evas);
    
@@ -114,6 +95,31 @@ e_fileman_new(E_Container *con)
    return fileman;
 }
 
+
+static void
+_e_fileman_scroll_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   e_fm_scroll_set(obj, x, y);
+}
+
+static void
+_e_fileman_scroll_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+{
+   e_fm_scroll_get(obj, x, y);
+}
+
+static void 
+_e_fileman_scroll_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+{
+   e_fm_scroll_max_get(obj, x, y);
+}
+
+static void 
+_e_fileman_scroll_child_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+{   
+   e_fm_geometry_virtual_get(obj, x, y);
+}
+
 void
 e_fileman_selector_enable(E_Fileman *fileman, void (*func)(E_Fileman *fileman, char *file, void *data), void *data)
 {   
@@ -151,7 +157,7 @@ _e_fileman_free(E_Fileman *fileman)
        ecore_event_handler_del(fileman->event_handlers->data);
        fileman->event_handlers = evas_list_remove_list(fileman->event_handlers, fileman->event_handlers);
     }
-   evas_object_del(fileman->vscrollbar);
+
    evas_object_del(fileman->smart);
    evas_object_del(fileman->main);
    e_object_del(E_OBJECT(fileman->win));
@@ -167,25 +173,6 @@ _e_fileman_resize_cb(E_Win *win)
    
    fileman = win->data;
    evas_object_resize(fileman->main, win->w, win->h);
-   e_fm_geometry_virtual_get(fileman->smart, &w, &h);
-   
-   D(("_e_fileman_resize_cb: e_fm_freeze\n"));
-   frozen = e_fm_freeze(fileman->smart);
-   if (frozen > 1)
-     e_fm_thaw(fileman->smart);
-       
-   if (h > win->h)
-     {
-       D(("e_fileman_resize_cb: show (%p)\n", fileman));       
-       edje_object_part_swallow(fileman->main, "vscrollbar", fileman->vscrollbar);     
-       e_fm_geometry_virtual_get(fileman->smart, &w, &h);
-     }
-   else 
-     {
-       D(("e_fileman_resize_cb: hide (%p)\n", fileman));
-       edje_object_part_unswallow(fileman->main, fileman->vscrollbar);
-       evas_object_hide(fileman->vscrollbar);
-     }   
 }
 
 static void
@@ -198,97 +185,6 @@ _e_fileman_delete_cb(E_Win *win)
    e_object_del(E_OBJECT(fileman));
 }
 
-static void
-_e_fileman_vscrollbar_drag_cb(Evas_Object *object, double value, void *data)
-{
-   E_Fileman *fileman;
-
-   fileman = data;
-   D(("e_fileman_vscrollbar_drag_cb: %f (%p)\n", value, fileman));
-   e_fm_scroll_vertical(fileman->smart, value);
-}
-
-static int
-_e_fileman_reconf_cb(void *data, int type, void *event)
-{   
-   E_Event_Fm_Reconfigure *ev;
-   E_Fileman *fileman;
-   Evas_Coord w, h;
-   int frozen;
-
-   if (!data) return 1;
-
-   fileman = data;
-   ev = event;
-
-   D(("_e_fileman_reconf_cb: e_fm_freeze\n"));
-   frozen = e_fm_freeze(fileman->smart);
-   if (frozen > 1)
-     e_fm_thaw(fileman->smart);
-
-   if (ev->h > fileman->win->h)
-     {
-       D(("e_fileman_reconf_cb: show (%p)\n", fileman));
-       edje_object_part_swallow(fileman->main, "vscrollbar", fileman->vscrollbar);
-     }
-   else
-     {
-       D(("e_fileman_reconf_cb: hide (%p)\n", fileman));       
-       edje_object_part_unswallow(fileman->main, fileman->vscrollbar);
-       evas_object_hide(fileman->vscrollbar);
-     }
-   return 1;
-}
-
-static int
-_e_fileman_dir_change_cb(void *data, int type, void *event)
-{
-   E_Event_Fm_Directory_Change *ev;
-   E_Fileman *fileman;
-   Evas_Coord w, h;
-   
-   if (!data) return 1;
-      
-   fileman = data;
-   ev = event;
-   
-   D(("_e_fileman_dir_change_cb:\n"));
-   e_scrollbar_value_set(fileman->vscrollbar,  0.0);
-         
-   return 1;
-}
-
-static int
-_e_fileman_mouse_wheel_cb(void *data, int type, void *event)
-{
-   Ecore_X_Event_Mouse_Wheel *ev;
-   E_Fileman *fileman;
-   double pos;
-   
-   ev = event;   
-   fileman = data;
-   
-   pos = e_scrollbar_value_get(fileman->vscrollbar);
-
-   if (ev->z < 0)
-     {
-       pos -= 0.05;
-       if (pos < 0.0)
-         pos = 0.0;       
-     }
-
-   if (ev->z > 0)
-     {
-       pos += 0.05;
-       if (pos > 1.0)
-         pos = 1.0;
-     }  
-   
-   e_scrollbar_value_set(fileman->vscrollbar,  pos);   
-   e_fm_scroll_vertical(fileman->smart, pos);
-   return 1;
-}
-
 static void 
 _e_fileman_selector_cb(Evas_Object *object, char *file, void *data)
 {
@@ -298,25 +194,3 @@ _e_fileman_selector_cb(Evas_Object *object, char *file, void *data)
    fileman->selector.func(fileman, file, fileman->selector.data);
    //e_object_del(E_OBJECT(fileman));
 }
-
-static void
-_e_fileman_vscrollbar_show_cb(void *data, Evas *e, Evas_Object *obj, void *ev)
-{
-   E_Fileman *fileman;
-   
-   fileman = data;
-   
-   D(("_e_fileman_vscrollbar_show_cb: thaw (%p)\n", fileman));
-   e_fm_thaw(fileman->smart);
-}
-
-static void
-_e_fileman_vscrollbar_hide_cb(void *data, Evas *e, Evas_Object *obj, void *ev)
-{
-   E_Fileman *fileman;
-   
-   fileman = data;
-   
-   D(("_e_fileman_vscrollbar_hide_cb: thaw (%p)\n", fileman));
-   e_fm_thaw(fileman->smart);
-}
index 17d5e8f..e2b9db2 100644 (file)
@@ -157,8 +157,8 @@ struct _E_Fm_Smart_Data
    } icon_info;
 
    struct {
-      Evas_Coord w, h;
-   } max;
+      Evas_Coord x, y, w, h;
+   } child;
 
    struct {
        Evas_List *files;
@@ -324,33 +324,62 @@ e_fm_e_win_get(Evas_Object *object)
 }
 
 void
-e_fm_scroll_horizontal(Evas_Object *object, double percent)
+e_fm_scroll_set(Evas_Object *object, Evas_Coord x, Evas_Coord y)
 {
-
+   E_Fm_Smart_Data *sd;
+   
+   sd = evas_object_smart_data_get(object);
+   if (!sd) return NULL;
+      
+   if (x > (sd->child.w - sd->w)) x = sd->child.w - sd->w;
+   if (y > (sd->child.h - sd->h)) y = sd->child.h - sd->h;
+   if (x < 0) x = 0;
+   if (y < 0) y = 0;
+   if ((x == sd->child.x) && (y == sd->child.y)) return;
+   sd->child.x = x;
+   sd->child.y = y;
+   
+   e_icon_layout_clip_freeze(sd->layout);
+   evas_object_move(sd->layout, sd->x - sd->child.x, sd->y - sd->child.y);
+   e_icon_layout_clip_thaw(sd->layout);
+   
+   evas_object_smart_callback_call(sd->object, "changed", NULL);
 }
 
 void
-e_fm_scroll_vertical(Evas_Object *object, double percent)
+e_fm_scroll_max_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y)
 {
    E_Fm_Smart_Data *sd;
-   int offsetpx;
-   Evas_Coord x, y, w, h;
-
-   if ((!object) || !(sd = evas_object_smart_data_get(object)))
-     return;
    
-   if(sd->max.h <= sd->h) return;
+   sd = evas_object_smart_data_get(object);
+   if (!sd) return NULL;
    
-   sd->position = percent;
-
-   offsetpx = (percent) * (sd->max.h - sd->h);
+   if (x)
+     {
+       if (sd->w < sd->child.w) *x = sd->child.w - sd->w;
+       else *x = 0;
+     }
+   if (y)
+     {
+       if (sd->h < sd->child.h) *y = sd->child.h - sd->h;
+       else *y = 0;
+     }
+   
+}
 
-   evas_object_geometry_get(sd->layout, &x, &y, &w, &h);
-   e_icon_layout_clip_freeze(sd->layout);
-   evas_object_move(sd->layout, x, sd->y - offsetpx);
-   e_icon_layout_clip_thaw(sd->layout);
+void
+e_fm_scroll_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y)
+{
+   E_Fm_Smart_Data *sd;
+   
+   sd = evas_object_smart_data_get(object);
+   if (!sd) return NULL;
+   
+   if (x) *x = sd->child.x;
+   if (y) *y = sd->child.y;   
 }
 
+
 void
 e_fm_geometry_virtual_get(Evas_Object *object, Evas_Coord *w, Evas_Coord *h)
 {
@@ -360,10 +389,10 @@ e_fm_geometry_virtual_get(Evas_Object *object, Evas_Coord *w, Evas_Coord *h)
      return;
 
    if(w)
-     *w = sd->max.w;
+     *w = sd->child.w;
 
    if(h)
-     *h = sd->max.h;
+     *h = sd->child.h;
 }
 
 void
@@ -626,12 +655,12 @@ _e_fm_smart_move(Evas_Object *object, Evas_Coord x, Evas_Coord y)
    sd = evas_object_smart_data_get(object);
    if (!sd) return;
 
-   evas_object_move(sd->bg, x, y);
-   evas_object_move(sd->clip, x, y);
-   evas_object_move(sd->layout, x, y);
-
    sd->x = x;
-   sd->y = y;
+   sd->y = y;   
+   
+   evas_object_move(sd->bg, x, y);
+   evas_object_move(sd->clip, x, y); 
+   evas_object_move(sd->layout, sd->x - sd->child.x, sd->y - sd->child.y);   
 }
 
 static void
@@ -647,18 +676,15 @@ _e_fm_smart_resize(Evas_Object *object, Evas_Coord w, Evas_Coord h)
    evas_object_resize(sd->clip, w, h);
    evas_object_resize(sd->layout, w, h);
    e_icon_layout_width_fix(sd->layout, w);
-   e_icon_layout_virtual_size_get(sd->layout, &sd->max.w, &sd->max.h);
+   e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h);
    sd->conf.main->width = w;
    sd->conf.main->height = h;
 
    sd->w = w;
    sd->h = h;
 
-   if(sd->position > 0.0 && sd->max.h > sd->h)
-     e_fm_scroll_vertical(object, sd->position);
-   else
-     sd->position = 0.0;
-
+   evas_object_smart_callback_call(sd->object, "changed", NULL);
+      
    if(sd->frozen)
      return;
 
@@ -669,8 +695,8 @@ _e_fm_smart_resize(Evas_Object *object, Evas_Coord w, Evas_Coord h)
 
        evas_object_geometry_get(sd->layout, NULL, NULL, &w, &h);
        ev->object = sd->object;
-       ev->w = sd->max.w;
-       ev->h = sd->max.h;
+       ev->w = sd->child.w;
+       ev->h = sd->child.h;
        ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
     }
 }
@@ -692,8 +718,8 @@ _e_fm_redraw(E_Fm_Smart_Data *sd)
        evas_object_geometry_get(sd->layout, NULL, NULL, &w, &h);
 
        ev->object = sd->object;
-       ev->w = sd->max.w;
-       ev->h = sd->max.h;
+       ev->w = sd->child.w;
+       ev->h = sd->child.h;
        ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
     }
 }
@@ -1053,7 +1079,7 @@ _e_fm_icon_prop_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, void *dat
    lastmod = E_NEW(char, 128);
    strftime(lastmod, 128, "%a %b %d %T %Y", t);
 
-   permissions = E_NEW(char, 128); // todo
+   permissions = E_NEW(char, 128);
    snprintf(permissions, 128, "%s", "");
 
    ol = e_widget_list_add(evas, 0, 0);
@@ -1248,13 +1274,13 @@ _e_fm_menu_arrange_cb(void *data, E_Menu *m, E_Menu_Item *mi)
      case E_FILEMAN_CANVAS_ARRANGE_NAME:
        sd->files = evas_list_sort(sd->files, evas_list_count(sd->files), _e_fm_files_sort_name_cb);
        sd->arrange = E_FILEMAN_CANVAS_ARRANGE_NAME;
-       _e_fm_redraw(sd); // no_new
+       _e_fm_redraw(sd); 
        break;
 
      case E_FILEMAN_CANVAS_ARRANGE_MODTIME:
        sd->files = evas_list_sort(sd->files, evas_list_count(sd->files), _e_fm_files_sort_modtime_cb);
        sd->arrange = E_FILEMAN_CANVAS_ARRANGE_MODTIME;
-       _e_fm_redraw(sd); // no new
+       _e_fm_redraw(sd); 
        break;
     }
 }
@@ -1350,8 +1376,8 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
    if (ev)
      {
        ev->object = sd->object;
-       ev->w = sd->max.w;
-       ev->h = sd->max.h;
+       ev->w = sd->child.w;
+       ev->h = sd->child.h;
        ecore_event_add(E_EVENT_FM_DIRECTORY_CHANGE, ev, NULL, NULL);
      }
 
@@ -1359,13 +1385,16 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
      return;
 
    /* raise reconfigure event */
+   e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h);   
+   evas_object_smart_callback_call(sd->object, "changed", NULL);
+   
    ev = E_NEW(E_Event_Fm_Reconfigure, 1);
    if (ev)
      {
-       e_icon_layout_virtual_size_get(sd->layout, &sd->max.w, &sd->max.h);
+       e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h);
        ev->object = sd->object;
-       ev->w = sd->max.w;
-       ev->h = sd->max.h;
+       ev->w = sd->child.w;
+       ev->h = sd->child.h;
        ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
      }
 }
@@ -1502,7 +1531,7 @@ _e_fm_dir_monitor_cb(void *data, Ecore_File_Monitor *ecore_file_monitor,
            }
        }       
        break;
-    }   
+    }
 }
 
 static void
index c8c089e..96e309d 100644 (file)
@@ -31,8 +31,14 @@ EAPI void                  e_fm_e_win_set(Evas_Object *object, E_Win *win);
 EAPI E_Win                *e_fm_e_win_get(Evas_Object *object);
 EAPI void                  e_fm_menu_set(Evas_Object *object, E_Menu *menu);
 EAPI E_Menu               *e_fm_menu_get(Evas_Object *object);
+
+EAPI void                  e_fm_scroll_set(Evas_Object *object, Evas_Coord x, Evas_Coord y);
+EAPI void                  e_fm_scroll_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y);
+EAPI void                  e_fm_scroll_max_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y);
+
 EAPI void                  e_fm_scroll_horizontal(Evas_Object *object, double percent);
 EAPI void                  e_fm_scroll_vertical(Evas_Object *object, double percent);
+
 EAPI void                  e_fm_geometry_virtual_get(Evas_Object *object, Evas_Coord *w, Evas_Coord *h);
 EAPI void                  e_fm_reconfigure_callback_add(Evas_Object *object, void (*func)(void *data, Evas_Object *obj, E_Event_Fm_Reconfigure *ev), void *data);
 EAPI int                   e_fm_freeze(Evas_Object *freeze);