Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_draw.cc
| Show First 20 Lines • Show All 2,935 Lines • ▼ Show 20 Lines | uiDefIconBut(block, | ||||
| 1.0, | 1.0, | ||||
| alpha, | alpha, | ||||
| (data.drag_id && ID_IS_LINKED(data.drag_id)) ? data.drag_id->lib->filepath : ""); | (data.drag_id && ID_IS_LINKED(data.drag_id)) ? data.drag_id->lib->filepath : ""); | ||||
| } | } | ||||
| return true; | 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, | * For icon-only children of a collapsed tree, | ||||
| * Draw small number over the icon to show how many items of this type are displayed. | * 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 offsx, | ||||
| int ys, | int ys, | ||||
| const TreeElement *te_parent, | |||||
| const int num_elements) | 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_parent, ys, color); | |||||
| float ufac = 0.25f * UI_UNIT_X; | float ufac = 0.25f * UI_UNIT_X; | ||||
| float offset_x = float(offsx) + UI_UNIT_X * 0.35f; | float offset_x = float(offsx) + UI_UNIT_X * 0.35f; | ||||
| rctf rect{}; | rctf rect{}; | ||||
| BLI_rctf_init(&rect, | BLI_rctf_init(&rect, | ||||
| offset_x + ufac, | offset_x + ufac, | ||||
| offset_x + UI_UNIT_X - ufac, | offset_x + UI_UNIT_X - ufac, | ||||
| float(ys) - UI_UNIT_Y * 0.2f + ufac, | float(ys) - UI_UNIT_Y * 0.2f + ufac, | ||||
| float(ys) - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac); | float(ys) - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | 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. */ | /* Now the numbers. */ | ||||
| uchar text_col[4]; | uchar text_col[4]; | ||||
| UI_GetThemeColor3ubv(TH_TEXT_HI, text_col); | UI_GetThemeColor3ubv(TH_TEXT, text_col); | ||||
| text_col[3] = 255; | text_col[3] = 255; | ||||
| uiFontStyle fstyle_small = *fstyle; | uiFontStyle fstyle_small = *fstyle; | ||||
| fstyle_small.points *= 0.8f; | fstyle_small.points *= 0.8f; | ||||
| /* We treat +99 as 4 digits to make sure the (eyeballed) alignment looks nice. */ | /* We treat +99 as 4 digits to make sure the (eyeballed) alignment looks nice. */ | ||||
| int num_digits = 4; | int num_digits = 4; | ||||
| char number_text[4] = "+99"; | char number_text[4] = "+99"; | ||||
| Show All 35 Lines | static void outliner_draw_active_indicator(const float minx, | ||||
| BLI_rctf_init(&rect, minx, maxx, miny + ufac, maxy - ufac); | BLI_rctf_init(&rect, minx, maxx, miny + ufac, maxy - ufac); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_aa(&rect, true, radius, icon_color); | UI_draw_roundbox_aa(&rect, true, radius, icon_color); | ||||
| UI_draw_roundbox_aa(&rect, false, radius, icon_border); | UI_draw_roundbox_aa(&rect, false, radius, icon_border); | ||||
| GPU_blend(GPU_BLEND_ALPHA); /* Round-box disables. */ | 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_parent, | |||||
| TreeElement *te, | TreeElement *te, | ||||
| const uiFontStyle *fstyle, | const uiFontStyle *fstyle, | ||||
| int xmax, | int xmax, | ||||
| int *offsx, | int *offsx, | ||||
| int ys, | int ys, | ||||
| float alpha_fac, | float alpha_fac, | ||||
| const eOLDrawState active, | const eOLDrawState active, | ||||
| const int num_elements) | const int num_elements) | ||||
| Show All 20 Lines | if (tselem->flag & TSE_HIGHLIGHTED_ICON) { | ||||
| alpha_fac += 0.5; | alpha_fac += 0.5; | ||||
| } | } | ||||
| tselem_draw_icon(block, xmax, float(*offsx), float(ys), tselem, te, alpha_fac, false); | tselem_draw_icon(block, xmax, float(*offsx), float(ys), tselem, te, alpha_fac, false); | ||||
| te->xs = *offsx; | te->xs = *offsx; | ||||
| te->ys = ys; | te->ys = ys; | ||||
| te->xend = short(*offsx) + UI_UNIT_X; | te->xend = short(*offsx) + UI_UNIT_X; | ||||
| if (num_elements > 1) { | if (num_elements > 1) { | ||||
| outliner_draw_iconrow_number(fstyle, *offsx, ys, num_elements); | outliner_draw_iconrow_number(region, fstyle, *offsx, ys, te_parent, num_elements); | ||||
| te->flag |= TE_ICONROW_MERGED; | te->flag |= TE_ICONROW_MERGED; | ||||
| } | } | ||||
| else { | else { | ||||
| te->flag |= TE_ICONROW; | te->flag |= TE_ICONROW; | ||||
| } | } | ||||
| (*offsx) += UI_UNIT_X; | (*offsx) += UI_UNIT_X; | ||||
| } | } | ||||
| Show All 20 Lines | struct MergedIconRow { | ||||
| TreeElement *tree_element[INDEX_ID_MAX + OB_TYPE_MAX]; | TreeElement *tree_element[INDEX_ID_MAX + OB_TYPE_MAX]; | ||||
| }; | }; | ||||
| static void outliner_draw_iconrow(bContext *C, | static void outliner_draw_iconrow(bContext *C, | ||||
| uiBlock *block, | uiBlock *block, | ||||
| const uiFontStyle *fstyle, | const uiFontStyle *fstyle, | ||||
| const TreeViewContext *tvc, | const TreeViewContext *tvc, | ||||
| SpaceOutliner *space_outliner, | SpaceOutliner *space_outliner, | ||||
| TreeElement *te_parent, | |||||
| ListBase *lb, | ListBase *lb, | ||||
| int level, | int level, | ||||
| int xmax, | int xmax, | ||||
| int *offsx, | int *offsx, | ||||
| int ys, | int ys, | ||||
| float alpha_fac, | float alpha_fac, | ||||
| MergedIconRow *merged) | MergedIconRow *merged) | ||||
| { | { | ||||
| const ARegion *region = CTX_wm_region(C); | |||||
| eOLDrawState active = OL_DRAWSEL_NONE; | eOLDrawState active = OL_DRAWSEL_NONE; | ||||
| LISTBASE_FOREACH (TreeElement *, te, lb) { | LISTBASE_FOREACH (TreeElement *, te, lb) { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| te->flag &= ~(TE_ICONROW | TE_ICONROW_MERGED); | te->flag &= ~(TE_ICONROW | TE_ICONROW_MERGED); | ||||
| /* object hierarchy always, further constrained on level */ | /* object hierarchy always, further constrained on level */ | ||||
| if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) || | if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) || | ||||
| Show All 23 Lines | if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) || | ||||
| TSE_LIBRARY_OVERRIDE_BASE, | TSE_LIBRARY_OVERRIDE_BASE, | ||||
| TSE_LIBRARY_OVERRIDE, | TSE_LIBRARY_OVERRIDE, | ||||
| TSE_LIBRARY_OVERRIDE_OPERATION, | TSE_LIBRARY_OVERRIDE_OPERATION, | ||||
| TSE_BONE, | TSE_BONE, | ||||
| TSE_EBONE, | TSE_EBONE, | ||||
| TSE_POSE_CHANNEL, | TSE_POSE_CHANNEL, | ||||
| TSE_POSEGRP, | TSE_POSEGRP, | ||||
| TSE_DEFGROUP)) { | TSE_DEFGROUP)) { | ||||
| outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1); | outliner_draw_iconrow_doit( | ||||
| region, block, te_parent, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1); | |||||
| } | } | ||||
| else { | else { | ||||
| const int index = tree_element_id_type_to_index(te); | const int index = tree_element_id_type_to_index(te); | ||||
| merged->num_elements[index]++; | merged->num_elements[index]++; | ||||
| if ((merged->tree_element[index] == nullptr) || (active > merged->active[index])) { | if ((merged->tree_element[index] == nullptr) || (active > merged->active[index])) { | ||||
| merged->tree_element[index] = te; | merged->tree_element[index] = te; | ||||
| } | } | ||||
| merged->active[index] = MAX2(active, merged->active[index]); | merged->active[index] = MAX2(active, merged->active[index]); | ||||
| } | } | ||||
| } | } | ||||
| /* this tree element always has same amount of branches, so don't draw */ | /* this tree element always has same amount of branches, so don't draw */ | ||||
| if (tselem->type != TSE_R_LAYER) { | if (tselem->type != TSE_R_LAYER) { | ||||
| outliner_draw_iconrow(C, | outliner_draw_iconrow(C, | ||||
| block, | block, | ||||
| fstyle, | fstyle, | ||||
| tvc, | tvc, | ||||
| space_outliner, | space_outliner, | ||||
| te, | |||||
| &te->subtree, | &te->subtree, | ||||
| level + 1, | level + 1, | ||||
| xmax, | xmax, | ||||
| offsx, | offsx, | ||||
| ys, | ys, | ||||
| alpha_fac, | alpha_fac, | ||||
| merged); | merged); | ||||
| } | } | ||||
| } | } | ||||
| if (level == 0) { | if (level == 0) { | ||||
| for (int i = 0; i < INDEX_ID_MAX; i++) { | for (int i = 0; i < INDEX_ID_MAX; i++) { | ||||
| const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; | const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; | ||||
| /* See tree_element_id_type_to_index for the index logic. */ | /* See tree_element_id_type_to_index for the index logic. */ | ||||
| int index_base = i; | int index_base = i; | ||||
| if (i > INDEX_ID_OB) { | if (i > INDEX_ID_OB) { | ||||
| index_base += OB_TYPE_MAX; | index_base += OB_TYPE_MAX; | ||||
| } | } | ||||
| for (int j = 0; j < num_subtypes; j++) { | for (int j = 0; j < num_subtypes; j++) { | ||||
| const int index = index_base + j; | const int index = index_base + j; | ||||
| if (merged->num_elements[index] != 0) { | if (merged->num_elements[index] != 0) { | ||||
| outliner_draw_iconrow_doit(block, | outliner_draw_iconrow_doit(region, | ||||
| block, | |||||
| te_parent, | |||||
| merged->tree_element[index], | merged->tree_element[index], | ||||
| fstyle, | fstyle, | ||||
| xmax, | xmax, | ||||
| offsx, | offsx, | ||||
| ys, | ys, | ||||
| alpha_fac, | alpha_fac, | ||||
| merged->active[index], | merged->active[index], | ||||
| merged->num_elements[index]); | merged->num_elements[index]); | ||||
| ▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | if (!TSELEM_OPEN(tselem, space_outliner)) { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| MergedIconRow merged{}; | MergedIconRow merged{}; | ||||
| outliner_draw_iconrow(C, | outliner_draw_iconrow(C, | ||||
| block, | block, | ||||
| fstyle, | fstyle, | ||||
| tvc, | tvc, | ||||
| space_outliner, | space_outliner, | ||||
| te, | |||||
| &te->subtree, | &te->subtree, | ||||
| 0, | 0, | ||||
| xmax, | xmax, | ||||
| &tempx, | &tempx, | ||||
| *starty, | *starty, | ||||
| alpha_fac, | alpha_fac, | ||||
| &merged); | &merged); | ||||
| ▲ Show 20 Lines • Show All 574 Lines • Show Last 20 Lines | |||||