CT TREE: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (added scripting example)
m (Text replacement - "{{Feature|Informative|" to "{{Feature|informative|")
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category: Control Types]]
{{CT|intro
{{CT|intro


Line 14: Line 12:
* [[:Category:Command_Group:_GUI_Control_-_Tree_View|Commands: Tree View]]
* [[:Category:Command_Group:_GUI_Control_-_Tree_View|Commands: Tree View]]
|events =
|events =
* [[User_Interface_Event_Handlers#Tree_events|Events: Tree View]]
* [[User_Interface_Event_Handlers#Tree_Events|Events: Tree View]]
}}
}}


Line 23: Line 21:
|type1=Number
|type1=Number
|value1=0
|value1=0
|description=Shows a border around the control.
|description=Shows a border around the control. Setting the size to 0 will not hide the border. Set the {{hl|colorBorder}} to transparent instead.
}}
}}


Line 39: Line 37:
|type1=Array
|type1=Array
|value1={0,0,0,0}
|value1={0,0,0,0}
|description=With {{Inline code|borderSize {{=}} 1}} determines the color of that border.
|description=With {{hl|borderSize {{=}} 1}} determines the color of that border.
}}
}}


Line 48: Line 46:
|description=These lines connect the different entries for better clarity.  
|description=These lines connect the different entries for better clarity.  
<gallery>
<gallery>
CT TREE Lines.jpg|<tt>colorLines[] = {1,1,1,1};</tt>
CT TREE Lines.jpg|{{hl|c= colorLines[] = {1,1,1,1};}}
CT TREE NoLines.jpg|<tt>colorLines[] = {0,0,0,0};</tt>
CT TREE NoLines.jpg|{{hl|c= colorLines[] = {0,0,0,0};}}
</gallery>
</gallery>
}}
}}
Line 57: Line 55:
|type1=Array
|type1=Array
|value1={0.2,0.3,0.7,1}
|value1={0.2,0.3,0.7,1}
|description=Background color of all subsequently selected entries when {{Inline code|multiselectEnabled {{=}} 1;}}.
|description=Background color of all subsequently selected entries when {{hl|multiselectEnabled {{=}} 1;}}.
}}
}}


Line 64: Line 62:
|type1=Array
|type1=Array
|value1={0,0.5,0.5,1}
|value1={0,0.5,0.5,1}
|description=Background color of the first selected entry with {{Inline code|multiselectEnabled {{=}} 1;}}.
|description=Background color of the first selected entry with {{hl|multiselectEnabled {{=}} 1;}}.
}}
}}


Line 71: Line 69:
|type1=Array
|type1=Array
|value1={0,0,0,1}
|value1={0,0,0,1}
|description=Text color of secondarly selected entries with {{Inline code|multiselectEnabled {{=}} 1;}}.
|description=Text color of secondarly selected entries with {{hl|multiselectEnabled {{=}} 1;}}.
}}
}}


Line 127: Line 125:
|type1=Array
|type1=Array
|value1={"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])",1}
|value1={"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])",1}
|description=Entry's background when {{Inline code|multiselectEnabled {{=}} 0;}}.
|description=Entry's background when {{hl|multiselectEnabled {{=}} 0;}}.
}}
}}


Line 141: Line 139:
|type1=Array
|type1=Array
|value1={0,0,0,1}
|value1={0,0,0,1}
|description=Text color of a selected entry with {{Inline code|multiselectEnabled {{=}} 0;}}.
|description=Text color of a selected entry with {{hl|multiselectEnabled {{=}} 0;}}.
}}
}}


Line 224: Line 222:
|value1=1
|value1=1
|description=Enable/disable multi selection with CTRL or SHIFT to select all entries up to the first selected entry.
|description=Enable/disable multi selection with CTRL or SHIFT to select all entries up to the first selected entry.
{{Feature|Informative|Commands to retrieve all selected entries in a multi selection tv are only available after {{GVI|arma3|2.01}}.}}
{{Feature|informative|Commands to retrieve all selected entries in a multi selection tv are only available after {{GVI|arma3|2.01}}.}}
}}
}}


