diff options
author | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-15 21:13:03 +0300 |
---|---|---|
committer | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-15 21:47:09 +0300 |
commit | 452a1c7b38383fd3f51532c429912677864e4a33 (patch) | |
tree | 37481ed6eca5cc6840dee0686b24b75ba1842cbc /source/blender/editors/interface/interface_icons.c | |
parent | f137022f9919f4dd315ec6b325a08e1bf5aec6fb (diff) |
Collections: Add color tagging
This adds color tagging to collections. There are 8 color
options which are themable in the user preferences, with an additional
option for no color tag by default.
This adds a new filled collection icon and 8 colored variants of the
icon that can be themed in the user preferences.
In this commit the only interface to setting the color tags is through
Python, and there is nowhere in the interface where the collections are
shown colored. Setting and viewing the color tags from the outliner will
follow.
Manifest Task: https://developer.blender.org/T77777
Differential Revision: https://developer.blender.org/D8622
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index d22ddb5f2b7..7008d22becc 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -41,6 +41,7 @@ #include "BLI_utildefines.h" #include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_gpencil_types.h" @@ -461,6 +462,33 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19) # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH +static void vicon_collection_color_draw( + short color_tag, 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_tag]; + + 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 * 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. @@ -969,6 +997,15 @@ static void init_internal_icons(void) 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_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) @@ -2324,6 +2361,17 @@ int UI_mode_icon_get(const int mode) } } +int UI_collection_color_icon_get(const Collection *collection) +{ + int icon = ICON_OUTLINER_COLLECTION; + + if (collection->color_tag != COLLECTION_COLOR_NONE) { + icon = ICON_COLLECTION_COLOR_01 + collection->color_tag; + } + + return icon; +} + /* draws icon with dpi scale factor */ void UI_icon_draw(float x, float y, int icon_id) { |