Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_icons.c
| Show All 35 Lines | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_fileops_types.h" | #include "BLI_fileops_types.h" | ||||
| #include "BLI_math_color_blend.h" | #include "BLI_math_color_blend.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| #include "DNA_collection_types.h" | |||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_dynamicpaint_types.h" | #include "DNA_dynamicpaint_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| ▲ Show 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | |||||
| DEF_ICON_VECTOR_COLORSET_DRAW_NTH(16, 15) | DEF_ICON_VECTOR_COLORSET_DRAW_NTH(16, 15) | ||||
| DEF_ICON_VECTOR_COLORSET_DRAW_NTH(17, 16) | DEF_ICON_VECTOR_COLORSET_DRAW_NTH(17, 16) | ||||
| DEF_ICON_VECTOR_COLORSET_DRAW_NTH(18, 17) | DEF_ICON_VECTOR_COLORSET_DRAW_NTH(18, 17) | ||||
| DEF_ICON_VECTOR_COLORSET_DRAW_NTH(19, 18) | DEF_ICON_VECTOR_COLORSET_DRAW_NTH(19, 18) | ||||
| DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19) | DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19) | ||||
| # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH | # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH | ||||
| static void vicon_collection_color_draw( | |||||
| short color, int x, int y, int UNUSED(w), int UNUSED(h), float UNUSED(alpha)) | |||||
| { | |||||
| bTheme *btheme = UI_GetTheme(); | |||||
| const ThemeCollectionColor *collection_color = &btheme->collection_color[color - 1]; | |||||
| UI_icon_draw_ex( | |||||
| x, y, ICON_OUTLINER_COLLECTION, U.inv_dpi_fac, 1.0f, 0.0f, collection_color->color, true); | |||||
| } | |||||
| # define DEF_ICON_COLLECTION_COLOR_DRAW(index, color) \ | |||||
| static void vicon_collection_color_draw_##index(int x, int y, int w, int h, float alpha) \ | |||||
| { \ | |||||
| vicon_collection_color_draw(color, x, y, w, h, alpha); \ | |||||
| } | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(01, COLLECTION_COLOR_01); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(02, COLLECTION_COLOR_02); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(03, COLLECTION_COLOR_03); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(04, COLLECTION_COLOR_04); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(05, COLLECTION_COLOR_05); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(06, COLLECTION_COLOR_06); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(07, COLLECTION_COLOR_07); | |||||
| DEF_ICON_COLLECTION_COLOR_DRAW(08, COLLECTION_COLOR_08); | |||||
| # undef DEF_ICON_COLLECTION_COLOR_DRAW | |||||
| /* Dynamically render icon instead of rendering a plain color to a texture/buffer | /* Dynamically render icon instead of rendering a plain color to a texture/buffer | ||||
| * This is not strictly a "vicon", as it needs access to icon->obj to get the color info, | * This is not strictly a "vicon", as it needs access to icon->obj to get the color info, | ||||
| * but it works in a very similar way. | * but it works in a very similar way. | ||||
| */ | */ | ||||
| static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h) | static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h) | ||||
| { | { | ||||
| bGPDlayer *gpl = (bGPDlayer *)icon->obj; | bGPDlayer *gpl = (bGPDlayer *)icon->obj; | ||||
| ▲ Show 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | # endif | ||||
| def_internal_vicon(ICON_COLORSET_13_VEC, vicon_colorset_draw_13); | def_internal_vicon(ICON_COLORSET_13_VEC, vicon_colorset_draw_13); | ||||
| def_internal_vicon(ICON_COLORSET_14_VEC, vicon_colorset_draw_14); | def_internal_vicon(ICON_COLORSET_14_VEC, vicon_colorset_draw_14); | ||||
| def_internal_vicon(ICON_COLORSET_15_VEC, vicon_colorset_draw_15); | def_internal_vicon(ICON_COLORSET_15_VEC, vicon_colorset_draw_15); | ||||
| def_internal_vicon(ICON_COLORSET_16_VEC, vicon_colorset_draw_16); | def_internal_vicon(ICON_COLORSET_16_VEC, vicon_colorset_draw_16); | ||||
| def_internal_vicon(ICON_COLORSET_17_VEC, vicon_colorset_draw_17); | def_internal_vicon(ICON_COLORSET_17_VEC, vicon_colorset_draw_17); | ||||
| def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18); | def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18); | ||||
| def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19); | def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19); | ||||
| def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20); | def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20); | ||||
| def_internal_vicon(ICON_COLLECTION_COLOR_01, vicon_collection_color_draw_01); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_02, vicon_collection_color_draw_02); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_03, vicon_collection_color_draw_03); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_04, vicon_collection_color_draw_04); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_05, vicon_collection_color_draw_05); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07); | |||||
| def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08); | |||||
| } | } | ||||
| static void init_iconfile_list(struct ListBase *list) | static void init_iconfile_list(struct ListBase *list) | ||||
| { | { | ||||
| IconFile *ifile; | IconFile *ifile; | ||||
| struct direntry *dir; | struct direntry *dir; | ||||
| int index = 1; | int index = 1; | ||||
| const char *icondir; | const char *icondir; | ||||
| ▲ Show 20 Lines • Show All 1,148 Lines • ▼ Show 20 Lines | switch (GS(id->name)) { | ||||
| case ID_LA: /* fall through */ | case ID_LA: /* fall through */ | ||||
| iconid = BKE_icon_id_ensure(id); | iconid = BKE_icon_id_ensure(id); | ||||
| /* checks if not exists, or changed */ | /* checks if not exists, or changed */ | ||||
| UI_id_icon_render(C, NULL, id, big, true); | UI_id_icon_render(C, NULL, id, big, true); | ||||
| break; | break; | ||||
| case ID_SCR: | case ID_SCR: | ||||
| iconid = ui_id_screen_get_icon(C, id); | iconid = ui_id_screen_get_icon(C, id); | ||||
| break; | break; | ||||
| case ID_GR: | |||||
| iconid = UI_collection_color_icon_get((Collection *)id); | |||||
| break; | |||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| return iconid; | return iconid; | ||||
| } | } | ||||
| int UI_library_icon_get(const ID *id) | int UI_library_icon_get(const ID *id) | ||||
| ▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | case OB_MODE_POSE: | ||||
| return ICON_POSE_HLT; | return ICON_POSE_HLT; | ||||
| case OB_MODE_PAINT_GPENCIL: | case OB_MODE_PAINT_GPENCIL: | ||||
| return ICON_GREASEPENCIL; | return ICON_GREASEPENCIL; | ||||
| default: | default: | ||||
| return ICON_NONE; | return ICON_NONE; | ||||
| } | } | ||||
| } | } | ||||
| int UI_collection_color_icon_get(const Collection *collection) | |||||
| { | |||||
| int icon = ICON_OUTLINER_COLLECTION; | |||||
| if (collection->color != COLLECTION_COLOR_NONE) { | |||||
| icon = ICON_COLLECTION_COLOR_01 + (collection->color - 1); | |||||
| } | |||||
| return icon; | |||||
| } | |||||
| /* draws icon with dpi scale factor */ | /* draws icon with dpi scale factor */ | ||||
| void UI_icon_draw(float x, float y, int icon_id) | void UI_icon_draw(float x, float y, int icon_id) | ||||
| { | { | ||||
| UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false); | UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false); | ||||
| } | } | ||||
| void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) | void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||