Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_draw.c
| Show First 20 Lines • Show All 621 Lines • ▼ Show 20 Lines | if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| TIP_("Use view layer for rendering")); | TIP_("Use view layer for rendering")); | ||||
| UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); | UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); | ||||
| UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); | UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); | ||||
| UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE); | UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE); | ||||
| } | } | ||||
| else if ((tselem->type == 0 && te->idcode == ID_OB) && | |||||
| (te->flag & TE_CHILD_NOT_IN_COLLECTION)) { | |||||
| /* Don't show restrict columns for children that are not directly inside the collection. */ | |||||
| } | |||||
| else if (tselem->type == 0 && te->idcode == ID_OB) { | else if (tselem->type == 0 && te->idcode == ID_OB) { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| RNA_pointer_create(&ob->id, &RNA_Object, ob, &ptr); | RNA_pointer_create(&ob->id, &RNA_Object, ob, &ptr); | ||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | Base *base = BKE_view_layer_base_find(view_layer, ob); | ||||
| if (base) { | if (base) { | ||||
| int icon = ICON_RESTRICT_VIEW_ON; | int icon = ICON_RESTRICT_VIEW_ON; | ||||
| ▲ Show 20 Lines • Show All 1,430 Lines • ▼ Show 20 Lines | static void outliner_draw_tree_element(bContext *C, | ||||
| TreeStoreElem *tselem; | TreeStoreElem *tselem; | ||||
| 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]; | float color[4]; | ||||
| tselem = TREESTORE(te); | tselem = TREESTORE(te); | ||||
| 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) || draw_grayed_out) ? 0.5f : 1.0f; | const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) || | ||||
| draw_grayed_out) ? | |||||
| 0.5f : | |||||
| 1.0f; | |||||
| const float alpha = 0.5f * alpha_fac; | 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 */ | ||||
| ▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | |||||
| static void outliner_draw_hierarchy_lines_recursive(unsigned pos, | static void outliner_draw_hierarchy_lines_recursive(unsigned pos, | ||||
| SpaceOutliner *soops, | SpaceOutliner *soops, | ||||
| ListBase *lb, | ListBase *lb, | ||||
| int startx, | int startx, | ||||
| const unsigned char col[4], | const unsigned char col[4], | ||||
| bool draw_grayed_out, | bool draw_grayed_out, | ||||
| int *starty) | int *starty) | ||||
| { | { | ||||
| TreeElement *te, *te_vertical_line_last = NULL; | TreeElement *te, *te_vertical_line_last = NULL, *te_vertical_line_last_dashed = NULL; | ||||
| int y1, y2; | int y1, y2, y1_dashed, y2_dashed; | ||||
| if (BLI_listbase_is_empty(lb)) { | if (BLI_listbase_is_empty(lb)) { | ||||
| return; | return; | ||||
| } | } | ||||
| struct { | |||||
| int steps_num; | |||||
| int step_len; | |||||
| int gap_len; | |||||
| } dash = { | |||||
| .steps_num = 4, | |||||
| }; | |||||
| dash.step_len = UI_UNIT_X / dash.steps_num; | |||||
| dash.gap_len = dash.step_len / 2; | |||||
| const unsigned char grayed_alpha = col[3] / 2; | const unsigned char grayed_alpha = col[3] / 2; | ||||
| /* For vertical lines between objects. */ | /* For vertical lines between objects. */ | ||||
| y1 = y2 = *starty; | y1 = y2 = y1_dashed = y2_dashed = *starty; | ||||
| for (te = lb->first; te; te = te->next) { | for (te = lb->first; te; te = te->next) { | ||||
| bool draw_childs_grayed_out = draw_grayed_out || (te->flag & TE_DRAGGING); | bool draw_childs_grayed_out = draw_grayed_out || (te->flag & TE_DRAGGING) || | ||||
| (te->flag & TE_CHILD_NOT_IN_COLLECTION); | |||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (draw_childs_grayed_out) { | if (draw_childs_grayed_out) { | ||||
| immUniformColor3ubvAlpha(col, grayed_alpha); | immUniformColor3ubvAlpha(col, grayed_alpha); | ||||
| } | } | ||||
| else { | else { | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| } | } | ||||
| if ((te->flag & TE_CHILD_NOT_IN_COLLECTION) == 0) { | |||||
| /* Horizontal Line? */ | /* Horizontal Line? */ | ||||
| if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) { | if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) { | ||||
| immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - 1); | immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - 1); | ||||
| /* Vertical Line? */ | /* Vertical Line? */ | ||||
| if (te->idcode == ID_OB) { | if (te->idcode == ID_OB) { | ||||
| te_vertical_line_last = te; | te_vertical_line_last = te; | ||||
| y2 = *starty; | y2 = *starty; | ||||
| } | } | ||||
| y1_dashed = *starty - UI_UNIT_Y; | |||||
| } | |||||
| } | |||||
| else { | |||||
| BLI_assert(te->idcode == ID_OB); | |||||
| /* Horizontal line - dashed. */ | |||||
| int start = startx; | |||||
| for (int i = 0; i < dash.steps_num; i++) { | |||||
| immRecti(pos, start, *starty, start + dash.step_len - dash.gap_len, *starty - 1); | |||||
| start += dash.step_len; | |||||
| } | |||||
| te_vertical_line_last_dashed = te; | |||||
| y2_dashed = *starty; | |||||
| } | } | ||||
| *starty -= UI_UNIT_Y; | *starty -= UI_UNIT_Y; | ||||
| if (TSELEM_OPEN(tselem, soops)) { | if (TSELEM_OPEN(tselem, soops)) { | ||||
| outliner_draw_hierarchy_lines_recursive( | outliner_draw_hierarchy_lines_recursive( | ||||
| pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_childs_grayed_out, starty); | pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_childs_grayed_out, starty); | ||||
| } | } | ||||
| } | } | ||||
| if (draw_grayed_out) { | if (draw_grayed_out) { | ||||
| immUniformColor3ubvAlpha(col, grayed_alpha); | immUniformColor3ubvAlpha(col, grayed_alpha); | ||||
| } | } | ||||
| else { | else { | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| } | } | ||||
| /* Vertical line. */ | /* Vertical line. */ | ||||
| te = te_vertical_line_last; | te = te_vertical_line_last; | ||||
| if ((te != NULL) && (te->parent || lb->first != lb->last)) { | if ((te != NULL) && (te->parent || lb->first != lb->last)) { | ||||
| immRecti(pos, startx, y1 + UI_UNIT_Y, startx + 1, y2); | immRecti(pos, startx, y1 + UI_UNIT_Y, startx + 1, y2); | ||||
| } | } | ||||
| /* Children that are not in the collection are always in the end of the subtree. | |||||
| * This way we can draw their own dashed vertical lines. */ | |||||
| te = te_vertical_line_last_dashed; | |||||
| if ((te != NULL) && (te->parent || lb->first != lb->last)) { | |||||
| const int steps_num = ((y1_dashed + UI_UNIT_Y) - y2_dashed) / dash.step_len; | |||||
| int start = y1_dashed + UI_UNIT_Y; | |||||
| for (int i = 0; i < steps_num; i++) { | |||||
| immRecti(pos, startx, start, startx + 1, start - dash.step_len + dash.gap_len); | |||||
| start -= dash.step_len; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void outliner_draw_hierarchy_lines(SpaceOutliner *soops, | static void outliner_draw_hierarchy_lines(SpaceOutliner *soops, | ||||
| ListBase *lb, | ListBase *lb, | ||||
| int startx, | int startx, | ||||
| int *starty) | int *starty) | ||||
| { | { | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| ▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines | |||||