From: Enlightenment S. <no-...@en...> - 2010-01-17 17:00:02
|
Log: * eyelight: Start to merge edje file with eyelight data. Author: cedric Date: 2010-01-17 08:59:55 -0800 (Sun, 17 Jan 2010) New Revision: 45263 Modified: trunk/PROTO/eyelight/src/bin/eyelight.c trunk/PROTO/eyelight/src/lib/Eyelight.h trunk/PROTO/eyelight/src/lib/Eyelight_Smart.h trunk/PROTO/eyelight/src/lib/edit/edit_slide.c trunk/PROTO/eyelight/src/lib/eyelight_smart.c trunk/PROTO/eyelight/src/lib/eyelight_viewer.c trunk/PROTO/eyelight/src/lib/eyelight_viewer.h trunk/PROTO/eyelight/src/lib/eyelight_viewer_expose.c trunk/PROTO/eyelight/src/lib/eyelight_viewer_slideshow.c trunk/PROTO/eyelight/src/lib/eyelight_viewer_thumbnails.c Modified: trunk/PROTO/eyelight/src/bin/eyelight.c =================================================================== --- trunk/PROTO/eyelight/src/bin/eyelight.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/bin/eyelight.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -341,8 +341,9 @@ "Launch eyelight, presentation viewer\n\n" "%prog use Edje to display a presentation. \n\n\n" "Examples: \n" - "eyelight -p presentation/eyelight.elt -t theme/default -e opengl-x11\n" - "eyelight -p presentation/eyelight.elt", + "eyelight -p presentation/eyelight.elt -t theme/default -e opengl-x11 -o presentation/eyelight.eye\n" + "eyelight -p presentation/eyelight.elt\n" + "eyelight -y presentation/eyelight.eye\n", 1, { ECORE_GETOPT_VERSION('V', "version"), @@ -357,6 +358,8 @@ ECORE_GETOPT_STORE_STR('b', "no-thumbs-bg", "deactivate the creation of the thumbnails list in the background, saves a lot of memory, some mode (expose, slideshow) will be slow"), ECORE_GETOPT_STORE_TRUE('H', "hd", "Display the presentation with a default size of 1280x720"), ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_STORE_STR('o', "dump", "dump all generated value/image/theme inside a file use it with -y"), + ECORE_GETOPT_STORE_STR('y', "eye", "use an eye file, faster than elt + theme"), ECORE_GETOPT_SENTINEL } }; @@ -371,6 +374,8 @@ char* engine = NULL; char* theme = NULL; char* presentation = NULL; + char* dump_in = NULL; + char* dump_out = NULL; unsigned char with_border = 0; unsigned char no_thumbs_bg = 0; unsigned char hd = 0; @@ -404,6 +409,8 @@ ECORE_GETOPT_VALUE_BOOL(no_thumbs_bg), ECORE_GETOPT_VALUE_BOOL(hd), ECORE_GETOPT_VALUE_BOOL(exit_option), + ECORE_GETOPT_VALUE_STR(dump_out), + ECORE_GETOPT_VALUE_STR(dump_in) }; ecore_app_args_set(argc, (const char **) argv); @@ -420,16 +427,26 @@ if(exit_option || engines_listed) return 0; - if(!presentation) + if ((presentation || theme) && dump_in) { + fprintf(stderr, "You can't set an eye file as an input if you want to specify a theme and a presentation.\nBetter specify it with -o.\n"); + return EXIT_FAILURE; + } + + if((dump_out || !dump_in) && !presentation) + { fprintf(stderr,"A presentation is required !\n"); return EXIT_FAILURE; } - if(ecore_file_is_dir(presentation) || !ecore_file_exists(presentation)) + if(presentation && (ecore_file_is_dir(presentation) || !ecore_file_exists(presentation))) { fprintf(stderr,"The presentation file doesn't exists \n"); exit(EXIT_FAILURE); + } else if (dump_in && (ecore_file_is_dir(dump_in) || !ecore_file_exists(dump_in))) + { + fprintf(stderr,"The eye file doesn't exists \n"); + exit(EXIT_FAILURE); } if(hd) @@ -462,6 +479,8 @@ eyelight_smart = eyelight_object_add(evas); eyelight_object_theme_file_set(eyelight_smart, theme); eyelight_object_presentation_file_set(eyelight_smart, presentation); + eyelight_object_eye_file_set(eyelight_smart, dump_in); + eyelight_object_dump_file_set(eyelight_smart, dump_out); eyelight_object_border_set(eyelight_smart, with_border); evas_object_move(eyelight_smart,0,0); evas_object_resize(eyelight_smart, sizew, sizeh); Modified: trunk/PROTO/eyelight/src/lib/Eyelight.h =================================================================== --- trunk/PROTO/eyelight/src/lib/Eyelight.h 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/Eyelight.h 2010-01-17 16:59:55 UTC (rev 45263) @@ -46,6 +46,7 @@ int* thumb; int w; int h; + int pos; }; @@ -61,7 +62,9 @@ EAPI void eyelight_viewer_thumbnails_size_set(Eyelight_Viewer *pres, int w, int h); EAPI int eyelight_viewer_presentation_file_set(Eyelight_Viewer *pres, const char* presentation); +EAPI int eyelight_viewer_eye_file_set(Eyelight_Viewer *pres, const char *eye); EAPI int eyelight_viewer_theme_file_set(Eyelight_Viewer *pres, const char* theme); +EAPI int eyelight_viewer_dump_file_set(Eyelight_Viewer *pres, const char *eye); EAPI int eyelight_viewer_new_presentation_file_set(Eyelight_Viewer *pres, const char* presentation); EAPI const char* eyelight_viewer_presentation_file_get(Eyelight_Viewer *pres); EAPI const char* eyelight_viewer_theme_file_get(Eyelight_Viewer *pres); Modified: trunk/PROTO/eyelight/src/lib/Eyelight_Smart.h =================================================================== --- trunk/PROTO/eyelight/src/lib/Eyelight_Smart.h 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/Eyelight_Smart.h 2010-01-17 16:59:55 UTC (rev 45263) @@ -11,6 +11,9 @@ EAPI const char* eyelight_object_presentation_file_get(Evas_Object *obj); EAPI const char* eyelight_object_theme_file_get(Evas_Object *obj); +EAPI void eyelight_object_eye_file_set(Evas_Object *obj, const char *eye); +EAPI void eyelight_object_dump_file_set(Evas_Object *obj, const char *dump); + EAPI void eyelight_object_border_set(Evas_Object *obj, int border); EAPI int eyelight_object_size_get(Evas_Object* obj); Modified: trunk/PROTO/eyelight/src/lib/edit/edit_slide.c =================================================================== --- trunk/PROTO/eyelight/src/lib/edit/edit_slide.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/edit/edit_slide.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -59,6 +59,8 @@ Eyelight_Slide *slide = calloc(1,sizeof(Eyelight_Slide)); + slide->thumb.pos = -1; + if(after<0) pres->slides = eina_list_prepend(pres->slides, slide); else if(after>=pres->size) Modified: trunk/PROTO/eyelight/src/lib/eyelight_smart.c =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_smart.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_smart.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -129,6 +129,25 @@ return eyelight_viewer_theme_file_get(sd->pres); } +EAPI void eyelight_object_eye_file_set(Evas_Object *obj, const char *eye) +{ + Smart_Data *sd; + E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); + if (!sd->pres || !eye) return; + + eyelight_object_theme_file_set(obj, eye); + eyelight_viewer_eye_file_set(sd->pres, eye); +} + +EAPI void eyelight_object_dump_file_set(Evas_Object *obj, const char *dump) +{ + Smart_Data *sd; + E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); + if (!sd->pres) return; + + eyelight_viewer_dump_file_set(sd->pres, dump); +} + void eyelight_object_border_set(Evas_Object *obj, int border) { Smart_Data *sd; Modified: trunk/PROTO/eyelight/src/lib/eyelight_viewer.c =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_viewer.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_viewer.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -137,6 +137,34 @@ DBG("## Number of slides: %d",pres->size); } +int eyelight_viewer_eye_file_set(Eyelight_Viewer *pres, const char *eye) +{ + EYELIGHT_FREE(pres->dump_in); + if (!eye || !ecore_file_exists(eye)) + return EINA_FALSE; + + pres->dump_in = strdup(eye); + + return EINA_TRUE; +} + +int eyelight_viewer_dump_file_set(Eyelight_Viewer *pres, const char *dump) +{ + EYELIGHT_FREE(pres->dump_out); + if (!dump) + return EINA_FALSE; + + pres->dump_out = strdup(dump); + + if (pres->theme) + { + int res = ecore_file_cp(pres->theme, pres->dump_out); + fprintf(stderr, "CP file: %i\n", res); + } + + return EINA_TRUE; +} + /** * Set the presentation elt file */ @@ -226,6 +254,8 @@ EYELIGHT_FREE((*pres)->theme); EYELIGHT_FREE((*pres)->elt_file); + EYELIGHT_FREE((*pres)->dump_in); + EYELIGHT_FREE((*pres)->dump_out); eyelight_viewer_clean(*pres); @@ -239,6 +269,7 @@ { Eyelight_Slide *slide = calloc(1,sizeof(Eyelight_Slide)); slide->pres = pres; + slide->thumb.pos = -1; return slide; } Modified: trunk/PROTO/eyelight/src/lib/eyelight_viewer.h =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_viewer.h 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_viewer.h 2010-01-17 16:59:55 UTC (rev 45263) @@ -115,6 +115,8 @@ Eyelight_Compiler *compiler; char* theme; + char *dump_in; + char *dump_out; int default_size_w; int default_size_h; Modified: trunk/PROTO/eyelight/src/lib/eyelight_viewer_expose.c =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_viewer_expose.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_viewer_expose.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -114,15 +114,33 @@ } else { + /* FIXME: Cleanup required, sharing more code with eyelight_viewer_slideshow.c */ + /* FIXME: Should be possible to do this asynchronously. */ snprintf(buf,EYELIGHT_BUFLEN,"object.swallow_%d_%d",pos_y,pos_x); const Eyelight_Thumb* thumb = eyelight_viewer_thumbnails_get(pres,i+first_slide); o_image = evas_object_image_add(pres->evas); pres->expose_image_thumbnails[i] = o_image; evas_object_color_set(o_image,255,255,255,255); - evas_object_image_size_set(o_image, thumb->w, thumb->h); - evas_object_image_data_set(o_image,thumb->thumb); - evas_object_image_filled_set(o_image,1); + + if (thumb->thumb) + { + evas_object_image_size_set(o_image, thumb->w, thumb->h); + evas_object_image_data_set(o_image,thumb->thumb); + evas_object_image_filled_set(o_image,1); + } + else + { + char key[256]; + int w; + int h; + + snprintf(key, sizeof (key), "eyelight/thumb/%i", thumb->pos); + evas_object_image_file_set(o_image, pres->dump_in, key); + evas_object_image_size_get(o_image, &w, &h); + evas_object_image_fill_set(o_image, 0, 0, w, h); + } + evas_object_show(o_image); edje_object_part_swallow(pres->expose_background,buf,o_image); Modified: trunk/PROTO/eyelight/src/lib/eyelight_viewer_slideshow.c =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_viewer_slideshow.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_viewer_slideshow.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -100,10 +100,25 @@ o_image = evas_object_image_add(pres->evas); pres->slideshow_image_thumbnails[i] = o_image; - evas_object_image_size_set(o_image, thumb->w, thumb->h); - evas_object_image_data_set(o_image,thumb->thumb); - evas_object_image_filled_set(o_image,1); - evas_object_show(o_image); + if (thumb->thumb) + { + evas_object_image_size_set(o_image, thumb->w, thumb->h); + evas_object_image_data_set(o_image,thumb->thumb); + evas_object_image_filled_set(o_image,1); + } + else + { + char key[256]; + int w; + int h; + + snprintf(key, sizeof (key), "eyelight/thumb/%i", thumb->pos); + evas_object_image_file_set(o_image, pres->dump_in, key); + evas_object_image_size_get(o_image, &w, &h); + evas_object_image_fill_set(o_image, 0, 0, w, h); + } + + evas_object_show(o_image); snprintf(buf,EYELIGHT_BUFLEN,"object.swallow_%d",i+1); edje_object_part_swallow(pres->slideshow_background,buf,o_image); } Modified: trunk/PROTO/eyelight/src/lib/eyelight_viewer_thumbnails.c =================================================================== --- trunk/PROTO/eyelight/src/lib/eyelight_viewer_thumbnails.c 2010-01-17 15:59:00 UTC (rev 45262) +++ trunk/PROTO/eyelight/src/lib/eyelight_viewer_thumbnails.c 2010-01-17 16:59:55 UTC (rev 45263) @@ -19,10 +19,10 @@ #include "eyelight_viewer.h" -int* _eyelight_viewer_thumbnails_create(Eyelight_Viewer* pres,int pos, int w, int h); -int _eyelight_viewer_thumbnails_load_idle(void *data); -int* _eyelight_viewer_thumbnails_resize(const int* pixel,int src_w,int src_h,int new_w,int new_h); -const Eyelight_Thumb* _eyelight_viewer_thumbnails_get(Eyelight_Viewer* pres, int pos, int w, int h); +static int* _eyelight_viewer_thumbnails_create(Eyelight_Viewer* pres,int pos, int w, int h); +static int _eyelight_viewer_thumbnails_load_idle(void *data); +static int* _eyelight_viewer_thumbnails_resize(const char *file, int index, const int* pixel,int src_w,int src_h,int new_w,int new_h); +static const Eyelight_Thumb* _eyelight_viewer_thumbnails_get(Eyelight_Viewer* pres, int pos, int w, int h); void eyelight_viewer_thumbnails_background_load_start(Eyelight_Viewer* pres) { @@ -52,7 +52,7 @@ for(i=0; i<eyelight_viewer_size_get(pres); i++) { Eyelight_Slide *slide = eina_list_nth(pres->slides, i); - if(slide->thumb.thumb) + if(slide->thumb.thumb || (pres->dump_in && slide->thumb.pos >= 0)) { EYELIGHT_FREE(slide->thumb.thumb); eyelight_viewer_thumbnails_get(pres, i); @@ -88,7 +88,7 @@ * @return returns a slide if success, * NULL if an error is occurs */ -const Eyelight_Thumb* _eyelight_viewer_thumbnails_get(Eyelight_Viewer* pres, int pos, int size_w, int size_h) +static const Eyelight_Thumb* _eyelight_viewer_thumbnails_get(Eyelight_Viewer* pres, int pos, int size_w, int size_h) { Eet_File* file; unsigned int w,h; @@ -98,13 +98,18 @@ if(!slide->thumb.thumb) { - slide->thumb.thumb = _eyelight_viewer_thumbnails_create(pres,pos,size_w,size_h); + if (pres->dump_in) + slide->thumb.pos = pos; + else + { + slide->thumb.thumb = _eyelight_viewer_thumbnails_create(pres,pos,size_w,size_h); - if(!slide->thumb.thumb) - return NULL; + if(!slide->thumb.thumb) + return NULL; - slide->thumb.w = size_w; - slide->thumb.h = size_h; + slide->thumb.w = size_w; + slide->thumb.h = size_h; + } if(pres->thumbnails.done_cb) pres->thumbnails.done_cb(pres, pos, &(slide->thumb), @@ -114,7 +119,7 @@ return &(slide->thumb); } -int* _eyelight_viewer_thumbnails_create(Eyelight_Viewer* pres,int pos,int size_w, int size_h) +static int* _eyelight_viewer_thumbnails_create(Eyelight_Viewer* pres,int pos,int size_w, int size_h) { Ecore_Evas *ee; Evas *e; @@ -165,7 +170,7 @@ pixel = ecore_evas_buffer_pixels_get(ee); - pixel_resize = _eyelight_viewer_thumbnails_resize(pixel,buffer_w,buffer_h, + pixel_resize = _eyelight_viewer_thumbnails_resize(pres->dump_out, pos, pixel,buffer_w,buffer_h, size_w, size_h); @@ -192,7 +197,7 @@ } } -int* _eyelight_viewer_thumbnails_resize(const int* pixel,int src_w,int src_h,int new_w,int new_h) +static int* _eyelight_viewer_thumbnails_resize(const char *file, int pos, const int* pixel,int src_w,int src_h,int new_w,int new_h) { Ecore_Evas* ee; Evas* e; @@ -216,6 +221,31 @@ new_pixel_copy = malloc(sizeof(int)*new_w*new_h); memcpy(new_pixel_copy,new_pixel,sizeof(int)*new_w*new_h); + /* FIXME: This could be done in another thread, would make startup more interactiv. */ + if (file) + { + char buffer[10]; + Eet_File *ef; + char *tmp; + int bytes; + + eina_convert_itoa(pos, buffer); + + tmp = alloca(strlen(buffer) + 16); + + strcpy(tmp, "eyelight/thumb/"); + strcat(tmp, buffer); + + ef = eet_open(file, EET_FILE_MODE_READ_WRITE); + + if (ef) + { + bytes = eet_data_image_write(ef, tmp, new_pixel, new_w, new_h, 0, 1, 0, 0); + + eet_close(ef); + } + } + evas_object_image_data_set(o_image,NULL); ecore_evas_free(ee); @@ -223,7 +253,7 @@ return new_pixel_copy; } -int _eyelight_viewer_thumbnails_load_idle(void *data) +static int _eyelight_viewer_thumbnails_load_idle(void *data) { Eyelight_Viewer* pres = (Eyelight_Viewer*)data; |