[Bf-blender-cvs] [5289b16d775] master: UI: File Browser Preview Outlines

Harley Acheson noreply at git.blender.org
Fri Sep 6 19:03:32 CEST 2019


Commit: 5289b16d775d3bddd2815f24d56a5eccc53f0c75
Author: Harley Acheson
Date:   Fri Sep 6 10:02:18 2019 -0700
Branches: master
https://developer.blender.org/rB5289b16d775d3bddd2815f24d56a5eccc53f0c75

UI: File Browser Preview Outlines

File Browser image thumbnails get just a contrasting outline and no shadow.

Differential Revision: https://developer.blender.org/D5708

Reviewed by Brecht Van Lommel

===================================================================

M	source/blender/editors/space_file/file_draw.c

===================================================================

diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 3e16a8473ad..e11ca06494d 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -223,7 +223,7 @@ static void file_draw_preview(uiBlock *block,
   float scaledx, scaledy;
   float scale;
   int ex, ey;
-  bool use_dropshadow = !is_icon &&
+  bool show_outline = !is_icon &&
                         (typeflags & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_BLENDER));
 
   BLI_assert(imb != NULL);
@@ -259,11 +259,6 @@ static void file_draw_preview(uiBlock *block,
   xco = sx + (int)dx;
   yco = sy - layout->prv_h + (int)dy;
 
-  /* shadow */
-  if (use_dropshadow) {
-    UI_draw_box_shadow(128, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
-  }
-
   GPU_blend(true);
 
   /* the large image */
@@ -344,23 +339,21 @@ static void file_draw_preview(uiBlock *block,
     }
   }
 
-  /* border */
-  if (use_dropshadow) {
+  /* Contrasting outline around some preview types. */
+  if (show_outline) {
     GPUVertFormat *format = immVertexFormat();
-    uint pos_attr = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-    uint col_attr = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
-
-    immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-    immBegin(GPU_PRIM_LINE_LOOP, 4);
-    immAttr4f(col_attr, 1.0f, 1.0f, 1.0f, 0.15f);
-    immVertex2f(pos_attr, (float)xco + 1, (float)(yco + ey));
-    immAttr4f(col_attr, 1.0f, 1.0f, 1.0f, 0.2f);
-    immVertex2f(pos_attr, (float)(xco + ex), (float)(yco + ey));
-    immAttr4f(col_attr, 0.0f, 0.0f, 0.0f, 0.2f);
-    immVertex2f(pos_attr, (float)(xco + ex), (float)yco + 1);
-    immAttr4f(col_attr, 0.0f, 0.0f, 0.0f, 0.3f);
-    immVertex2f(pos_attr, (float)xco + 1, (float)yco + 1);
-    immEnd();
+    uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+    immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+    float border_color[4] = {1.0f, 1.0f, 1.0f, 0.4f};
+    float bgcolor[4];
+    UI_GetThemeColor4fv(TH_BACK, bgcolor);
+    if (rgb_to_grayscale(bgcolor) > 0.5f) {
+      border_color[0] = 0.0f;
+      border_color[1] = 0.0f;
+      border_color[2] = 0.0f;
+    }
+    immUniformColor4fv(border_color);
+    imm_draw_box_wire_2d(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
     immUnbindProgram();
   }



More information about the Bf-blender-cvs mailing list