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
This commit is contained in:
Harley Acheson 2019-09-10 08:07:39 -07:00
parent a3e7440cfd
commit 8f55794c0e
13 changed files with 35 additions and 19 deletions

@ -1 +1 @@
Subproject commit e7cd12454a2fe775361012cbc176fb9c370b6abb
Subproject commit 1f6ec7f7a145c36808231090c8666febb49db220

View File

@ -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),

@ -1 +1 @@
Subproject commit 14abe13dc890ba8fc7f78723ad67533ec2146aff
Subproject commit 5f3c703ea4b0f4651e4f28e682a91382a90a5596

@ -1 +1 @@
Subproject commit c646ac7c00965d9a117e50a066b777f5691028b9
Subproject commit 23b744fa47da73c0b6c5b41b02cfe0efa008ec5c

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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},

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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(