Line 239: Line 237:


{{CT|examples}}
{{CT|examples}}
=== RscExample ===
=== RscExample ===
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
class RscTree
class RscTree
Line 287: Line 287:
borderSize = 0;
borderSize = 0;
expandOnDoubleclick = 1;
expandOnDoubleclick = 1;
class ScrollBar: ScrollBar
class ScrollBar : ScrollBar
{
{
};
};
};
};
</syntaxhighlight>
</syntaxhighlight>


== Other examples ==
== Other examples ==
=== RscTree with search functionality ===
=== RscTree with search functionality ===
<syntaxhighlight lang="cpp">class Dialog
 
<syntaxhighlight lang="cpp">
class Dialog
{
{
idd = -1;
idd = -1;
Line 312: Line 316:
sizeEx = 0.04;
sizeEx = 0.04;
autocomplete = "";
autocomplete = "";
canModify = true;  
canModify = true;
maxChars = 100;  
maxChars = 100;
forceDrawCaret = false;
forceDrawCaret = false;
colorSelection[] = {0,1,0,1};
colorSelection[] = {0,1,0,1};
colorText[] = {1,1,1,1};
colorText[] = {1,1,1,1};
colorDisabled[] = {1,0,0,1};  
colorDisabled[] = {1,0,0,1};
colorBackground[] = {0,0,0,0.8};
colorBackground[] = {0,0,0,0.8};
text = "";
text = "";
Line 326: Line 330:
/* Common properties */
/* Common properties */
idc = 200;
idc = 200;
            /* Add some entries */
/* Add some entries */
onLoad = "params ['_tv'];\
onLoad = "params ['_tv'];\
_classes = 'true' configClasses (configFile >> 'CfgVehicles');\
_classes = 'true' configClasses (configFile >> 'CfgVehicles');\
Line 382: Line 386:
colorSelectBackground[] = {0,0,0,0.5};
colorSelectBackground[] = {0,0,0,0.5};
colorLines[] = {0,0,0,0};
colorLines[] = {0,0,0,0};
class ScrollBar: ScrollBar
class ScrollBar : ScrollBar
{
{
};
};
Line 402: Line 406:
};
};
};
};
};</syntaxhighlight>
};
</syntaxhighlight>
 


== Scripting Example ==
== Scripting Example ==
[[private]] ["_count","_current","_data","_text","_value","_pic"];
 
