Blender  V2.93
Classes | Macros | Typedefs | Enumerations | Functions
BKE_icons.h File Reference
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Classes

struct  Icon
 
struct  Icon_Geom
 

Macros

#define ICON_RENDER_DEFAULT_HEIGHT   32
 

Typedefs

typedef void(* DrawInfoFreeFP) (void *drawinfo)
 
typedef struct Icon Icon
 

Enumerations

enum  {
  ICON_DATA_ID = 0 , ICON_DATA_IMBUF , ICON_DATA_PREVIEW , ICON_DATA_GEOM ,
  ICON_DATA_STUDIOLIGHT , ICON_DATA_GPLAYER
}
 

Functions

void BKE_icons_init (int first_dyn_id)
 
int BKE_icon_id_ensure (struct ID *id)
 
int BKE_icon_gplayer_color_ensure (struct bGPDlayer *gpl)
 
int BKE_icon_preview_ensure (struct ID *id, struct PreviewImage *preview)
 
int BKE_icon_imbuf_create (struct ImBuf *ibuf) ATTR_WARN_UNUSED_RESULT
 
struct ImBufBKE_icon_imbuf_get_buffer (int icon_id) ATTR_WARN_UNUSED_RESULT
 
struct IconBKE_icon_get (const int icon_id)
 
void BKE_icon_set (const int icon_id, struct Icon *icon)
 
void BKE_icon_id_delete (struct ID *id)
 
bool BKE_icon_delete (const int icon_id)
 
bool BKE_icon_delete_unmanaged (const int icon_id)
 
void BKE_icon_changed (const int icon_id)
 
void BKE_icons_free (void)
 
void BKE_icons_deferred_free (void)
 
void BKE_previewimg_freefunc (void *link)
 
void BKE_previewimg_free (struct PreviewImage **prv)
 
void BKE_previewimg_clear (struct PreviewImage *prv)
 
void BKE_previewimg_clear_single (struct PreviewImage *prv, enum eIconSizes size)
 
struct PreviewImage ** BKE_previewimg_id_get_p (const struct ID *id)
 
struct PreviewImageBKE_previewimg_id_get (const struct ID *id)
 
bool BKE_previewimg_id_supports_jobs (const struct ID *id)
 
void BKE_previewimg_id_custom_set (struct ID *id, const char *path)
 
void BKE_previewimg_id_free (struct ID *id)
 
struct PreviewImageBKE_previewimg_create (void)
 
struct PreviewImageBKE_previewimg_copy (const struct PreviewImage *prv)
 
void BKE_previewimg_id_copy (struct ID *new_id, const struct ID *old_id)
 
struct PreviewImageBKE_previewimg_id_ensure (struct ID *id)
 
void BKE_previewimg_ensure (struct PreviewImage *prv, const int size)
 
struct ImBufBKE_previewimg_to_imbuf (struct PreviewImage *prv, const int size)
 
void BKE_previewimg_finish (struct PreviewImage *prv, const int size)
 
bool BKE_previewimg_is_finished (const struct PreviewImage *prv, const int size)
 
struct PreviewImageBKE_previewimg_cached_get (const char *name)
 
struct PreviewImageBKE_previewimg_cached_ensure (const char *name)
 
struct PreviewImageBKE_previewimg_cached_thumbnail_read (const char *name, const char *path, const int source, bool force_update)
 
void BKE_previewimg_cached_release (const char *name)
 
void BKE_previewimg_deferred_release (struct PreviewImage *prv)
 
void BKE_previewimg_blend_write (struct BlendWriter *writer, const struct PreviewImage *prv)
 
void BKE_previewimg_blend_read (struct BlendDataReader *reader, struct PreviewImage *prv)
 
int BKE_icon_geom_ensure (struct Icon_Geom *geom)
 
struct Icon_GeomBKE_icon_geom_from_memory (uchar *data, size_t data_len)
 
struct Icon_GeomBKE_icon_geom_from_file (const char *filename)
 
struct ImBufBKE_icon_geom_rasterize (const struct Icon_Geom *geom, const unsigned int size_x, const unsigned int size_y)
 
void BKE_icon_geom_invert_lightness (struct Icon_Geom *geom)
 
int BKE_icon_ensure_studio_light (struct StudioLight *sl, int id_type)
 

Detailed Description

Resizable Icons for Blender

There is some thread safety for this API but it is rather weak. Registering or unregistering icons is thread safe, changing data of icons from multiple threads is not. Practically this should be fine since only the main thread modifies icons. Should that change, more locks or a different design need to be introduced.

