GeData objListData = GeData(CUSTOMDATA_ITEMTREE, DEFAULTVALUE);
ItemTreeData* volList = (ItemTreeData*)(objListData.GetCustomDataType(CUSTOMDATA_ITEMTREE));
if (volList)
volList->SetOwner((BaseList2D*)node);
bc.SetData(ID_VOLUMEBUILDER_OBJECT_LIST, objListData);
this sets up the cgui_itemtree list. Important is to set the Owner, or many callbacks will not arrive the parent object.
It's recommended to refresh this owner on "MSG_DESCRIPTION_POSTSETPARAMETER" and "MSG_DOCUMENTINFO_TYPE_SETACTIVE"message, because it happens that the information is lost
#define BOOL_MODE_COLUMN ITEMTREE_USER_COL
#define MIX_MODE_COLUMN ITEMTREE_USER_COL + 1
#define MIXVECTOR_MODE_COLUMN ITEMTREE_USER_COL + 2
#define CHILDTYPE_COLUMN ITEMTREE_USER_COL + 3
#define SMOOTH_RADIUS_COLUMN ITEMTREE_USER_COL + 4
BaseContainer* itreeui = description->GetParameterI(DescLevel(ID_VOLUMEBUILDER_OBJECT_LIST), arr);
if (itreeui)
{
_volMode = GetVolumeMode(bc);
BaseContainer userColTypes;
userColTypes.SetInt32(BOOL_MODE_COLUMN, LV_DROPDOWN);
userColTypes.SetInt32(MIX_MODE_COLUMN, LV_DROPDOWN);
userColTypes.SetInt32(MIXVECTOR_MODE_COLUMN, LV_DROPDOWN);
userColTypes.SetInt32(SMOOTH_RADIUS_COLUMN, LV_SLIDER);
itreeui->SetContainer(ITEMTREE_USER_COL_TYPES, userColTypes);
BaseContainer userColActive;
userColActive.SetBool(BOOL_MODE_COLUMN, _volMode == VOLUMEMODE::SDF);
userColActive.SetBool(MIX_MODE_COLUMN, _volMode == VOLUMEMODE::FOG);
userColActive.SetBool(MIXVECTOR_MODE_COLUMN, _volMode == VOLUMEMODE::VECTOR);
userColActive.SetBool(CHILDTYPE_COLUMN, true);
userColActive.SetBool(SMOOTH_RADIUS_COLUMN, _volMode == VOLUMEMODE::SDF);
itreeui->SetContainer(ITEMTREE_USER_COL_ACTIVE, userColActive);
itreeui->SetBool(ITEMTREE_CHECKBOX_FRONT, true);
BaseContainer thdata;
thdata.SetString(ITEMTREE_ENABLE_COL, ""_s);
thdata.SetString(ITEMTREE_OBJECT_COL, GeLoadString(IDS_VOLUMEBUILDERLIST_NAME));
thdata.SetString(BOOL_MODE_COLUMN, GeLoadString(IDS_VOLUMEBUILDERLIST_MODE));
thdata.SetString(MIX_MODE_COLUMN, GeLoadString(IDS_VOLUMEBUILDERLIST_MODE));
thdata.SetString(MIXVECTOR_MODE_COLUMN, GeLoadString(IDS_VOLUMEBUILDERLIST_MODE));
thdata.SetString(CHILDTYPE_COLUMN, GeLoadString(IDS_VOLUMEBUILDERLIST_INPUT_TYPE));
thdata.SetString(SMOOTH_RADIUS_COLUMN, GeLoadString(IDS_VOLUMEBUILDERLIST_SMOOTH_RADIUS));
itreeui->SetContainer(ITEMTREE_ID_HEADERS_DATA, thdata);
BaseContainer thids;
GeData columnId;
columnId.SetInt32(CHILDTYPE_COLUMN);
thids.SetData(CHILDTYPE_COLUMN, columnId);
itreeui->SetContainer(ITEMTREE_ID_HEADERS_IDS, thids);
}
thats the code in GetDDescription that sets up the UI with colums and header names and hides the columns that are not needed for the chosen mode.
Every entry needs the dropdown data in the list added (recommended to do that in the itemtree callback ITEMTREE_CALLBACK_INSERTNODE). Here an example how the volume builder does it:
inline BaseContainer BuildBoolCycleEntries()
{
BaseContainer cyclebc;
cyclebc.InsData(ID_VOLUMEBUILDER_BOOL_UNION, GeLoadString(IDS_BOOL_UNION));
cyclebc.InsData(ID_VOLUMEBUILDER_BOOL_DIFF, GeLoadString(IDS_BOOL_DIFF));
cyclebc.InsData(ID_VOLUMEBUILDER_BOOL_INTERSECT, GeLoadString(IDS_BOOL_INTERSECT));
return cyclebc;
}
inline BaseContainer BuildBoolCycle()
{
BaseContainer bc;
bc.SetContainer(DESC_CYCLE, BuildBoolCycleEntries());
return bc;
}
inline void AddDropdownDataToNode(ItemTreeNodeData& node)
{
BaseContainer cycleBoolBC = BuildBoolCycle();
cycleBoolBC.SetInt32(BOOL_MODE_COLUMN, ID_VOLUMEBUILDER_BOOL_UNION);
BaseContainer cycleMixBC = BuildMixCycle();
cycleMixBC.SetInt32(MIX_MODE_COLUMN, ID_VOLUMEBUILDER_MIX_NORMAL);
BaseContainer cycleMixVectorBC = BuildMixVectorCycle();
cycleMixVectorBC.SetInt32(MIXVECTOR_MODE_COLUMN, ID_VOLUMEBUILDER_MIXVECTOR_NORMAL);
BaseContainer nodeContainer;
nodeContainer.SetContainer(BOOL_MODE_COLUMN, cycleBoolBC);
nodeContainer.SetContainer(MIX_MODE_COLUMN, cycleMixBC);
nodeContainer.SetContainer(MIXVECTOR_MODE_COLUMN, cycleMixVectorBC);
nodeContainer.SetString(CHILDTYPE_COLUMN, ""_s);
node.m_Data.SetContainer(nodeContainer);
}
in the resource file the UI element needs to be set up correctly:
ITEMTREE ID_VOLUMEBUILDER_OBJECT_LIST
{
ANIM ON; // animation is allowed
NEWLINE; // the name of the UI element is above the ui element
HEADERS; // shows the header bar
MULTIPLE; // allows multiselect of entries
COLUMNS 7; // amount of columns
CHECKBOX; // checkbox added in the list
FOLDERS; // parent folders can be created
DRAGDROP; // drag & drop callbacks are send and d&d is allowed
ICON; // entries are shown with icons
NO_MENU; // no right click menu
ACCEPT // what types are accepted in the list
{
Obase;
1001381; //TP GROUP
}
}
Hope this helps
Regards
Fritz