_CT_TREE [[tvAdd]] [ [],"Parent_A"];
{| class="valign-top"
_CT_TREE [[tvAdd]] [ [0],"Child_A"];
| <sqf>
_CT_TREE [[tvAdd]] [ [0,0],"Grandchild_A"];
private ["_count", "_current", "_data", "_text", "_value", "_pic"];
_CT_TREE [[tvAdd]] [ [],"Parent_B"];
_CT_TREE tvAdd [[], "Parent_A"];
_CT_TREE [[tvAdd]] [ [1],"Child_B"];
_CT_TREE tvAdd [[0], "Child_A"];
[[file:WuChaoRen_CTTree001.png]]
_CT_TREE tvAdd [[0,0], "Grandchild_A"];
_count = _CT_TREE [[tvCount]] []; //return 2
_CT_TREE tvAdd [[], "Parent_B"];
_CT_TREE [[tvSetCurSel]] [0,0,0]; //select grandchild_A
_CT_TREE tvAdd [[1], "Child_B"];
[[file:WuChaoRen_CTTree003.png]]
</sqf>
_current = [[tvCurSel]] _CT_TREE; //return [0,0,0]
| [[File:WuChaoRen_CTTree001.png]]
_CT_TREE [[tvSetData]] [_current,"I'm grandchild_A"];
|-
_data = _CT_TREE [[tvData]] _current; // "I'm grandchild_A"
| <sqf>
_text = _CT_TREE [[tvText]] _current; //"Grandchild_A"
_count = _CT_TREE tvCount []; // return 2
_CT_TREE [[tvSetValue]] [_current,14];
_CT_TREE tvSetCurSel [0,0,0]; // select grandchild_A
_value = _CT_TREE [[tvValue]] _current; // 14
</sqf>
_CT_TREE [[tvSetPicture]] [_current,[[getText]] ([[configFile]] >> "CfgWeapons" >> "optic_NVS" >> "picture")];
| [[File:WuChaoRen_CTTree003.png]]
_pic = _CT_TREE [[tvPicture]] _current;
|-
[[file:WuChaoRen_CTTree004.png]]
| <sqf>
_CT_TREE [[tvExpand]] [1];
_current = tvCurSel _CT_TREE; // return [0,0,0]
[[file:WuChaoRen_CTTree005.png]]
_CT_TREE tvSetData [_current, "I'm grandchild_A"];
_CT_TREE [[tvSort]] [[],[[false]] ];
_data = _CT_TREE tvData _current; // "I'm grandchild_A"
_CT_TREE [[tvSortByValue]] [[],[[false]] ];
_text = _CT_TREE tvText _current; // "Grandchild_A"
[[file:WuChaoRen_CTTree006.png]]
_CT_TREE tvSetValue [_current,14];
_CT_TREE [[tvDelete]] [0,0]; //remove child_b
_value = _CT_TREE tvValue _current; // 14
[[tvClear]] 12;
_CT_TREE tvSetPicture [_current, getText (configFile >> "CfgWeapons" >> "optic_NVS" >> "picture")];
_CT_TREE [[tvCollapse]] [];
_pic = _CT_TREE tvPicture _current;
[[file:WuChaoRen_CTTree002.png]]
</sqf>
</code>
| [[File:WuChaoRen_CTTree004.png]]
|-
| <sqf>_CT_TREE tvExpand [1];</sqf>
| [[File:WuChaoRen_CTTree005.png]]
|-
| <sqf>
_CT_TREE tvSort [[], false];
_CT_TREE tvSortByValue [[], false];
</sqf>
| [[File:WuChaoRen_CTTree006.png]]
|-
| <sqf>
_CT_TREE tvDelete [0,0]; // remove child_b
tvClear 12;
_CT_TREE tvCollapse [];
</sqf>
| [[File:WuChaoRen_CTTree002.png]]
|}
 


[[Category: Control Types]]
[[Category: Control Types]]

Latest revision as of 01:24, 2 February 2024

Introduction

The CT_TREE, also referred to as tree view (tv), is a control with similar functionality as the CT_LISTBOX. In addition to that it supports multiple levels of entries as well as a search functionality.
Since Arma 3 logo black.png2.01: Multiple selections are now also supported via commands.

The engine driven search is very slow. Searching a tree view with many entries can freeze the game.

Related commands & functions

Related User Interface Eventhandlers

Alphabetical Order

TokenNames common to most controls, such as x, y, w, h, text, idc... can be found here.
Not all of the listed attributes might have an effect nor might the list be complete. All attributes were gathered with this config crawler.
#define CT_TREE 12


B

borderSize

Type
Number
Description
Shows a border around the control. Setting the size to 0 will not hide the border. Set the colorBorder to transparent instead.
borderSize = 0;


C

colorArrow

This attribute is mandatory for the control to work!
Type
Array
Description
Has no effect but without it an error is thrown.
colorArrow[] = {1,1,1,1};


colorBorder

Type
Array
Description
With borderSize = 1 determines the color of that border.
colorBorder[] = {0,0,0,0};


colorLines

Type
Array
Description
These lines connect the different entries for better clarity.
colorLines[] = {0,0,0,0};


colorMarked

Type
Array
Description
Background color of all subsequently selected entries when multiselectEnabled = 1;.
colorMarked[] = {0.2,0.3,0.7,1};


