Enlightenment CVS committal Author : codewarrior Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fileman.c e_fileman.h e_fileman_smart.c e_fileman_smart.h e_icon_layout.c e_icon_layout.h Log Message: - make events use ecore_event system - fix layout so that it draws based on a fixed width or fixed height - add e_fm_init and e_fm_shutdown (should be moved to E's init and shutdown) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_fileman.c 14 Oct 2005 12:11:38 -0000 1.5 +++ e_fileman.c 19 Oct 2005 11:37:30 -0000 1.6 @@ -14,7 +14,7 @@ ****/ static void _e_fileman_vscrollbar_drag_cb(Evas_Object *object, double value, void *data); -static void _e_fileman_reconf_cb(void *data, Evas_Object *obj, E_Fm_Event_Reconfigure *ev); +static void _e_fileman_reconf_cb(void *data, int type, void *event); static void _e_fileman_cb_resize(E_Win *win); static void _e_fileman_cb_delete(E_Win *win); static void _e_fileman_free(E_Fileman *fileman); @@ -72,6 +72,8 @@ e_win_resize_callback_set(fileman->win, _e_fileman_cb_resize); e_win_resize(fileman->win, 640, 480); + e_fm_init(); // this needs to move to e's global init + fileman->smart = e_fm_add(fileman->evas); e_fm_e_win_set(fileman->smart, fileman->win); //e_fm_dir_set(fileman->smart, dir); @@ -79,8 +81,10 @@ ecore_x_dnd_aware_set(fileman->win->evas_win, 1); - e_fm_reconfigure_callback_add(fileman->smart, _e_fileman_reconf_cb, fileman); - + fileman->event_handlers = evas_list_append(fileman->event_handlers, + ecore_event_handler_add(E_EVENT_FM_RECONFIGURE, + _e_fileman_reconf_cb, + fileman)); return fileman; } @@ -151,11 +155,15 @@ } static void -_e_fileman_reconf_cb(void *data, Evas_Object *obj, E_Fm_Event_Reconfigure *ev) +_e_fileman_reconf_cb(void *data, int type, void *event) { + E_Event_Fm_Reconfigure *ev; E_Fileman *fileman; fileman = data; + ev = event; + + evas_event_freeze(fileman->evas); if (ev->h > fileman->win->h) edje_object_part_swallow(fileman->main, "vscrollbar", fileman->vscrollbar); @@ -164,4 +172,6 @@ edje_object_part_unswallow(fileman->main, fileman->vscrollbar); evas_object_hide(fileman->vscrollbar); } + + evas_event_thaw(fileman->evas); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_fileman.h 13 Oct 2005 00:52:02 -0000 1.3 +++ e_fileman.h 19 Oct 2005 11:37:30 -0000 1.4 @@ -15,17 +15,21 @@ { E_Object e_obj_inherit; - E_Container *con; - E_Win *win; + E_Container *con; + E_Win *win; - Evas *evas; - Evas_Object *main; - Evas_Object *vscrollbar; + Evas *evas; + Evas_Object *main; + Evas_Object *vscrollbar; - Evas_Object *smart; + Evas_Object *smart; - double xpos; - double ypos; + double xpos; + double ypos; + + int swallowed; + + Evas_List *event_handlers; }; EAPI E_Fileman *e_fileman_new(E_Container *con); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- e_fileman_smart.c 18 Oct 2005 23:03:36 -0000 1.36 +++ e_fileman_smart.c 19 Oct 2005 11:37:30 -0000 1.37 @@ -48,6 +48,8 @@ * wrap on wrap=char */ +int E_EVENT_FM_RECONFIGURE; + #ifdef EFM_DEBUG # define D(x) do {printf(__FILE__ ":%d: ", __LINE__); printf x; fflush(stdout);} while (0) #else @@ -133,13 +135,6 @@ pid_t pid; }; -struct _E_Fm_Event_Reconfigure_Internal -{ - void *data; - Evas_Object *obj; - void (*func)(void *data, Evas_Object *obj, E_Fm_Event_Reconfigure *ev); -}; - enum _E_Fm_File_Type { E_FILEMAN_FILETYPE_ALL = 0, @@ -175,16 +170,14 @@ Evas_Object *bg; Evas_Object *clip; Evas_Object *layout; + Evas_Object *object; E_Menu *menu; E_Win *win; Evas *evas; Evas_List *event_handlers; - Evas_List *reconf_event_handlers; Evas_List *pending_thumbs; - - unsigned char reconf_event_raised : 1; char *dir; Evas_List *files; @@ -196,6 +189,8 @@ int visible_files; double position; + Evas_Coord x, y, w, h; + struct { unsigned char start : 1; int x, y; @@ -259,7 +254,6 @@ static void _e_fm_redraw(E_Fm_Smart_Data *sd); static void _e_fm_size_calc(E_Fm_Smart_Data *sd); static void _e_fm_stat_to_attr(struct stat st, E_Fm_File_Attributes *attr, char *name); -static void _e_fm_event_reconfigure_raise(E_Fm_Smart_Data *sd); static void _e_fm_selections_clear(E_Fm_Smart_Data *sd); static void _e_fm_selections_add(E_Fm_File *file); static void _e_fm_selections_del(E_Fm_File *file); @@ -322,28 +316,44 @@ /* externally accessible functions */ + +int +e_fm_init(void) +{ + if (!e_fm_smart) + { + e_fm_smart = evas_smart_new("e_fm", + _e_fm_smart_add, /* add */ + _e_fm_smart_del, /* del */ + NULL, /* layer_set */ + _e_fm_smart_raise, /* raise */ + _e_fm_smart_lower, /* lower */ + _e_fm_smart_stack_above, /* stack_above */ + _e_fm_smart_stack_below, /* stack_below */ + _e_fm_smart_move, /* move */ + _e_fm_smart_resize, /* resize */ + _e_fm_smart_show, /* show */ + _e_fm_smart_hide, /* hide */ + NULL, /* color_set */ + NULL, /* clip_set */ + NULL, /* clip_unset */ + NULL); /* data*/ + } + E_EVENT_FM_RECONFIGURE = ecore_event_type_new(); + return 1; +} + +int +e_fm_shutdown(void) +{ + evas_smart_free(e_fm_smart); + return 1; +} + + Evas_Object * e_fm_add(Evas *evas) { - if (!e_fm_smart) - { - e_fm_smart = evas_smart_new("e_fm", - _e_fm_smart_add, /* add */ - _e_fm_smart_del, /* del */ - NULL, /* layer_set */ - _e_fm_smart_raise, /* raise */ - _e_fm_smart_lower, /* lower */ - _e_fm_smart_stack_above, /* stack_above */ - _e_fm_smart_stack_below, /* stack_below */ - _e_fm_smart_move, /* move */ - _e_fm_smart_resize, /* resize */ - _e_fm_smart_show, /* show */ - _e_fm_smart_hide, /* hide */ - NULL, /* color_set */ - NULL, /* clip_set */ - NULL, /* clip_unset */ - NULL); /* data*/ - } return evas_object_smart_add(evas, e_fm_smart); } @@ -430,7 +440,7 @@ if ((!object) || !(sd = evas_object_smart_data_get(object))) return; - offsetpx = (sd->position - percent) * sd->max.h; + offsetpx = (sd->position - percent) * (sd->max.h - sd->h); sd->position = percent; if (offsetpx > 0) // moving up @@ -467,23 +477,6 @@ *h = sd->max.h; } -void -e_fm_reconfigure_callback_add(Evas_Object *object, void (*func)(void *data, Evas_Object *obj, E_Fm_Event_Reconfigure *ev), void *data) -{ - E_Fm_Smart_Data *sd; - E_Fm_Event_Reconfigure_Internal *event; - - if ((!object) || !(sd = evas_object_smart_data_get(object))) - return; - - event = E_NEW(E_Fm_Event_Reconfigure_Internal, 1); - event->data = data; - event->func = func; - event->obj = object; - - sd->reconf_event_handlers = evas_list_append(sd->reconf_event_handlers, event); -} - /* local subsystem functions */ static void @@ -500,6 +493,8 @@ sd = E_NEW(E_Fm_Smart_Data, 1); if (!sd) return; + sd->object = object; + sd->bg = evas_object_rectangle_add(evas); // this should become an edje evas_object_color_set(sd->bg, 0, 0, 0, 0); evas_object_show(sd->bg); @@ -749,6 +744,8 @@ 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; // _e_fm_redraw(sd); // no new } @@ -756,24 +753,41 @@ _e_fm_smart_resize(Evas_Object *object, Evas_Coord w, Evas_Coord h) { E_Fm_Smart_Data *sd; - + E_Event_Fm_Reconfigure *ev; + if ((!object) || !(sd = evas_object_smart_data_get(object))) return; evas_object_resize(sd->bg, w, h); evas_object_resize(sd->clip, w, h); - _e_fm_size_calc(sd); - evas_object_resize(sd->layout, w, h); - e_icon_layout_virtual_size_set(sd->layout, w, sd->max.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); sd->conf.main->width = w; sd->conf.main->height = h; + + sd->w = w; + sd->h = h; // optimize // _e_fm_redraw(sd); // no new - if(!sd->reconf_event_raised) - _e_fm_event_reconfigure_raise(sd); + if(sd->position > 0) + e_fm_scroll_vertical(object, sd->position); + + ev = E_NEW(E_Event_Fm_Reconfigure, 1); + if (ev) + { + Evas_Coord w, 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; + ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL); + } } static void @@ -807,6 +821,7 @@ E_Fm_File *file; E_Fm_File_Attributes *attr; + E_Event_Fm_Reconfigure *ev; if (!sd->dir) return; @@ -886,19 +901,41 @@ } e_icon_layout_thaw(sd->layout); - - if(!sd->reconf_event_raised) - _e_fm_event_reconfigure_raise(sd); + + ev = E_NEW(E_Event_Fm_Reconfigure, 1); + if (ev) + { + Evas_Coord w, 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; + ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL); + } } static void _e_fm_redraw(E_Fm_Smart_Data *sd) { + E_Event_Fm_Reconfigure *ev; + e_icon_layout_redraw_force(sd->layout); - if(!sd->reconf_event_raised) - _e_fm_event_reconfigure_raise(sd); + ev = E_NEW(E_Event_Fm_Reconfigure, 1); + if (ev) + { + Evas_Coord w, 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; + ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL); + } } // when this is enabled, the thumbnailer is broken, double check if its @@ -930,21 +967,18 @@ while (dirs) { int icon_w, icon_h; - Evas_Object *icon; attr = evas_list_data(dirs); - - icon = edje_object_add(sd->evas); - e_theme_edje_object_set(icon, "base/theme/fileman", "fileman/icon"); - + file = E_NEW(E_Fm_File, 1); - file->icon = icon; + file->icon = edje_object_add(sd->evas);; + e_theme_edje_object_set(file->icon, "base/theme/fileman", "fileman/icon"); file->attr = attr; file->sd = sd; file->icon_img = _e_fm_file_icon_get(file); // this might be causing borkage - edje_object_part_swallow(icon, "icon_swallow", file->icon_img); - edje_object_part_text_set(icon, "icon_title", attr->name); - edje_object_size_min_calc(icon, &icon_w, &icon_h); + edje_object_part_swallow(file->icon, "icon_swallow", file->icon_img); + edje_object_part_text_set(file->icon, "icon_title", attr->name); + edje_object_size_min_calc(file->icon, &icon_w, &icon_h); if ((x > w) || ((x + icon_w) > w)) { @@ -954,8 +988,11 @@ x += icon_w + sd->icon_info.x_space; + edje_object_part_unswallow(file->icon, file->icon_img); + evas_object_del(file->icon_img); evas_object_del(file->icon); - evas_object_del(file->icon_img); + file->attr = NULL; + file->sd = NULL; free(file); dirs = dirs->next; @@ -966,34 +1003,6 @@ } static void -_e_fm_event_reconfigure_raise(E_Fm_Smart_Data *sd) -{ - Evas_List *l; - - if(sd->reconf_event_raised == 1) - return; - - sd->reconf_event_raised = 1; - - for (l = sd->reconf_event_handlers; l; l = l->next) - { - E_Fm_Event_Reconfigure_Internal *ri; - E_Fm_Event_Reconfigure *ev; - - ev = E_NEW(E_Fm_Event_Reconfigure, 1); - - ri = l->data; - - ev->w = sd->max.w; - ev->h = sd->max.h; - - ri->func(ri->data, ri->obj, ev); - } - - sd->reconf_event_raised = 0; -} - -static void _e_fm_selections_clear(E_Fm_Smart_Data *sd) { Evas_List *l; @@ -1087,6 +1096,7 @@ if (sd->dir) free (sd->dir); sd->dir = strdup(dir); + sd->position = 0; _e_fm_selections_clear(sd); _e_fm_redraw_new(sd); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_fileman_smart.h 14 Oct 2005 11:55:49 -0000 1.3 +++ e_fileman_smart.h 19 Oct 2005 11:37:30 -0000 1.4 @@ -3,14 +3,15 @@ */ #ifdef E_TYPEDEFS -typedef struct _E_Fm_Event_Reconfigure E_Fm_Event_Reconfigure; +typedef struct _E_Event_Fm_Reconfigure E_Event_Fm_Reconfigure; #else #ifndef E_FM_SMART_H #define E_FM_SMART_H -struct _E_Fm_Event_Reconfigure +struct _E_Event_Fm_Reconfigure { + Evas_Object *object; Evas_Coord w, h; }; @@ -24,7 +25,8 @@ 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_Fm_Event_Reconfigure *ev), void *data); +EAPI void e_fm_reconfigure_callback_add(Evas_Object *object, void (*func)(void *data, Evas_Object *obj, E_Event_Fm_Reconfigure *ev), void *data); +extern int E_EVENT_FM_RECONFIGURE; #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_icon_layout.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_icon_layout.c 15 Oct 2005 00:48:27 -0000 1.5 +++ e_icon_layout.c 19 Oct 2005 11:37:30 -0000 1.6 @@ -17,6 +17,7 @@ Evas_Object *obj; int frozen; int clip_frozen; + int fixed; unsigned char changed : 1; Evas_List *items; }; @@ -89,34 +90,50 @@ return sd->frozen; } +void +e_icon_layout_virtual_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) +{ + E_Smart_Data *sd; + + if ((!obj) || !(sd = evas_object_smart_data_get(obj))) + return; + + if (w) *w = sd->vw; + if (h) *h = sd->vh; +} void -e_icon_layout_virtual_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h) +e_icon_layout_width_fix(Evas_Object *obj, Evas_Coord w) { E_Smart_Data *sd; if ((!obj) || !(sd = evas_object_smart_data_get(obj))) return; - if (w < 1) w = 1; - if (h < 1) h = 1; - if ((sd->vw == w) && (sd->vh == h)) return; + if(w < 1) w = 1; + if (sd->vw == w) return; + sd->fixed = 0; sd->vw = w; - sd->vh = h; + sd->vh = 0; sd->changed = 1; - if (sd->frozen <= 0) _e_icon_layout_smart_reconfigure(sd); + if (sd->frozen <= 0) _e_icon_layout_smart_reconfigure(sd); } void -e_icon_layout_virtual_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) +e_icon_layout_height_fix(Evas_Object *obj, Evas_Coord h) { E_Smart_Data *sd; if ((!obj) || !(sd = evas_object_smart_data_get(obj))) return; - if (w) *w = sd->vw; - if (h) *h = sd->vh; + if(h < 1) h = 1; + if (sd->vh == h) return; + sd->fixed = 1; + sd->vw = 0; + sd->vh = h; + sd->changed = 1; + if (sd->frozen <= 0) _e_icon_layout_smart_reconfigure(sd); } void @@ -341,31 +358,62 @@ w = sd->vw; h = sd->vh; - for (l = sd->items; l; l = l->next) + if (sd->fixed == 0) { - E_Icon_Layout_Item *li; - Evas_Object *obj; - - obj = l->data; - li = evas_object_data_get(obj, "e_icon_layout_data"); - - if(x > w || x + li->w > w) + for (l = sd->items; l; l = l->next) { - x = sd->x + sd->xs; - y += li->h + sd->ys; - } + E_Icon_Layout_Item *li; + Evas_Object *obj; + + obj = l->data; + li = evas_object_data_get(obj, "e_icon_layout_data"); + + if(x > sd->x + w || x + li->w > sd->x + w) + { + x = sd->x + sd->xs; + y += li->h + sd->ys; + } + + li->x = x; + li->y = y; - li->x = x; - li->y = y; + _e_icon_layout_smart_move_resize_item(li); + + x += li->w + sd->xs; + + } - _e_icon_layout_smart_move_resize_item(li); - - x += li->w + sd->xs; + sd->vh = y - sd->y; + } + else + { + for (l = sd->items; l; l = l->next) + { + E_Icon_Layout_Item *li; + Evas_Object *obj; + + obj = l->data; + li = evas_object_data_get(obj, "e_icon_layout_data"); + + if(y > sd->y + h || y + li->h > sd->y + h) + { + y = sd->y + sd->ys; + x += li->w + sd->xs; + } + + li->x = x; + li->y = y; + + _e_icon_layout_smart_move_resize_item(li); + + y += li->h + sd->ys; + } + sd->vw = x - sd->x; } sd->xc = x; - sd->yc = y; + sd->yc = y; sd->changed = 0; } @@ -373,7 +421,7 @@ static void _e_icon_layout_smart_move_resize_item(E_Icon_Layout_Item *li) { - if(li->w == 0 || li->h == 0) + if(li->w == 0 || li->h == 0) evas_object_geometry_get(li->obj, NULL, NULL, &li->w, &li->h); evas_object_move(li->obj, li->x, li->y); @@ -420,6 +468,7 @@ sd->ys = 0; sd->xc = 0; sd->yc = 0; + sd->fixed = 0; sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj)); evas_object_smart_member_add(sd->clip, obj); evas_object_move(sd->clip, 0, 0); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_icon_layout.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_icon_layout.h 14 Oct 2005 11:51:30 -0000 1.2 +++ e_icon_layout.h 19 Oct 2005 11:37:30 -0000 1.3 @@ -11,6 +11,8 @@ EAPI int e_icon_layout_thaw (Evas_Object *obj); EAPI void e_icon_layout_virtual_size_set (Evas_Object *obj, Evas_Coord w, Evas_Coord h); EAPI void e_icon_layout_virtual_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); +EAPI void e_icon_layout_width_fix (Evas_Object *obj, Evas_Coord w); +EAPI void e_icon_layout_height_fix (Evas_Object *obj, Evas_Coord h); EAPI void e_icon_layout_pack (Evas_Object *obj, Evas_Object *child); EAPI void e_icon_layout_child_resize (Evas_Object *obj, Evas_Coord w, Evas_Coord h); EAPI void e_icon_layout_child_stack_above (Evas_Object *obj, Evas_Object *above); ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs