Commit: 48325306d979b3ba246fd0cd95f8ec6f8d76bc7e
Author: Nathan Craddock
Date:   Wed Aug 19 19:35:47 2020 -0600
Branches: master
https://developer.blender.org/rB48325306d979b3ba246fd0cd95f8ec6f8d76bc7e

Cleanup: Outliner active indicator repeated code

Refactor the code to draw the roundrect behind outliner icons for active
elements into a single function.

No functional changes.

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

M       source/blender/editors/space_outliner/outliner_draw.c

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c 
b/source/blender/editors/space_outliner/outliner_draw.c
index 1705b9dd606..cf6a86ba6d7 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2743,6 +2743,23 @@ static void outliner_icon_background_colors(float 
icon_color[4], float icon_bord
   icon_border[3] = 0.2f;
 }
 
+/* Draw a rounded rectangle behind icons of active elements. */
+static void outliner_draw_active_indicator(const float minx,
+                                           const float miny,
+                                           const float maxx,
+                                           const float maxy,
+                                           const float icon_color[4],
+                                           const float icon_border[4])
+{
+  const float ufac = UI_UNIT_X / 20.0f;
+  const float radius = UI_UNIT_Y / 4.0f;
+
+  UI_draw_roundbox_corner_set(UI_CNR_ALL);
+  UI_draw_roundbox_aa(true, minx, miny + ufac, maxx, maxy - ufac, radius, 
icon_color);
+  UI_draw_roundbox_aa(false, minx, miny + ufac, maxx, maxy - ufac, radius, 
icon_border);
+  GPU_blend(GPU_BLEND_ALPHA); /* Roundbox disables. */
+}
+
 static void outliner_draw_iconrow_doit(uiBlock *block,
                                        TreeElement *te,
                                        const uiFontStyle *fstyle,
@@ -2756,31 +2773,19 @@ static void outliner_draw_iconrow_doit(uiBlock *block,
   TreeStoreElem *tselem = TREESTORE(te);
 
   if (active != OL_DRAWSEL_NONE) {
-    float ufac = UI_UNIT_X / 20.0f;
     float icon_color[4], icon_border[4];
     outliner_icon_background_colors(icon_color, icon_border);
     if (active == OL_DRAWSEL_ACTIVE) {
       UI_GetThemeColor4fv(TH_EDITED_OBJECT, icon_color);
       icon_border[3] = 0.3f;
     }
-    UI_draw_roundbox_corner_set(UI_CNR_ALL);
-
-    UI_draw_roundbox_aa(true,
-                        (float)*offsx,
-                        (float)ys + ufac,
-                        (float)*offsx + UI_UNIT_X,
-                        (float)ys + UI_UNIT_Y - ufac,
-                        (float)UI_UNIT_Y / 4.0f,
-                        icon_color);
-    /* border around it */
-    UI_draw_roundbox_aa(false,
-                        (float)*offsx,
-                        (float)ys + ufac,
-                        (float)*offsx + UI_UNIT_X,
-                        (float)ys + UI_UNIT_Y - ufac,
-                        (float)UI_UNIT_Y / 4.0f,
-                        icon_border);
-    GPU_blend(GPU_BLEND_ALPHA); /* Roundbox disables. */
+
+    outliner_draw_active_indicator((float)*offsx,
+                                   (float)ys,
+                                   (float)*offsx + UI_UNIT_X,
+                                   (float)ys + UI_UNIT_Y,
+                                   icon_color,
+                                   icon_border);
   }
 
   if (tselem->flag & TSE_HIGHLIGHTED) {
@@ -3052,23 +3057,12 @@ static void outliner_draw_tree_element(bContext *C,
 
     /* active circle */
     if (active != OL_DRAWSEL_NONE) {
-      UI_draw_roundbox_corner_set(UI_CNR_ALL);
-      UI_draw_roundbox_aa(true,
-                          (float)startx + offsx + UI_UNIT_X,
-                          (float)*starty + ufac,
-                          (float)startx + offsx + 2.0f * UI_UNIT_X,
-                          (float)*starty + UI_UNIT_Y - ufac,
-                          UI_UNIT_Y / 4.0f,
-                          icon_bgcolor);
-      /* border around it */
-      UI_draw_roundbox_aa(false,
-                          (float)startx + offsx + UI_UNIT_X,
-                          (float)*starty + ufac,
-                          (float)startx + offsx + 2.0f * UI_UNIT_X,
-                          (float)*starty + UI_UNIT_Y - ufac,
-                          UI_UNIT_Y / 4.0f,
-                          icon_border);
-      GPU_blend(GPU_BLEND_ALPHA); /* roundbox disables it */
+      outliner_draw_active_indicator((float)startx + offsx + UI_UNIT_X,
+                                     (float)*starty,
+                                     (float)startx + offsx + 2.0f * UI_UNIT_X,
+                                     (float)*starty + UI_UNIT_Y,
+                                     icon_bgcolor,
+                                     icon_border);
 
       te->flag |= TE_ACTIVE; /* For lookup in display hierarchies. */
     }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to