void EflResources::initCb__( void* _this , Ecore_Thread* _th ) { ASSERT( _this && _th , "NULL pointers passed to thread function." ); EflResources* rh( static_cast< EflResources* >( _this ) ); std::for_each( init_images__.begin() , init_images__.end() , [&]( std::string const _path ) { Evas_Object* object = evas_object_image_add( rh->window__ ); evas_object_image_load_size_set( object , rh->max_width__ , rh->max_height__ ); evas_object_image_file_set( object , _path.c_str() , nullptr ); CCallbackHandler::evasEventCallback( object , CALLBACK_IMAGE_PRELOADED , [=](){ ++( rh->resources_loaded__ ); rh->signals__[LOADING]->emit(); } ); rh->preloaded_images__[_path] = object; evas_object_image_preload( object , 0 ); } ); }
void EflResources::preloadCachedImageCb__( std::string const& _path ) { if( 0 < preloaded_images__.count( _path ) ) { Evas_Object* object = preloaded_images__[_path]; evas_object_image_load_size_set( object , max_width__ , max_height__ ); std::string cached_file( cache_dir + _path ); evas_object_image_file_set( object , cached_file.c_str() , nullptr ); if( EVAS_LOAD_ERROR_NONE != evas_object_image_load_error_get( object ) ) { signals__[PRELOAD_FAIL]->emit(); LOGGER( "Failed to load image file: " + _path ); } else { CCallbackHandler::evasEventCallback( object , CALLBACK_IMAGE_PRELOADED , [=](){ signals__[PRELOAD_SUCCESS]->emit(); } ); evas_object_image_preload( object , 0 ); } } }
void create_image_obj(EFL_Core *core, EFL_Image *img, const char* path_image, int img_width, int img_height){ img->obj = evas_object_image_add(get_main_object(core)); evas_object_image_file_set(img->obj, path_image, NULL); evas_object_image_preload(img->obj, EINA_TRUE); img->width = img_width; img->height = img_height; }
EAPI Eina_Bool e_icon_fdo_icon_set(Evas_Object *obj, const char *icon) { E_Smart_Data *sd; const char *path; int len; if (!icon) return EINA_FALSE; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (icon[0] == '/') return e_icon_file_set(obj, icon); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; eina_stringshare_replace(&sd->fdo, icon); if (!sd->fdo) return EINA_FALSE; path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size); if (!path) return EINA_FALSE; len = strlen(icon); if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj"))) return e_icon_file_edje_set(obj, path, "icon"); /* smart code here */ _e_icon_obj_prepare(obj, sd); sd->loading = 0; if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); evas_object_image_file_set(sd->obj, path, NULL); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, 0); } else if (evas_object_visible_get(obj)) evas_object_show(sd->obj); _e_icon_smart_reconfigure(sd); return EINA_TRUE; }
EAPI Eina_Bool e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; /* smart code here */ sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; _e_icon_obj_prepare(obj, sd); if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); evas_object_image_file_set(sd->obj, file, key); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (!_handle_anim(sd)) { if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, 0); } else if (evas_object_visible_get(obj)) evas_object_show(sd->obj); } _e_icon_smart_reconfigure(sd); return EINA_TRUE; }
EAPI Eina_Bool e_icon_file_set(Evas_Object *obj, const char *file) { E_Smart_Data *sd; int len; if (!file) return EINA_FALSE; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; len = strlen(file); if ((len > 4) && (!strcasecmp(file + len - 4, ".edj"))) return e_icon_file_edje_set(obj, file, "icon"); /* smart code here */ _e_icon_obj_prepare(obj, sd); /* FIXME: 64x64 - unhappy about this. use icon size */ sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); #ifdef USE_ICON_CACHE if (_e_icon_cache_find(obj, file)) { _e_icon_smart_reconfigure(sd); return EINA_TRUE; } #endif evas_object_image_file_set(sd->obj, file, NULL); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (!_handle_anim(sd)) { if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, EINA_FALSE); } else if (evas_object_visible_get(obj)) { evas_object_show(sd->obj); #ifdef USE_ICON_CACHE _e_icon_cache_icon_loaded(sd->ci); #endif } } #ifdef USE_ICON_CACHE else { evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL, _e_icon_obj_del, obj); _cache->load_queue = eina_list_remove(_cache->load_queue, sd->ci); eina_stringshare_del(sd->ci->id); E_FREE(sd->ci); sd->ci = NULL; } #endif _e_icon_smart_reconfigure(sd); return EINA_TRUE; }