Using the NodeData::GetDDescription() we can add, hide or modify elements in the Description of a BaseList2D object.
Here we show how to hide (or unhide) an element. This is useful if certain description elements should only be visible if the user selected a certain option.
The function
// Shows or hides a description from the node. Bool ShowDescriptionElement(GeListNode *node, Description *descr, LONG MyDescID, Bool show) { AutoAlloc<AtomArray> ar; if(!ar) return FALSE; ar->Append(static_cast<C4DAtom*>(node)); BaseContainer *bc = descr->GetParameterI(DescLevel(MyDescID), ar); if(bc) bc->SetBool(DESC_HIDE, !show); else return FALSE; return TRUE; }
Usage
The following code will hide/show either one parameter or two others, depending on the value of TMYEXPRESSIONTAG_MODE.
// Dynamic description Bool MyExpressionTag::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC& flags) { // Load description (user interface) if (!description->LoadDescription(Tmyepressiontag)) return FALSE; flags |= DESCFLAGS_DESC_LOADED; BaseContainer *bc = ((BaseTag*)node)->GetDataInstance(); Bool simplemode = bc->GetLong(TMYEXPRESSIONTAG_MODE) == TMYEXPRESSIONTAG_MODE_SIMPLE; ShowDescriptionElement(node, description, TMYEXPRESSIONTAG_SIMPLE_PARAMETER, simplemode); ShowDescriptionElement(node, description, TMYEXPRESSIONTAG_COMPLEX_PARAMETER_1, !simplemode); ShowDescriptionElement(node, description, TMYEXPRESSIONTAG_COMPLEX_PARAMETER_2, !simplemode); return TRUE; }