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:
authorDalai Felinto <dalai@blender.org>2022-10-13 21:00:40 +0300
committerDalai Felinto <dalai@blender.org>2022-10-13 21:05:28 +0300
commita5d3b648e3e2d68c99d6f7d9dad466ff4e302f34 (patch)
tree061c1123b87a7283a502f26162e25b28bcde9260 /source/blender/editors/space_outliner/outliner_draw.cc
parent6f190c669f3001f73e9051fc66e4d233957391c4 (diff)
Outliner: Use row background color for elements count indicator
From T101799: Currently, the count indicator background and color are hardcoded to black and white in an attempt to maximize contrast, at the expense of being too prominent even when not needed. Changing the background color to match the row (or any other element) background, would make it look like the data-block icon is masked out, improving readability while not standing out too much. The circle background color should not have transparency, as it does now. And the text inside should match the color of the text used for the parent element (instead of hardcoded white). This should make it look good in any theme. --- Before: {F13674265, size=full} After: {F13674269, size=full} Differential Revision: https://developer.blender.org/D16246
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.cc')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.cc76
1 files changed, 68 insertions, 8 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index 8a1119d5e66..34d1e1bb546 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -2941,16 +2941,66 @@ static bool tselem_draw_icon(uiBlock *block,
return true;
}
+static bool outliner_is_main_row(const ARegion *region, const int ys)
+{
+ int ystart;
+
+ ystart = int(region->v2d.tot.ymax);
+ ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET;
+
+ return ((ys - ystart) / UI_UNIT_Y) % 2;
+}
+
+/**
+ * Get the expected row background color to use for the data-block counter
+ *
+ * This reproduces somes of the logic of outliner_draw_highlights.
+ * At the moment it doesn't implement the search match color since
+ * we don't draw the data-block counter in those cases.
+ */
+static void outliner_get_row_color(const ARegion *region,
+ const TreeElement *te,
+ int ys,
+ float r_color[4])
+{
+ const TreeStoreElem *tselem = TREESTORE(te);
+
+ if ((tselem->flag & TSE_ACTIVE) && (tselem->flag & TSE_SELECTED)) {
+ UI_GetThemeColor3fv(TH_ACTIVE, r_color);
+ }
+ else if (tselem->flag & TSE_SELECTED) {
+ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, r_color);
+ }
+ else if (outliner_is_main_row(region, ys)) {
+ UI_GetThemeColor3fv(TH_BACK, r_color);
+ }
+ else {
+ float color_alternating[4];
+ UI_GetThemeColor4fv(TH_ROW_ALTERNATE, color_alternating);
+ UI_GetThemeColorBlend3f(TH_BACK, TH_ROW_ALTERNATE, color_alternating[3], r_color);
+ }
+
+ if (tselem->flag & TSE_HIGHLIGHTED) {
+ const float color_highlight[4] = {1.0f, 1.0f, 1.0f, 0.13f};
+ interp_v3_v3v3(r_color, r_color, color_highlight, color_highlight[3]);
+ }
+ r_color[3] = 1.0f;
+}
+
/**
* For icon-only children of a collapsed tree,
* Draw small number over the icon to show how many items of this type are displayed.
*/
-static void outliner_draw_iconrow_number(const uiFontStyle *fstyle,
+static void outliner_draw_iconrow_number(const ARegion *region,
+ const uiFontStyle *fstyle,
int offsx,
int ys,
+ const TreeElement *te_visible,
const int num_elements)
{
- const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float color[4];
+ outliner_get_row_color(region, te_visible, ys, color);
+
float ufac = 0.25f * UI_UNIT_X;
float offset_x = float(offsx) + UI_UNIT_X * 0.35f;
rctf rect{};
@@ -2961,12 +3011,13 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle,
float(ys) - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_aa(&rect, true, float(UI_UNIT_Y) / 2.0f - ufac, color);
+ UI_draw_roundbox_4fv_ex(
+ &rect, color, NULL, 1.0f, color, U.pixelsize, float(UI_UNIT_Y) / 2.0f - ufac);
/* Now the numbers. */
uchar text_col[4];
- UI_GetThemeColor3ubv(TH_TEXT_HI, text_col);
+ UI_GetThemeColor3ubv(TH_TEXT, text_col);
text_col[3] = 255;
uiFontStyle fstyle_small = *fstyle;
@@ -3018,7 +3069,9 @@ static void outliner_draw_active_indicator(const float minx,
GPU_blend(GPU_BLEND_ALPHA); /* Round-box disables. */
}
-static void outliner_draw_iconrow_doit(uiBlock *block,
+static void outliner_draw_iconrow_doit(const ARegion *region,
+ uiBlock *block,
+ TreeElement *te_visible,
TreeElement *te,
const uiFontStyle *fstyle,
int xmax,
@@ -3055,7 +3108,7 @@ static void outliner_draw_iconrow_doit(uiBlock *block,
te->xend = short(*offsx) + UI_UNIT_X;
if (num_elements > 1) {
- outliner_draw_iconrow_number(fstyle, *offsx, ys, num_elements);
+ outliner_draw_iconrow_number(region, fstyle, *offsx, ys, te_visible, num_elements);
te->flag |= TE_ICONROW_MERGED;
}
else {
@@ -3092,6 +3145,7 @@ static void outliner_draw_iconrow(bContext *C,
const uiFontStyle *fstyle,
const TreeViewContext *tvc,
SpaceOutliner *space_outliner,
+ TreeElement *te_visible,
ListBase *lb,
int level,
int xmax,
@@ -3100,6 +3154,7 @@ static void outliner_draw_iconrow(bContext *C,
float alpha_fac,
MergedIconRow *merged)
{
+ const ARegion *region = CTX_wm_region(C);
eOLDrawState active = OL_DRAWSEL_NONE;
LISTBASE_FOREACH (TreeElement *, te, lb) {
@@ -3139,7 +3194,8 @@ static void outliner_draw_iconrow(bContext *C,
TSE_POSE_CHANNEL,
TSE_POSEGRP,
TSE_DEFGROUP)) {
- outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1);
+ outliner_draw_iconrow_doit(
+ region, block, te_visible, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1);
}
else {
const int index = tree_element_id_type_to_index(te);
@@ -3158,6 +3214,7 @@ static void outliner_draw_iconrow(bContext *C,
fstyle,
tvc,
space_outliner,
+ te,
&te->subtree,
level + 1,
xmax,
@@ -3179,7 +3236,9 @@ static void outliner_draw_iconrow(bContext *C,
for (int j = 0; j < num_subtypes; j++) {
const int index = index_base + j;
if (merged->num_elements[index] != 0) {
- outliner_draw_iconrow_doit(block,
+ outliner_draw_iconrow_doit(region,
+ block,
+ te_visible,
merged->tree_element[index],
fstyle,
xmax,
@@ -3419,6 +3478,7 @@ static void outliner_draw_tree_element(bContext *C,
fstyle,
tvc,
space_outliner,
+ te,
&te->subtree,
0,
xmax,