colorMarkedSelected

Type
Array
Description
Background color of the first selected entry with multiselectEnabled = 1;.
colorMarkedSelected[] = {0,0.5,0.5,1};


colorMarkedText

Type
Array
Description
Text color of secondarly selected entries with multiselectEnabled = 1;.
colorMarkedText[] = {0,0,0,1};


colorPicture

Type
Array
Description
Left picture color of an unselected entry.
colorPicture[] = {1,1,1,1};


colorPictureDisabled

Type
Array
Description
Left picture color when control is disabled.
colorPictureDisabled[] = {1,1,1,0.25};


colorPictureRight

Type
Array
Description
Right picture color of an unselected entry.
colorPictureRight[] = {1,1,1,1};


colorPictureRightDisabled

Type
Array
Description
Right picture color when control is disabled.
colorPictureRightDisabled[] = {1,1,1,0.25};


colorPictureRightSelected

Type
Array
Description
Right picture color of an selected entry.
colorPictureRightSelected[] = {0,0,0,1};


colorPictureSelected

Type
Array
Description
Left picture color of an selected entry.
colorPictureSelected[] = {1,1,1,1};


colorSearch

Type
Array
Description
Color of the entries that fit the search of the idcSearch listbox.
colorSearch[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])",1};


colorSelect

Type
Array
Description
Entry's background when multiselectEnabled = 0;.
colorSelect[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])",1};


colorSelectBackground

Type
Array
Description
n/a
colorSelectBackground[] = {0,0,0,0.5};


colorSelectText

Type
Array
Description
Text color of a selected entry with multiselectEnabled = 0;.
colorSelectText[] = {0,0,0,1};


D

defaultItem

Type
Array
Description
n/a
defaultItem[] = {"BLU_F","Infantry"};


disableKeyboardSearch

Type
Number
Description
n/a
disableKeyboardSearch = 1;


disableSearchHighlight

Type
Number
Description
n/a
disableSearchHighlight = 1;


E

expandedTexture

Type
String
Description
"Arrow" texture on the left side, if non is given ("") a minus with box will be displayed.
expandedTexture = "A3\ui_f\data\gui\rsccommon\rsctree\expandedTexture_ca.paa";


expandOnDoubleclick

Type
Number
Description
Enable/disable expanding and collapsing with double-click.
expandOnDoubleclick = 1;


H

hiddenTexture

Type
String
Description
"Arrow" texture on the left side, if non is given ("") a plus with box will be displayed.
hiddenTexture = "A3\ui_f\data\gui\rsccommon\rsctree\hiddenTexture_ca.paa";


I

iconFolder

Type
String
Description
n/a
iconFolder = "\a3\3DEN\Data\Cfg3DEN\Layer\icon_ca.paa";


iconFolderDefault

Type
String
Description
n/a
iconFolderDefault = "\a3\3DEN\Data\Cfg3DEN\Layer\iconDefault_ca.paa";


idcSearch

Type
Number
Description
IDC of a CT_EDIT control which functions as the search input.
idcSearch = 283;


M

maxHistoryDelay

Type
Number
Description
n/a
maxHistoryDelay = 1;


multiselectEnabled

Type
Number
Description
Enable/disable multi selection with CTRL or SHIFT to select all entries up to the first selected entry.
Commands to retrieve all selected entries in a multi selection tv are only available after Arma 3 logo black.png2.01.
multiselectEnabled = 1;



Default Classes

Arma 3
AddOns: Classes need to be initialised first with class SomeClass;

Missions: Since Arma 3 v2.02 one can use import SomeClass; to initialise a class (see the import keyword).

In older versions, use "Default" call BIS_fnc_exportGUIBaseClasses; and paste the result into the description.ext.


RscExample

