UI: File Browser Custom Folder Color
authorHarley Acheson <harley.acheson@gmail.com>
Tue, 10 Sep 2019 15:07:39 +0000 (08:07 -0700)
committerHarley Acheson <harley.acheson@gmail.com>
Tue, 10 Sep 2019 15:07:39 +0000 (08:07 -0700)
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

13 files changed:
release/datafiles/locale
release/datafiles/userdef/userdef_default_theme.c
release/scripts/addons
release/scripts/addons_contrib
release/scripts/startup/bl_ui/space_userpref.py
source/blender/blenloader/intern/versioning_userdef.c
source/blender/editors/include/UI_icons.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/resources.c
source/blender/editors/space_file/file_draw.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index e7cd12454a2fe775361012cbc176fb9c370b6abb..1f6ec7f7a145c36808231090c8666febb49db220 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e7cd12454a2fe775361012cbc176fb9c370b6abb
+Subproject commit 1f6ec7f7a145c36808231090c8666febb49db220
index 23b1eb570d910c8e54023c859f7c83e9b6b49d84..ff2a5ae2739d6ce0cd5ca31980ea759e388f3641 100644 (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),
index 14abe13dc890ba8fc7f78723ad67533ec2146aff..5f3c703ea4b0f4651e4f28e682a91382a90a5596 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 14abe13dc890ba8fc7f78723ad67533ec2146aff
+Subproject commit 5f3c703ea4b0f4651e4f28e682a91382a90a5596
index c646ac7c00965d9a117e50a066b777f5691028b9..23b744fa47da73c0b6c5b41b02cfe0efa008ec5c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c646ac7c00965d9a117e50a066b777f5691028b9
+Subproject commit 23b744fa47da73c0b6c5b41b02cfe0efa008ec5c
index 8ed8eb04898e8b310cf484097278d67361412dce..14a15ace67e1cec6990db8ddc61e50efcd202001 100644 (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")
 
 
index 0182f8f6162dd85e66f162138393c0e32a73bdd5..967820565e74565f52207bc0b1be815cd832b82b 100644 (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
index 29892657086b40be105730cd2390bd9879559570..dd052a8256b5dccbbd733f61f41742b1b90771fb 100644 (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
index 29022adac6ce134612bdf640460cc1bef7f549ec..1c317ac458bf1479741836e029ae0b10e6cfaf32 100644 (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,
index 7ada4755a642770d0feb21d13a2009f82c945a14..085ae5bdb93711ac0c9e124ca95b8fb106cc3cf4 100644 (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},
index 7c5d5401d0870ac213ab73eecc6ec165d88b7d1a..ae161f1017cdcaf10c7e85e6e3eff6f654c2028a 100644 (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;
index ca26a56a26e9f5198e9a89d89efb0ba44f75aad6..0aec6d5e6a0a6b40e9bc5245cbf9754a1ec51dab 100644 (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;
index 9e69cd6fda20f1e182103f2690addb4b75cf78b2..6e44c51970dbd48cdbc31e5cd28c76a3d2264ef3 100644 (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;
index 37fee576fde67a060195324a4978201558b7a20f..46abaef48d57b4e4db740e5bc6510ee40f932dbe 100644 (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(