Hide Description elements

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;
}
Avatar

Frank Willeke

worked with computers since more than 20 years | got hooked on computer graphics back on the AMIGA | started programming at the age of 13 | relesed some successful plugins for cinema 4d | started working for maxon computer gmbh in 2009 | now contributing to cinema 4d as a senior developer making electronic music since 1993 | playing the electric guitar since 1995 age of 14 | first live gigs in 1997 | playing the bass guitar 2005 | playing keyboards and synths since 2012 experimenting with photography since 2003