class RscTree
{
	deletable = 0;
	fade = 0;
	access = 0;
	type = CT_TREE;
	colorBackground[] = {0,0,0,0};
	colorSelect[] = {1,1,1,0.7};
	colorDisabled[] = {1,1,1,0.25};
	colorText[] = {1,1,1,1};
	colorSelectText[] = {0,0,0,1};
	colorBorder[] = {0,0,0,0};
	colorSearch[] =
	{
		"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.13])",
		"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.54])",
		"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.21])",
		"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"
	};
	colorMarked[] = {0.2,0.3,0.7,1};
	colorMarkedText[] = {0,0,0,1};
	colorMarkedSelected[] = {0,0.5,0.5,1};
	multiselectEnabled = 0;
	colorPicture[] = {1,1,1,1};
	colorPictureSelected[] = {0,0,0,1};
	colorPictureDisabled[] = {1,1,1,0.25};
	colorPictureRight[] = {1,1,1,1};
	colorPictureRightSelected[] = {0,0,0,1};
	colorPictureRightDisabled[] = {1,1,1,0.25};
	colorArrow[] = {1,1,1,1};
	maxHistoryDelay = 1;
	shadow = 0;
	style = ST_LEFT;
	font = "RobotoCondensed";
	sizeEx = GUI_TEXT_SIZE_MEDIUM;
	expandedTexture = "A3\ui_f\data\gui\rsccommon\rsctree\expandedTexture_ca.paa";
	hiddenTexture = "A3\ui_f\data\gui\rsccommon\rsctree\hiddenTexture_ca.paa";
	x = 0;
	y = 0;
	w = 0.1;
	h = 0.2;
	rowHeight = 0.0439091;
	colorSelectBackground[] = {0,0,0,0.5};
	colorLines[] = {0,0,0,0};
	borderSize = 0;
	expandOnDoubleclick = 1;
	class ScrollBar : ScrollBar
	{
	};
};


Other examples

RscTree with search functionality

class Dialog
{
	idd = -1;
	class Controls
	{
		class _CT_EDIT
		{
			idc = 100;
			type = 2;
			style = "512";
			x = GUI_GRID_CENTER_X + 10 * GUI_GRID_CENTER_W;
			y = GUI_GRID_CENTER_Y + 0 * GUI_GRID_CENTER_H;
			w = 20 * GUI_GRID_CENTER_W;
			h = 2 * GUI_GRID_CENTER_H;
			font = "PuristaMedium";
			sizeEx = 0.04;
			autocomplete = "";
			canModify = true;
			maxChars = 100;
			forceDrawCaret = false;
			colorSelection[] = {0,1,0,1};
			colorText[] = {1,1,1,1};
			colorDisabled[] = {1,0,0,1};
			colorBackground[] = {0,0,0,0.8};
			text = "";
			tooltip = "Type to search";
		};
		class _CT_TREE
		{
			/* Common properties */
			idc = 200;
			/* Add some entries */
			onLoad = "params ['_tv'];\
					_classes = 'true' configClasses (configFile >> 'CfgVehicles');\
					for '_i' from 0 to 10 do\
					{\
						_tv tvAdd [[], configName selectRandom _classes];\
						for '_j' from 0 to 10 do\
						{\
							_tv tvAdd [[_i], configName selectRandom _classes];\
							for '_k' from 0 to 10 do\
							{\
								_tv tvAdd [[_i, _j], configName selectRandom _classes];\
							};\
						};\
					};";
			moving = 0;
			type = CT_TREE;
			style = ST_LEFT;
			x = GUI_GRID_CENTER_X + 10 * GUI_GRID_CENTER_W;
			y = GUI_GRID_CENTER_Y + 3 * GUI_GRID_CENTER_H;
			w = 20 * GUI_GRID_CENTER_W;
			h = 23 * GUI_GRID_CENTER_H;
			sizeEx = GUI_TEXT_SIZE_MEDIUM;
			font = "RobotoCondensed";
			colorText[] = {1,1,1,1};
			colorBackground[] = {0,0,0,0.8};
			colorDisabled[] = {1,1,1,0.25};
			shadow = 0;
			access = 0;

