From 8f55794c0e803ec5454febe2e45651c721f62c8f Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 10 Sep 2019 08:07:39 -0700 Subject: UI: File Browser Custom Folder Color Allows file browser folders to be shown in a theme-selectable color, default of manila. Differential Revision: https://developer.blender.org/D5713 Reviewed by Brecht Van Lommel --- release/datafiles/locale | 2 +- release/datafiles/userdef/userdef_default_theme.c | 1 + release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/blenloader/intern/versioning_userdef.c | 1 + source/blender/editors/include/UI_icons.h | 6 +++++- source/blender/editors/include/UI_resources.h | 1 + source/blender/editors/interface/interface_icons.c | 1 + source/blender/editors/interface/resources.c | 8 ++++++-- source/blender/editors/space_file/file_draw.c | 19 ++++++------------- source/blender/makesdna/DNA_userdef_types.h | 3 +++ source/blender/makesrna/intern/rna_userdef.c | 7 +++++++ 13 files changed, 35 insertions(+), 19 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index e7cd12454a2..1f6ec7f7a14 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit e7cd12454a2fe775361012cbc176fb9c370b6abb +Subproject commit 1f6ec7f7a145c36808231090c8666febb49db220 diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 23b1eb570d9..ff2a5ae2739 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -254,6 +254,7 @@ const bTheme U_theme_default = { .icon_object_data = RGBA(0x00d4a3ff), .icon_modifier = RGBA(0x84b8ffff), .icon_shading = RGBA(0xea7581ff), + .icon_folder = RGBA(0xe3c16eff), }, .space_properties = { .back = RGBA(0x42424200), diff --git a/release/scripts/addons b/release/scripts/addons index 14abe13dc89..5f3c703ea4b 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 14abe13dc890ba8fc7f78723ad67533ec2146aff +Subproject commit 5f3c703ea4b0f4651e4f28e682a91382a90a5596 diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index c646ac7c009..23b744fa47d 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit c646ac7c00965d9a117e50a066b777f5691028b9 +Subproject commit 23b744fa47da73c0b6c5b41b02cfe0efa008ec5c diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 8ed8eb04898..14a15ace67e 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -937,6 +937,7 @@ class USERPREF_PT_theme_interface_icons(PreferencePanel, Panel): flow.prop(ui, "icon_object_data") flow.prop(ui, "icon_modifier") flow.prop(ui, "icon_shading") + flow.prop(ui, "icon_folder") flow.prop(ui, "icon_border_intensity") diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 0182f8f6162..967820565e7 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -151,6 +151,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) */ { FROM_DEFAULT_V4_UCHAR(space_file.execution_buts); + FROM_DEFAULT_V4_UCHAR(tui.icon_folder); } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 29892657086..dd052a8256b 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -42,6 +42,9 @@ #ifndef DEF_ICON_SHADING # define DEF_ICON_SHADING DEF_ICON #endif +#ifndef DEF_ICON_FOLDER +# define DEF_ICON_FOLDER DEF_ICON +#endif #ifndef DEF_ICON_COLOR # define DEF_ICON_COLOR DEF_ICON #endif @@ -793,7 +796,7 @@ DEF_ICON(NEWFOLDER) DEF_ICON_BLANK(794) DEF_ICON(FILE_PARENT) DEF_ICON(FILE_REFRESH) -DEF_ICON(FILE_FOLDER) +DEF_ICON_FOLDER(FILE_FOLDER) DEF_ICON(FILE_BLANK) DEF_ICON(FILE_BLEND) DEF_ICON(FILE_IMAGE) @@ -1034,6 +1037,7 @@ DEF_ICON_COLOR(EVENT_RETURN) #undef DEF_ICON_OBJECT_DATA #undef DEF_ICON_MODIFIER #undef DEF_ICON_SHADING +#undef DEF_ICON_FOLDER #undef DEF_ICON_VECTOR #undef DEF_ICON_COLOR #undef DEF_ICON_FUND diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 29022adac6c..1c317ac458b 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -273,6 +273,7 @@ typedef enum ThemeColorID { TH_ICON_OBJECT_DATA, TH_ICON_MODIFIER, TH_ICON_SHADING, + TH_ICON_FOLDER, TH_ICON_FUND, TH_SCROLL_TEXT, diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 7ada4755a64..085ae5bdb93 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -169,6 +169,7 @@ static const IconType icontypes[] = { # define DEF_ICON_OBJECT_DATA(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT_DATA}, # define DEF_ICON_MODIFIER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_MODIFIER}, # define DEF_ICON_SHADING(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SHADING}, +# define DEF_ICON_FOLDER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FOLDER}, # define DEF_ICON_FUND(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FUND}, # define DEF_ICON_VECTOR(name) {ICON_TYPE_VECTOR, 0}, # define DEF_ICON_COLOR(name) {ICON_TYPE_COLOR_TEXTURE, 0}, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 7c5d5401d08..ae161f1017c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -905,6 +905,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_ICON_SHADING: cp = btheme->tui.icon_shading; break; + case TH_ICON_FOLDER: + cp = btheme->tui.icon_folder; + break; case TH_ICON_FUND: { /* Development fund icon color is not part of theme. */ static const uchar red[4] = {204, 48, 72, 255}; @@ -1391,8 +1394,9 @@ bool UI_GetIconThemeColor4ubv(int colorid, uchar col[4]) /* Always color development fund icon. */ } else if (!((theme_spacetype == SPACE_OUTLINER && theme_regionid == RGN_TYPE_WINDOW) || - (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR))) { - /* Only colored icons in outliner and popups, overall UI is intended + (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR) || + (theme_spacetype == SPACE_FILE && theme_regionid == RGN_TYPE_WINDOW))) { + /* Only colored icons in specific places, overall UI is intended * to stay monochrome and out of the way except a few places where it * is important to communicate different data types. */ return false; diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index ca26a56a26e..0aec6d5e6a0 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -138,13 +138,10 @@ static void file_draw_icon( { uiBut *but; int x, y; - // float alpha = 1.0f; x = sx; y = sy - height; - /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ - but = uiDefIconBut( block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); @@ -265,15 +262,11 @@ static void file_draw_preview(uiBlock *block, float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; if (is_icon) { - /* File and Folder icons draw with lowered opacity until we add themes */ - col[3] = 0.6f; - /* Use dark images if background is light */ - float bg[3]; - UI_GetThemeColor3fv(TH_BACK, bg); - if (rgb_to_grayscale(bg) > 0.5f) { - col[0] = 0; - col[1] = 0; - col[2] = 0; + if (typeflags & FILE_TYPE_DIR) { + UI_GetThemeColor4fv(TH_ICON_FOLDER, col); + } + else { + UI_GetThemeColor4fv(TH_TEXT, col); } } else if (typeflags & FILE_TYPE_FTFONT) { @@ -314,7 +307,7 @@ static void file_draw_preview(uiBlock *block, float icon_opacity = 0.3f; uchar icon_color[4] = {0, 0, 0, 255}; float bgcolor[4]; - UI_GetThemeColor4fv(TH_TEXT, bgcolor); + UI_GetThemeColor4fv(TH_ICON_FOLDER, bgcolor); if (rgb_to_grayscale(bgcolor) < 0.5f) { icon_color[0] = 255; icon_color[1] = 255; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 9e69cd6fda2..6e44c51970d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -196,6 +196,9 @@ typedef struct ThemeUI { unsigned char icon_modifier[4]; /** Shading related items. */ unsigned char icon_shading[4]; + /** File folders. */ + unsigned char icon_folder[4]; + char _pad2[4]; /** Intensity of the border icons. >0 will render an border around themed * icons. */ float icon_border_intensity; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 37fee576fde..46abaef48d5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1504,6 +1504,13 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shading", ""); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "icon_folder", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_folder"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text( + prop, "File Folders", "Color of folders in the file browser"); + RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "icon_border_intensity", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "icon_border_intensity"); RNA_def_property_ui_text( -- cgit v1.2.3