Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_draw.c
| Show First 20 Lines • Show All 2,394 Lines • ▼ Show 20 Lines | UI_fontstyle_draw_simple(&fstyle_small, | ||||
| (offset_x + ufac + UI_UNIT_X * (2 - num_digits) * 0.12f), | (offset_x + ufac + UI_UNIT_X * (2 - num_digits) * 0.12f), | ||||
| (float)ys - UI_UNIT_Y * 0.095f + ufac, | (float)ys - UI_UNIT_Y * 0.095f + ufac, | ||||
| number_text, | number_text, | ||||
| text_col); | text_col); | ||||
| UI_fontstyle_set(fstyle); | UI_fontstyle_set(fstyle); | ||||
| GPU_blend(true); /* Roundbox and text drawing disables. */ | GPU_blend(true); /* Roundbox and text drawing disables. */ | ||||
| } | } | ||||
| static void outliner_icon_background_colors(float icon_color[4], float icon_border[4]) | |||||
| { | |||||
| float text[4]; | |||||
| UI_GetThemeColor4fv(TH_TEXT, text); | |||||
| copy_v3_v3(icon_color, text); | |||||
| icon_color[3] = 0.4f; | |||||
| copy_v3_v3(icon_border, text); | |||||
| icon_border[3] = 0.2f; | |||||
| } | |||||
| static void outliner_draw_iconrow_doit(uiBlock *block, | static void outliner_draw_iconrow_doit(uiBlock *block, | ||||
| 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) | ||||
| { | { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (active != OL_DRAWSEL_NONE) { | if (active != OL_DRAWSEL_NONE) { | ||||
| float ufac = UI_UNIT_X / 20.0f; | float ufac = UI_UNIT_X / 20.0f; | ||||
| float color[4] = {1.0f, 1.0f, 1.0f, 0.2f}; | float icon_color[4], icon_border[4]; | ||||
| outliner_icon_background_colors(icon_color, icon_border); | |||||
| icon_color[3] *= alpha_fac; | |||||
| 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_corner_set(UI_CNR_ALL); | ||||
| color[3] *= alpha_fac; | |||||
| UI_draw_roundbox_aa(true, | UI_draw_roundbox_aa(true, | ||||
| (float)*offsx + 1.0f * ufac, | (float)*offsx, | ||||
| (float)ys + 1.0f * ufac, | (float)ys + ufac, | ||||
| (float)*offsx + UI_UNIT_X - 1.0f * ufac, | (float)*offsx + UI_UNIT_X, | ||||
| (float)ys + UI_UNIT_Y - ufac, | (float)ys + UI_UNIT_Y - ufac, | ||||
| (float)UI_UNIT_Y / 2.0f - ufac, | (float)UI_UNIT_Y / 4.0f, | ||||
| color); | 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(true); /* Roundbox disables. */ | GPU_blend(true); /* Roundbox disables. */ | ||||
| } | } | ||||
| /* No inlined icon should be clickable. */ | 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, 0.8f * 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(fstyle, *offsx, ys, num_elements); | ||||
| } | } | ||||
| (*offsx) += UI_UNIT_X; | (*offsx) += UI_UNIT_X; | ||||
| Show All 37 Lines | static void outliner_draw_iconrow(bContext *C, | ||||
| 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) | ||||
| { | { | ||||
| eOLDrawState active; | eOLDrawState active = OL_DRAWSEL_NONE; | ||||
| const Object *obact = OBACT(view_layer); | const Object *obact = OBACT(view_layer); | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | for (TreeElement *te = lb->first; te; te = te->next) { | ||||
| /* exit drawing early */ | /* exit drawing early */ | ||||
| if ((*offsx) - UI_UNIT_X > xmax) { | if ((*offsx) - UI_UNIT_X > xmax) { | ||||
| break; | break; | ||||
| } | } | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| /* object hierarchy always, further constrained on level */ | /* object hierarchy always, further constrained on level */ | ||||
| if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { | if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { | ||||
| /* active blocks get white circle */ | /* active blocks get white circle */ | ||||
| if (tselem->type == 0) { | if (tselem->type == 0) { | ||||
| if (te->idcode == ID_OB) { | if (te->idcode == ID_OB) { | ||||
| active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : | active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : | ||||
| OL_DRAWSEL_NONE; | OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| else if (is_object_data_in_editmode(tselem->id, obact)) { | else if (is_object_data_in_editmode(tselem->id, obact)) { | ||||
| active = OL_DRAWSEL_NORMAL; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
| else { | else { | ||||
| active = tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false); | active = tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| active = tree_element_type_active( | active = tree_element_type_active( | ||||
| C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static void outliner_draw_tree_element(bContext *C, | ||||
| SpaceOutliner *soops, | SpaceOutliner *soops, | ||||
| TreeElement *te, | TreeElement *te, | ||||
| bool draw_grayed_out, | bool draw_grayed_out, | ||||
| int startx, | int startx, | ||||
| int *starty, | int *starty, | ||||
| const float restrict_column_width, | const float restrict_column_width, | ||||
| TreeElement **te_edit) | TreeElement **te_edit) | ||||
| { | { | ||||
| TreeStoreElem *tselem; | TreeStoreElem *tselem = TREESTORE(te); | ||||
| float ufac = UI_UNIT_X / 20.0f; | float ufac = UI_UNIT_X / 20.0f; | ||||
| int offsx = 0; | int offsx = 0; | ||||
| eOLDrawState active = OL_DRAWSEL_NONE; | eOLDrawState active = OL_DRAWSEL_NONE; | ||||
| float color[4]; | unsigned char text_color[4]; | ||||
| tselem = TREESTORE(te); | UI_GetThemeColor4ubv(TH_TEXT, text_color); | ||||
| float icon_bgcolor[4], icon_border[4]; | |||||
| outliner_icon_background_colors(icon_bgcolor, icon_border); | |||||
| if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { | if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { | ||||
| const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) || | const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) || | ||||
| draw_grayed_out) ? | draw_grayed_out) ? | ||||
| 0.5f : | 0.5f : | ||||
| 1.0f; | 1.0f; | ||||
| const float alpha = 0.5f * alpha_fac; | |||||
| int xmax = ar->v2d.cur.xmax; | int xmax = ar->v2d.cur.xmax; | ||||
| if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) { | if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) { | ||||
| *te_edit = te; | *te_edit = te; | ||||
| } | } | ||||
| /* icons can be ui buts, we don't want it to overlap with restrict */ | /* icons can be ui buts, we don't want it to overlap with restrict */ | ||||
| if (restrict_column_width > 0) { | if (restrict_column_width > 0) { | ||||
| xmax -= restrict_column_width + UI_UNIT_X; | xmax -= restrict_column_width + UI_UNIT_X; | ||||
| } | } | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| /* colors for active/selected data */ | /* colors for active/selected data */ | ||||
| if (tselem->type == 0) { | if (tselem->type == 0) { | ||||
| const Object *obact = OBACT(view_layer); | const Object *obact = OBACT(view_layer); | ||||
| if (te->idcode == ID_SCE) { | if (te->idcode == ID_SCE) { | ||||
| if (tselem->id == (ID *)scene) { | if (tselem->id == (ID *)scene) { | ||||
| rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha); | /* active scene */ | ||||
| icon_bgcolor[3] = 0.2f; | |||||
| active = OL_DRAWSEL_ACTIVE; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
| } | } | ||||
| else if (te->idcode == ID_OB) { | else if (te->idcode == ID_OB) { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| Base *base = (te->directdata) ? (Base *)te->directdata : | Base *base = (te->directdata) ? (Base *)te->directdata : | ||||
| BKE_view_layer_base_find(view_layer, ob); | BKE_view_layer_base_find(view_layer, ob); | ||||
| const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0); | const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0); | ||||
| if (ob == obact || is_selected) { | if (ob == obact || is_selected) { | ||||
| uchar col[4] = {0, 0, 0, 0}; | |||||
| /* outliner active ob: always white text, circle color now similar to view3d */ | |||||
| active = OL_DRAWSEL_ACTIVE; | |||||
| if (ob == obact) { | if (ob == obact) { | ||||
| if (is_selected) { | /* active selected object */ | ||||
| UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); | UI_GetThemeColor3ubv(TH_ACTIVE_OBJECT, text_color); | ||||
| col[3] = alpha; | text_color[3] = 255; | ||||
| } | |||||
| active = OL_DRAWSEL_NORMAL; | |||||
| } | } | ||||
| else if (is_selected) { | else { | ||||
| UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); | /* other selected objects */ | ||||
| col[3] = alpha; | UI_GetThemeColor3ubv(TH_SELECTED_OBJECT, text_color); | ||||
| text_color[3] = 255; | |||||
| } | } | ||||
| rgba_float_args_set( | |||||
| color, (float)col[0] / 255, (float)col[1] / 255, (float)col[2] / 255, alpha); | |||||
| } | } | ||||
| } | } | ||||
| else if (is_object_data_in_editmode(tselem->id, obact)) { | else if (is_object_data_in_editmode(tselem->id, obact)) { | ||||
| rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha); | /* objects being edited */ | ||||
| UI_GetThemeColor4fv(TH_EDITED_OBJECT, icon_bgcolor); | |||||
| icon_border[3] = 0.3f; | |||||
| active = OL_DRAWSEL_ACTIVE; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
| else { | else { | ||||
| if (tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false)) { | if (tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false)) { | ||||
| rgba_float_args_set(color, 0.85f, 0.85f, 1.0f, alpha); | /* active items like camera or material */ | ||||
| icon_bgcolor[3] = 0.2f; | |||||
| active = OL_DRAWSEL_ACTIVE; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| active = tree_element_type_active( | active = tree_element_type_active( | ||||
| C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | ||||
| rgba_float_args_set(color, 0.85f, 0.85f, 1.0f, alpha); | /* active collection*/ | ||||
| icon_bgcolor[3] = 0.2f; | |||||
| } | } | ||||
| /* Checkbox to enable collections. */ | /* Checkbox to enable collections. */ | ||||
| if ((tselem->type == TSE_LAYER_COLLECTION) && | if ((tselem->type == TSE_LAYER_COLLECTION) && | ||||
| (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) { | (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) { | ||||
| tselem_draw_layer_collection_enable_icon( | tselem_draw_layer_collection_enable_icon( | ||||
| scene, block, xmax, (float)startx + offsx + UI_UNIT_X, (float)*starty, te, 0.8f); | scene, block, xmax, (float)startx + offsx + UI_UNIT_X, (float)*starty, te, 0.8f); | ||||
| offsx += UI_UNIT_X; | offsx += UI_UNIT_X; | ||||
| } | } | ||||
| /* active circle */ | /* active circle */ | ||||
| if (active != OL_DRAWSEL_NONE) { | if (active != OL_DRAWSEL_NONE) { | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_aa(true, | UI_draw_roundbox_aa(true, | ||||
| (float)startx + offsx + UI_UNIT_X + 1.0f * ufac, | (float)startx + offsx + UI_UNIT_X, | ||||
| (float)*starty + 1.0f * ufac, | (float)*starty + ufac, | ||||
| (float)startx + offsx + 2.0f * UI_UNIT_X - 1.0f * ufac, | (float)startx + offsx + 2.0f * UI_UNIT_X, | ||||
| (float)*starty + UI_UNIT_Y - 1.0f * ufac, | (float)*starty + UI_UNIT_Y - ufac, | ||||
| UI_UNIT_Y / 2.0f - 1.0f * ufac, | UI_UNIT_Y / 4.0f, | ||||
| color); | 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(true); /* roundbox disables it */ | GPU_blend(true); /* roundbox disables it */ | ||||
| te->flag |= TE_ACTIVE; // for lookup in display hierarchies | te->flag |= TE_ACTIVE; // for lookup in display hierarchies | ||||
| } | } | ||||
| if (tselem->type == TSE_VIEW_COLLECTION_BASE) { | if (tselem->type == TSE_VIEW_COLLECTION_BASE) { | ||||
| /* Scene collection in view layer can't expand/collapse. */ | /* Scene collection in view layer can't expand/collapse. */ | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | else if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_STATIC_OVERRIDE(tselem->id)) { | ||||
| ICON_LIBRARY_DATA_OVERRIDE, | ICON_LIBRARY_DATA_OVERRIDE, | ||||
| alpha_fac); | alpha_fac); | ||||
| offsx += UI_UNIT_X + 4 * ufac; | offsx += UI_UNIT_X + 4 * ufac; | ||||
| } | } | ||||
| GPU_blend(false); | GPU_blend(false); | ||||
| /* name */ | /* name */ | ||||
| if ((tselem->flag & TSE_TEXTBUT) == 0) { | if ((tselem->flag & TSE_TEXTBUT) == 0) { | ||||
| unsigned char text_col[4]; | if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { | ||||
| UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.75f, text_color); | |||||
| if (active == OL_DRAWSEL_NORMAL) { | text_color[3] = 255; | ||||
| UI_GetThemeColor4ubv(TH_TEXT_HI, text_col); | |||||
| } | |||||
| else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { | |||||
| UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.75f, text_col); | |||||
| text_col[3] = 255; | |||||
| } | } | ||||
| else { | text_color[3] *= alpha_fac; | ||||
| UI_GetThemeColor4ubv(TH_TEXT, text_col); | UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name, text_color); | ||||
| } | |||||
| text_col[3] *= alpha_fac; | |||||
| UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name, text_col); | |||||
| } | } | ||||
| offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); | offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); | ||||
| /* closed item, we draw the icons, not when it's a scene, or master-server list though */ | /* closed item, we draw the icons, not when it's a scene, or master-server list though */ | ||||
| if (!TSELEM_OPEN(tselem, soops)) { | if (!TSELEM_OPEN(tselem, soops)) { | ||||
| if (te->subtree.first) { | if (te->subtree.first) { | ||||
| if (tselem->type == 0 && te->idcode == ID_SCE) { | if (tselem->type == 0 && te->idcode == ID_SCE) { | ||||
| ▲ Show 20 Lines • Show All 528 Lines • Show Last 20 Lines | |||||