Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Craddock <nzcraddock@gmail.com>2020-08-20 04:35:47 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-08-20 04:35:47 +0300
commit48325306d979b3ba246fd0cd95f8ec6f8d76bc7e (patch)
tree03b8898bca86680c4aa564501e73dee2caa071af /source/blender/editors/space_outliner/outliner_draw.c
parent940b239ad47385d121d7864ea99c27eddb8df9fc (diff)
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.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c66
1 files changed, 30 insertions, 36 deletions
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. */
}