Definition in file BKE_icons.h.

Macro Definition Documentation

◆ ICON_RENDER_DEFAULT_HEIGHT

#define ICON_RENDER_DEFAULT_HEIGHT   32

Definition at line 202 of file BKE_icons.h.

Typedef Documentation

◆ DrawInfoFreeFP

typedef void(* DrawInfoFreeFP) (void *drawinfo)

Definition at line 39 of file BKE_icons.h.

◆ Icon

typedef struct Icon Icon

Definition at line 39 of file BKE_icons.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ICON_DATA_ID 

ID preview: obj is ID.

ICON_DATA_IMBUF 

Arbitrary Image buffer: obj is ImBuf

ICON_DATA_PREVIEW 

Preview: obj is PreviewImage

ICON_DATA_GEOM 

2D triangles: obj is Icon_Geom

ICON_DATA_STUDIOLIGHT 

Studiolight

ICON_DATA_GPLAYER 

GPencil Layer color preview (annotations): obj is bGPDlayer

Definition at line 41 of file BKE_icons.h.

Function Documentation

◆ BKE_icon_changed()

void BKE_icon_changed ( const int  icon_id)

◆ BKE_icon_delete()

bool BKE_icon_delete ( const int  icon_id)

◆ BKE_icon_delete_unmanaged()

bool BKE_icon_delete_unmanaged ( const int  icon_id)

◆ BKE_icon_ensure_studio_light()

int BKE_icon_ensure_studio_light ( struct StudioLight sl,
int  id_type 
)

◆ BKE_icon_geom_ensure()

int BKE_icon_geom_ensure ( struct Icon_Geom geom)

◆ BKE_icon_geom_from_file()

struct Icon_Geom* BKE_icon_geom_from_file ( const char *  filename)

◆ BKE_icon_geom_from_memory()

struct Icon_Geom* BKE_icon_geom_from_memory ( uchar data,
size_t  data_len 
)

◆ BKE_icon_geom_invert_lightness()

void BKE_icon_geom_invert_lightness ( struct Icon_Geom geom)

◆ BKE_icon_geom_rasterize()

struct ImBuf* BKE_icon_geom_rasterize ( const struct Icon_Geom geom,
const unsigned int  size_x,
const unsigned int  size_y 
)

◆ BKE_icon_get()

struct Icon* BKE_icon_get ( const int  icon_id)

◆ BKE_icon_gplayer_color_ensure()

int BKE_icon_gplayer_color_ensure ( struct bGPDlayer gpl)

◆ BKE_icon_id_delete()

void BKE_icon_id_delete ( struct ID id)

◆ BKE_icon_id_ensure()

int BKE_icon_id_ensure ( struct ID id)

◆ BKE_icon_imbuf_create()

int BKE_icon_imbuf_create ( ImBuf ibuf)

Create an icon as owner or ibuf. The icon-ID is not stored in ibuf, it needs to be stored separately.

Note
Transforms ownership of ibuf to the newly created icon.

Definition at line 856 of file icons.cc.

References Icon::flag, get_next_free_id(), icon_create(), ICON_DATA_IMBUF, ICON_FLAG_MANAGED, and Icon_Geom::icon_id.

Referenced by filelist_cache_preview_runf(), and filelist_file_create_entry().

◆ BKE_icon_imbuf_get_buffer()

struct ImBuf* BKE_icon_imbuf_get_buffer ( int  icon_id)

◆ BKE_icon_preview_ensure()

int BKE_icon_preview_ensure ( ID id,
PreviewImage preview 
)

Return icon id of given preview, or create new icon if not found.

Definition at line 811 of file icons.cc.

References BKE_previewimg_id_ensure(), BLI_assert, CLOG_ERROR, Icon::flag, G, get_next_free_id(), icon_create(), ICON_DATA_PREVIEW, ICON_FLAG_MANAGED, ID::icon_id, PreviewImage::icon_id, icon_id_ensure_create_icon(), id, and LOG.

◆ BKE_icon_set()

void BKE_icon_set ( const int  icon_id,
struct Icon icon 
)

◆ BKE_icons_deferred_free()

void BKE_icons_deferred_free ( void  )

◆ BKE_icons_free()

void BKE_icons_free ( void  )

◆ BKE_icons_init()

void BKE_icons_init ( int  first_dyn_id)

◆ BKE_previewimg_blend_read()

void BKE_previewimg_blend_read ( struct BlendDataReader reader,
struct PreviewImage prv 
)

◆ BKE_previewimg_blend_write()

