Blender V4.3
BKE_icons.h File Reference
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.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 (int icon_id)
 
bool BKE_icon_is_preview (int icon_id)
 
bool BKE_icon_is_image (int icon_id)
 
void BKE_icon_set (int icon_id, struct Icon *icon)
 
void BKE_icon_id_delete (struct ID *id)
 
bool BKE_icon_delete (int icon_id)
 
bool BKE_icon_delete_unmanaged (int icon_id)
 
void BKE_icon_changed (int icon_id)
 
void BKE_icons_free (void)
 
void BKE_icons_deferred_free (void)
 
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, unsigned int size_x, 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 159 of file BKE_icons.h.

Referenced by BKE_previewimg_ensure(), and UI_icon_preview_to_render_size().

Typedef Documentation

◆ DrawInfoFreeFP

typedef void(* DrawInfoFreeFP) (void *drawinfo)

Definition at line 28 of file BKE_icons.h.

◆ Icon

typedef struct Icon Icon

Definition at line 75 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 

Studio-light.

ICON_DATA_GPLAYER 

GPencil Layer color preview (annotations): obj is bGPDlayer

Definition at line 30 of file BKE_icons.h.

Function Documentation

◆ BKE_icon_changed()

◆ BKE_icon_delete()

◆ BKE_icon_delete_unmanaged()

bool BKE_icon_delete_unmanaged ( int icon_id)

◆ BKE_icon_ensure_studio_light()

int BKE_icon_ensure_studio_light ( struct StudioLight * sl,
int id_type )

Definition at line 586 of file icons.cc.

References get_next_free_id(), icon_create(), ICON_DATA_STUDIOLIGHT, and Icon::id_type.

Referenced by studiolight_create().

◆ BKE_icon_geom_ensure()

◆ 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,
unsigned int size_x,
unsigned int size_y )

Referenced by icon_draw_size().

◆ BKE_icon_get()

◆ BKE_icon_gplayer_color_ensure()

int BKE_icon_gplayer_color_ensure ( struct bGPDlayer * gpl)

Return icon id for Grease Pencil layer (color preview) or create new icon if not found.

Definition at line 313 of file icons.cc.

References BLI_assert, BLI_thread_is_main(), CLOG_ERROR, G, get_next_free_id(), icon_gplayer_color_ensure_create_icon(), bGPDlayer_Runtime::icon_id, LOG, and bGPDlayer::runtime.

◆ BKE_icon_id_delete()

void BKE_icon_id_delete ( struct ID * id)

◆ BKE_icon_id_ensure()

◆ BKE_icon_imbuf_create()

int BKE_icon_imbuf_create ( struct 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 376 of file icons.cc.

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

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

◆ BKE_icon_imbuf_get_buffer()

struct ImBuf * BKE_icon_imbuf_get_buffer ( int icon_id)

◆ BKE_icon_is_image()

bool BKE_icon_is_image ( int icon_id)

◆ BKE_icon_is_preview()

bool BKE_icon_is_preview ( int icon_id)

◆ BKE_icon_preview_ensure()

int BKE_icon_preview_ensure ( struct ID * id,
struct PreviewImage * preview )

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

Definition at line 336 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, icon_id_ensure_create_icon(), LOG, and PreviewImage::runtime.

◆ BKE_icon_set()

void BKE_icon_set ( int icon_id,
struct Icon * icon )

Set icon for id if not already defined. Used for inserting the internal icons.

Definition at line 429 of file icons.cc.

References BLI_ghash_ensure_p(), CLOG_ERROR, gIconMutex, gIcons, lock, LOG, and POINTER_FROM_INT.

Referenced by def_internal_icon(), and def_internal_vicon().

◆ 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)