Info for ITEMTREE/customgui_itemtree

Hi guys,
I'm curious if we have some guidance to show how to create/use "customgui_itemtree" UI as Volume Builder does it. I wish to make something simpler with checkbox+Enum UI as in picture at first. Any help please!
a1.jpg
Best,
A.

I haven't used it as part of an object UI.
So can't help there.

But for the usage of the treeview, you can just this thread https://plugincafe.maxon.net/topic/10654/14102_using-customgui-listview
There's a working plug in there.

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

Hey guys,
Thanks for replies, I'll give some try as advice of Fritz at first. I definitely need it inside object UI, by C++

@khor

this is a bit old but I guess this can server as an additional resource
https://c4dprogramming.wordpress.com/2012/11/25/treeview-made-simple-part-1/

@bentraje said in Info for ITEMTREE/customgui_itemtree:

@khor

this is a bit old but I guess this can server as an additional resource
https://c4dprogramming.wordpress.com/2012/11/25/treeview-made-simple-part-1/

Thanks, but it's not what I'm looking for!

Hi @Fritz,
There are some missing bricks: definition for ItemTreeNodeData. I cannot find it in anywhere and how can we catch/register callbacks for itemtree to use ITEMTREE_CALLBACK_INSERTNODE?

Hi @khor unfortunately Fritz is in holiday, but from what I see this is not possible since few types are not public.

I will confirm with him when he will be back, in the meantime I wish you a nice Christmas.
Cheers,
Maxime.