diff options
author | Julian Eisel <julian@blender.org> | 2022-01-26 21:11:34 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-01-26 21:15:57 +0300 |
commit | 7b615ca186cab53736fe656d894814c6f92de0e3 (patch) | |
tree | 3c3285206c9ce039cd530f27dccfe2e099163c47 /source/blender/editors/space_outliner/outliner_draw.cc | |
parent | 9dc0379dc0023fe45f185dc594dbd4a2fd9fedd3 (diff) |
Cleanup: Remove RNA data from TreeElement, get via type specific class
The `TreeElement.rnaptr` was only needed for RNA tree-elements. Now it
can be gotten through the new type specific classes, e.g.
`TreeElementRNAProperty.getPointerRNA()`.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.cc')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.cc | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 5d15e365dfa..5fd7559370f 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1910,20 +1910,20 @@ static void outliner_draw_rnacols(ARegion *region, int sizex) static void outliner_draw_rnabuts( uiBlock *block, ARegion *region, SpaceOutliner *space_outliner, int sizex, ListBase *lb) { - PointerRNA *ptr; + PointerRNA ptr; PropertyRNA *prop; LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { if (TreeElementRNAProperty *te_rna_prop = tree_element_cast<TreeElementRNAProperty>(te)) { - ptr = &te->rnaptr; + ptr = te_rna_prop->getPointerRNA(); prop = te_rna_prop->getPropertyRNA(); if (!TSELEM_OPEN(tselem, space_outliner)) { if (RNA_property_type(prop) == PROP_POINTER) { uiBut *but = uiDefAutoButR(block, - ptr, + &ptr, prop, -1, "", @@ -1936,7 +1936,7 @@ static void outliner_draw_rnabuts( } else if (RNA_property_type(prop) == PROP_ENUM) { uiDefAutoButR(block, - ptr, + &ptr, prop, -1, nullptr, @@ -1948,7 +1948,7 @@ static void outliner_draw_rnabuts( } else { uiDefAutoButR(block, - ptr, + &ptr, prop, -1, "", @@ -1962,11 +1962,11 @@ static void outliner_draw_rnabuts( } else if (TreeElementRNAArrayElement *te_rna_array_elem = tree_element_cast<TreeElementRNAArrayElement>(te)) { - ptr = &te->rnaptr; + ptr = te_rna_array_elem->getPointerRNA(); prop = te_rna_array_elem->getPropertyRNA(); uiDefAutoButR(block, - ptr, + &ptr, prop, te->index, "", @@ -2556,15 +2556,19 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case TSE_SEQUENCE_DUP: data.icon = ICON_SEQ_STRIP_DUPLICATE; break; - case TSE_RNA_STRUCT: - if (RNA_struct_is_ID(te->rnaptr.type)) { - data.drag_id = (ID *)te->rnaptr.data; - data.icon = RNA_struct_ui_icon(te->rnaptr.type); + case TSE_RNA_STRUCT: { + const TreeElementRNAStruct *te_rna_struct = tree_element_cast<TreeElementRNAStruct>(te); + const PointerRNA &ptr = te_rna_struct->getPointerRNA(); + + if (RNA_struct_is_ID(ptr.type)) { + data.drag_id = reinterpret_cast<ID *>(ptr.data); + data.icon = RNA_struct_ui_icon(ptr.type); } else { - data.icon = RNA_struct_ui_icon(te->rnaptr.type); + data.icon = RNA_struct_ui_icon(ptr.type); } break; + } case TSE_LAYER_COLLECTION: case TSE_SCENE_COLLECTION_BASE: case TSE_VIEW_COLLECTION_BASE: { @@ -3321,8 +3325,9 @@ static void outliner_draw_tree_element(bContext *C, offsx += 2 * ufac; } + const TreeElementRNAStruct *te_rna_struct = tree_element_cast<TreeElementRNAStruct>(te); if (ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION) || - ((tselem->type == TSE_RNA_STRUCT) && RNA_struct_is_ID(te->rnaptr.type))) { + (te_rna_struct && RNA_struct_is_ID(te_rna_struct->getPointerRNA().type))) { const BIFIconID lib_icon = (BIFIconID)UI_icon_from_library(tselem->id); if (lib_icon != ICON_NONE) { UI_icon_draw_alpha( |