diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 123 |
1 files changed, 50 insertions, 73 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index d3e70da80c8..90b137bcd7d 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -248,19 +248,6 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2)) -{ - ID *id = (ID *)poin; - - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(id, 0); - - if (GS(id->name) == ID_SCE) { - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, id); - } - WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL); -} - static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2)) { ID *id = (ID *)poin; @@ -275,9 +262,9 @@ static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void } } - static void namebutton_cb(bContext *C, void *tsep, char *oldname) { + Main *bmain = CTX_data_main(C); SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -289,7 +276,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) TreeElement *te = outliner_find_tree_element(&soops->tree, tselem); if (tselem->type == 0) { - BLI_libblock_ensure_unique_name(G.main, tselem->id->name); + BLI_libblock_ensure_unique_name(bmain, tselem->id->name); switch (GS(tselem->id->name)) { case ID_MA: @@ -311,7 +298,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) BKE_library_filepath_set(lib, lib->name); BLI_strncpy(expanded, lib->name, sizeof(expanded)); - BLI_path_abs(expanded, G.main->name); + BLI_path_abs(expanded, bmain->name); if (!BLI_exists(expanded)) { BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Library path '%s' does not exist, correct this before saving", expanded); @@ -329,7 +316,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object break; case TSE_NLA_ACTION: - BLI_libblock_ensure_unique_name(G.main, tselem->id->name); + BLI_libblock_ensure_unique_name(bmain, tselem->id->name); break; case TSE_EBONE: { @@ -404,14 +391,10 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd); break; } - case TSE_R_LAYER: - break; - case TSE_SCENE_COLLECTION: case TSE_LAYER_COLLECTION: { - SceneCollection *sc = outliner_scene_collection_from_tree_element(te); - BKE_collection_rename(tselem->id, sc, te->name); - WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); + BLI_libblock_ensure_unique_name(bmain, tselem->id->name); + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; break; } } @@ -427,16 +410,16 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TreeStoreElem *tselem; Object *ob = NULL; -#if 0 - PropertyRNA *object_prop_hide, *object_prop_hide_select, *object_prop_hide_render; - - /* get RNA properties (once) */ - object_prop_hide = RNA_struct_type_find_property(&RNA_Object, "hide"); - object_prop_hide_select = RNA_struct_type_find_property(&RNA_Object, "hide_select"); - object_prop_hide_render = RNA_struct_type_find_property(&RNA_Object, "hide_render"); - BLI_assert(object_prop_hide && object_prop_hide_select && object_prop_hide_render); -#endif - + /* get RNA properties (once for speed) */ + PropertyRNA *collection_prop_hide_viewport; + PropertyRNA *collection_prop_hide_select; + PropertyRNA *collection_prop_hide_render; + collection_prop_hide_select = RNA_struct_type_find_property(&RNA_Collection, "hide_select"); + collection_prop_hide_viewport = RNA_struct_type_find_property(&RNA_Collection, "hide_viewport"); + collection_prop_hide_render = RNA_struct_type_find_property(&RNA_Collection, "hide_render"); + BLI_assert(collection_prop_hide_viewport && + collection_prop_hide_select && + collection_prop_hide_render); for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); @@ -540,46 +523,33 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar UI_block_emboss_set(block, UI_EMBOSS); } - else if (tselem->type == TSE_LAYER_COLLECTION) { - LayerCollection *collection = te->directdata; - - const bool is_enabled = (collection->flag & COLLECTION_DISABLED) == 0; + else if (outliner_is_collection_tree_element(te)) { + LayerCollection *lc = (tselem->type == TSE_LAYER_COLLECTION) ? te->directdata : NULL; + Collection *collection = outliner_collection_from_tree_element(te); UI_block_emboss_set(block, UI_EMBOSS_NONE); - if (collection->scene_collection->type == COLLECTION_TYPE_NONE) { - bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, - UI_UNIT_Y, &collection->flag, 0, 0, 0, 0, - TIP_("Restrict/Allow 3D View selection of objects in the collection")); - UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection); - UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - } - else if ((soops->outlinevis == SO_GROUPS) && - (collection->scene_collection->type == COLLECTION_TYPE_GROUP_INTERNAL)) + if ((!lc || !(lc->flag & LAYER_COLLECTION_EXCLUDE)) && + !(collection->flag & COLLECTION_IS_MASTER)) { - bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VIEWPORT, 0, ICON_RESTRICT_VIEW_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, - UI_UNIT_Y, &collection->flag, 0, 0, 0, 0, - TIP_("Restrict/Allow 3D View selection of objects in the collection")); - UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection); + PointerRNA collection_ptr; + RNA_id_pointer_create(&collection->id, &collection_ptr); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_VIEW_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &collection_ptr, collection_prop_hide_viewport, -1, 0, 0, 0, 0, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_RENDER, 0, ICON_RESTRICT_RENDER_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, - UI_UNIT_Y, &collection->flag, 0, 0, 0, 0, - TIP_("Restrict/Allow 3D View selection of objects in the collection")); - UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection); + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_RENDER_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &collection_ptr, collection_prop_hide_render, -1, 0, 0, 0, 0, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - } - bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0, - is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, - UI_UNIT_Y, &collection->flag, 0, 0, 0, 0, - TIP_("Enable/Disable collection")); - UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection); - UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &collection_ptr, collection_prop_hide_select, -1, 0, 0, 0, 0, NULL); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + } UI_block_emboss_set(block, UI_EMBOSS); } @@ -1090,8 +1060,9 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } break; case TSE_LAYER_COLLECTION: - case TSE_SCENE_COLLECTION: - ICON_DRAW(ICON_COLLAPSEMENU); + case TSE_SCENE_COLLECTION_BASE: + case TSE_VIEW_COLLECTION_BASE: + ICON_DRAW(ICON_GROUP); break; /* Removed the icons from outliner. Need a better structure with Layers, Palettes and Colors */ #if 0 @@ -1131,7 +1102,13 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case OB_LIGHTPROBE: tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LIGHTPROBE); break; case OB_EMPTY: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); break; + if (ob->dup_group) { + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_GROUP_INSTANCE); + } + else { + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); + } + break; } } else { @@ -1339,7 +1316,7 @@ static void outliner_draw_tree_element( tselem = TREESTORE(te); if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { - const float alpha_fac = draw_grayed_out ? 0.5f : 1.0f; + const float alpha_fac = ((te->flag & TE_DISABLED) || draw_grayed_out) ? 0.5f : 1.0f; const float alpha = 0.5f * alpha_fac; int xmax = ar->v2d.cur.xmax; @@ -1422,8 +1399,8 @@ static void outliner_draw_tree_element( te->flag |= TE_ACTIVE; // for lookup in display hierarchies } - if ((soops->outlinevis == SO_COLLECTIONS) && (tselem->type == TSE_R_LAYER)) { - /* View layer in collections can't expand/collapse. */ + if (tselem->type == TSE_VIEW_COLLECTION_BASE) { + /* Scene collection in view layer can't expand/collapse. */ } else if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { /* open/close icon, only when sublevels, except for scene */ @@ -1448,7 +1425,7 @@ static void outliner_draw_tree_element( else offsx += 2 * ufac; - if (tselem->type == 0 && ID_IS_LINKED(tselem->id)) { + if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_LINKED(tselem->id)) { if (tselem->id->tag & LIB_TAG_MISSING) { UI_icon_draw_alpha((float)startx + offsx + 2 * ufac, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_BROKEN, alpha_fac); @@ -1463,7 +1440,7 @@ static void outliner_draw_tree_element( } offsx += UI_UNIT_X + 2 * ufac; } - else if (tselem->type == 0 && ID_IS_STATIC_OVERRIDE(tselem->id)) { + else if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_STATIC_OVERRIDE(tselem->id)) { UI_icon_draw_alpha((float)startx + offsx + 2 * ufac, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_OVERRIDE, alpha_fac); offsx += UI_UNIT_X + 2 * ufac; |