			/* CT_TREE specific properties */
			idcSearch = 100;
			colorSelect[] = {1,1,1,0.7};
			colorSelectText[] = {0,0,0,1};
			colorBorder[] = {0,0,0,0};
			colorSearch[] =
			{
				"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.13])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.54])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.21])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"
			};
			colorMarked[] = {0.2,0.3,0.7,1};
			colorMarkedText[] = {0,0,0,1};
			colorMarkedSelected[] = {0,0.5,0.5,1};
			multiselectEnabled = 0;
			colorPicture[] = {1,1,1,1};
			colorPictureSelected[] = {0,0,0,1};
			colorPictureDisabled[] = {1,1,1,0.25};
			colorPictureRight[] = {1,1,1,1};
			colorPictureRightSelected[] = {0,0,0,1};
			colorPictureRightDisabled[] = {1,1,1,0.25};
			colorArrow[] = {1,1,1,1};
			maxHistoryDelay = 1;
			colorSelectBackground[] = {0,0,0,0.5};
			colorLines[] = {0,0,0,0};
			class ScrollBar : ScrollBar
			{
			};
			expandedTexture = "A3\ui_f\data\gui\rsccommon\rsctree\expandedTexture_ca.paa";
			hiddenTexture = "A3\ui_f\data\gui\rsccommon\rsctree\hiddenTexture_ca.paa";
			rowHeight = 0.0439091;
			borderSize = 0;
			expandOnDoubleclick = 1;

			/* CT_TREE user interface eventhandlers */
			onTreeSelChanged = "systemChat str ['onTreeSelChanged',_this]; false";
			onTreeLButtonDown = "systemChat str ['onTreeLButtonDown',_this]; false";
			onTreeDblClick = "systemChat str ['onTreeDblClick',_this]; false";
			onTreeExpanded = "systemChat str ['onTreeExpanded',_this]; false";
			onTreeCollapsed = "systemChat str ['onTreeCollapsed',_this]; false";
			onTreeMouseMove = "systemChat str ['onTreeMouseMove',_this]; false";
			onTreeMouseHold = "systemChat str ['onTreeMouseHold',_this]; false";
			onTreeMouseExit = "systemChat str ['onTreeMouseExit',_this]; false";
		};
	};
};


Scripting Example

private ["_count", "_current", "_data", "_text", "_value", "_pic"]; _CT_TREE tvAdd [[], "Parent_A"]; _CT_TREE tvAdd [[0], "Child_A"]; _CT_TREE tvAdd [[0,0], "Grandchild_A"]; _CT_TREE tvAdd [[], "Parent_B"]; _CT_TREE tvAdd [[1], "Child_B"];
WuChaoRen CTTree001.png
_count = _CT_TREE tvCount []; // return 2 _CT_TREE tvSetCurSel [0,0,0]; // select grandchild_A
WuChaoRen CTTree003.png
_current = tvCurSel _CT_TREE; // return [0,0,0] _CT_TREE tvSetData [_current, "I'm grandchild_A"]; _data = _CT_TREE tvData _current; // "I'm grandchild_A" _text = _CT_TREE tvText _current; // "Grandchild_A" _CT_TREE tvSetValue [_current,14]; _value = _CT_TREE tvValue _current; // 14 _CT_TREE tvSetPicture [_current, getText (configFile >> "CfgWeapons" >> "optic_NVS" >> "picture")]; _pic = _CT_TREE tvPicture _current;
WuChaoRen CTTree004.png
_CT_TREE tvExpand [1];
WuChaoRen CTTree005.png
_CT_TREE tvSort [[], false]; _CT_TREE tvSortByValue [[], false];
WuChaoRen CTTree006.png
_CT_TREE tvDelete [0,0]; // remove child_b tvClear 12; _CT_TREE tvCollapse [];
WuChaoRen CTTree002.png