diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-09-10 18:07:39 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2019-09-10 18:07:39 +0300 |
commit | 8f55794c0e803ec5454febe2e45651c721f62c8f (patch) | |
tree | d72ee691ad669096d7f86e498560631cccadb515 /source | |
parent | a3e7440cfdd2f307e5c57922fd22e8770f0b8390 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 1 | ||||
-rw-r--r-- | source/blender/editors/include/UI_icons.h | 6 | ||||
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 19 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 7 |
8 files changed, 30 insertions, 16 deletions
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( |