void BKE_previewimg_blend_write ( struct BlendWriter writer,
const struct PreviewImage prv 
)

◆ BKE_previewimg_cached_ensure()

struct PreviewImage* BKE_previewimg_cached_ensure ( const char *  name)

Generate an empty PreviewImage, if not yet existing.

Definition at line 464 of file icons.cc.

References BKE_previewimg_create(), BLI_assert, BLI_ghash_ensure_p_ex(), BLI_strdup(), BLI_thread_is_main(), and gCachedPreviews.

Referenced by bpy_utils_previews_new().

◆ BKE_previewimg_cached_get()

struct PreviewImage* BKE_previewimg_cached_get ( const char *  name)

Definition at line 455 of file icons.cc.

References BLI_assert, BLI_ghash_lookup(), BLI_thread_is_main(), and gCachedPreviews.

◆ BKE_previewimg_cached_release()

void BKE_previewimg_cached_release ( const char *  name)

◆ BKE_previewimg_cached_thumbnail_read()

struct PreviewImage* BKE_previewimg_cached_thumbnail_read ( const char *  name,
const char *  path,
const int  source,
bool  force_update 
)

Generate a PreviewImage from given file path, using thumbnails management, if not yet existing. Does not actually generate the preview, BKE_previewimg_ensure() must be called for that.

Definition at line 485 of file icons.cc.

References BKE_previewimg_clear(), BKE_previewimg_free(), BLI_assert, BLI_ghash_insert(), BLI_ghash_lookup_p(), BLI_strdup(), BLI_thread_is_main(), gCachedPreviews, previewimg_deferred_create(), PRV_DEFERRED_DATA, and STREQ.

Referenced by bpy_utils_previews_load().

◆ BKE_previewimg_clear()

void BKE_previewimg_clear ( struct PreviewImage prv)

◆ BKE_previewimg_clear_single()

void BKE_previewimg_clear_single ( struct PreviewImage prv,
enum eIconSizes  size 
)

◆ BKE_previewimg_copy()

struct PreviewImage* BKE_previewimg_copy ( const struct PreviewImage prv)

Referenced by UI_icon_to_preview().

◆ BKE_previewimg_create()

struct PreviewImage* BKE_previewimg_create ( void  )

◆ BKE_previewimg_deferred_release()

void BKE_previewimg_deferred_release ( struct PreviewImage prv)

◆ BKE_previewimg_ensure()

void BKE_previewimg_ensure ( PreviewImage prv,
const int  size 
)

◆ BKE_previewimg_finish()

void BKE_previewimg_finish ( struct PreviewImage prv,
const int  size 
)

◆ BKE_previewimg_free()

void BKE_previewimg_free ( struct PreviewImage **  prv)

◆ BKE_previewimg_freefunc()

void BKE_previewimg_freefunc ( void *  link)

◆ BKE_previewimg_id_copy()

void BKE_previewimg_id_copy ( struct ID new_id,
const struct ID old_id 
)

◆ BKE_previewimg_id_custom_set()

void BKE_previewimg_id_custom_set ( struct ID id,
const char *  path 
)

◆ BKE_previewimg_id_ensure()

struct PreviewImage* BKE_previewimg_id_ensure ( struct ID id)

◆ BKE_previewimg_id_free()

void BKE_previewimg_id_free ( struct ID id)

Definition at line 392 of file icons.cc.

References BKE_previewimg_free(), and BKE_previewimg_id_get_p().

◆ BKE_previewimg_id_get()

struct PreviewImage* BKE_previewimg_id_get ( const struct ID id)

◆ BKE_previewimg_id_get_p()

struct PreviewImage** BKE_previewimg_id_get_p ( const struct ID id)

◆ BKE_previewimg_id_supports_jobs()

bool BKE_previewimg_id_supports_jobs ( const struct ID id)

◆ BKE_previewimg_is_finished()

bool BKE_previewimg_is_finished ( const struct PreviewImage prv,
const int  size 
)

◆ BKE_previewimg_to_imbuf()

struct ImBuf* BKE_previewimg_to_imbuf ( PreviewImage prv,
const int  size 
)

Create an ImBuf holding a copy of the preview image buffer in prv.

Note
The returned image buffer has to be free'd (IMB_freeImBuf()).

Definition at line 597 of file icons.cc.

References PreviewImage::h, IB_rect, IMB_allocImBuf(), ImBuf::rect, PreviewImage::rect, size(), w(), and PreviewImage::w.

Referenced by filelist_cache_preview_runf(), filelist_file_create_entry(), and IMB_thumb_load_blend().