UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_nodes.h File Reference
Include dependency graph for ui_nodes.h:

Go to the source code of this file.

Data Structures

struct  uiExcludeRect_t
struct  uiBox_t
struct  uiNode_t
 Atomic structure used to define most of the UI. More...

Macros

#define UI_EXTRADATA_POINTER(NODE, TYPE)
 Return extradata structure from a node.
#define UI_EXTRADATA(NODE, TYPE)
#define UI_EXTRADATACONST_POINTER(NODE, TYPE)
#define UI_EXTRADATACONST(NODE, TYPE)

Functions

void UI_InitNodes (void)
uiNode_tUI_AllocNode (const char *name, const char *type, bool isDynamic)
 Allocate a node into the UI memory.
uiNode_tUI_GetNodeByPath (const char *path) __attribute__((warn_unused_result))
 Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNodePath.
void UI_ReadNodePath (const char *path, const uiNode_t *relativeNode, const uiNode_t *iterationNode, uiNode_t **resultNode, const value_t **resultProperty, value_t *luaMethod=nullptr)
 Read a path and return every we can use (node and property).
uiNode_tUI_GetNodeAtPosition (int x, int y) __attribute__((warn_unused_result))
 Return the first visible node at a position.
const char * UI_GetPath (const uiNode_t *node) __attribute__((warn_unused_result))
 Return a path from a window to a node.
uiNode_tUI_CloneNode (const uiNode_t *node, uiNode_t *newWindow, bool recursive, const char *newName, bool isDynamic) __attribute__((warn_unused_result))
 Clone a node.
bool UI_CheckVisibility (uiNode_t *node)
 Check the if conditions for a given node.
void UI_DeleteAllChild (uiNode_t *node)
 Remove all child from a node (only remove dynamic memory allocation nodes).
void UI_DeleteNode (uiNode_t *node)
uiBehaviour_tUI_GetNodeBehaviour (const char *name) __attribute__((warn_unused_result))
 Return a node behaviour by name.
uiBehaviour_tUI_GetNodeBehaviourByIndex (int index) __attribute__((warn_unused_result))
int UI_GetNodeBehaviourCount (void) __attribute__((warn_unused_result))

Macro Definition Documentation

◆ UI_EXTRADATA

#define UI_EXTRADATA ( NODE,
TYPE )
Value:
(*UI_EXTRADATA_POINTER(NODE, TYPE))
#define UI_EXTRADATA_POINTER(NODE, TYPE)
Return extradata structure from a node.
Definition ui_nodes.h:184

Definition at line 185 of file ui_nodes.h.

Referenced by uiWindowNode::setFill(), UI_AbstractOption_SetBackgroundByName(), UI_Button_SetBackgroundByName(), UI_Button_SetIconByName(), UI_CheckBox_SetBackgroundByName(), UI_CheckBox_SetIconCheckedByName(), UI_CheckBox_SetIconUncheckedByName(), UI_CheckBox_SetIconUnknownByName(), UI_Model_SetAnimationSource(), UI_Model_SetModelSource(), UI_Model_SetSkinSource(), UI_Model_SetTagSource(), UI_Panel_SetBackgroundByName(), UI_Spinner_SetBackgroundByName(), UI_Spinner_SetBottomIconByName(), UI_Spinner_SetTopIconByName(), UI_TextEntry_SetBackgroundByName(), UI_Window_SetBackgroundByName(), uiAbstractOptionNode_t_lineheight(), uiAbstractOptionNode_t_lua_onViewChange_get(), uiAbstractOptionNode_t_lua_onViewChange_set(), uiAbstractOptionNode_t_set_lineheight(), uiAbstractScrollableNode_t_fullsize(), uiAbstractScrollableNode_t_lua_onViewChange_get(), uiAbstractScrollableNode_t_lua_onViewChange_set(), uiAbstractScrollableNode_t_viewpos(), uiAbstractScrollableNode_t_viewsize(), uiAbstractScrollbarNode_t_current(), uiAbstractScrollbarNode_t_fullsize(), uiAbstractScrollbarNode_t_is_autoshowscroll(), uiAbstractScrollbarNode_t_set_autoshowscroll(), uiAbstractScrollbarNode_t_set_fullsize(), uiAbstractScrollbarNode_t_set_viewsize(), uiAbstractScrollbarNode_t_viewsize(), uiBarNode_t_direction(), uiBarNode_t_is_nohover(), uiBarNode_t_is_readonly(), uiBarNode_t_set_direction(), uiBarNode_t_set_nohover(), uiBarNode_t_set_readonly(), uiBaseInventoryNode_t_columns(), uiBaseInventoryNode_t_filtertype(), uiBaseInventoryNode_t_fullsize(), uiBaseInventoryNode_t_is_displayammo(), uiBaseInventoryNode_t_is_displayavailableontop(), uiBaseInventoryNode_t_is_displayimplant(), uiBaseInventoryNode_t_is_displayunavailable(), uiBaseInventoryNode_t_is_displayunavailableammo(), uiBaseInventoryNode_t_is_displayweapon(), uiBaseInventoryNode_t_is_displayweaponammo(), uiBaseInventoryNode_t_lua_onViewChange_get(), uiBaseInventoryNode_t_lua_onViewChange_set(), uiBaseInventoryNode_t_set_displayammo(), uiBaseInventoryNode_t_set_displayavailableontop(), uiBaseInventoryNode_t_set_displayimplant(), uiBaseInventoryNode_t_set_displayunavailable(), uiBaseInventoryNode_t_set_displayunavailableammo(), uiBaseInventoryNode_t_set_displayweapon(), uiBaseInventoryNode_t_set_displayweaponammo(), uiBaseInventoryNode_t_set_fullsize(), uiBaseInventoryNode_t_set_viewpos(), uiBaseInventoryNode_t_set_viewsize(), uiBaseInventoryNode_t_viewpos(), uiBaseInventoryNode_t_viewsize(), uiBaseLayoutNode_t_baseid(), uiBaseLayoutNode_t_set_baseid(), uiButtonNode_t_flipicon(), uiButtonNode_t_set_flipicon(), uiContainerNode_t_lua_onSelect_get(), uiContainerNode_t_lua_onSelect_set(), uiContainerNode_t_selectedid(), uiDataNode_t_as_float(), uiDataNode_t_as_integer(), uiDataNode_t_set_value__SWIG_1(), uiDataNode_t_set_valuef(), uiGeoscapeNode_t_paddingright(), uiGeoscapeNode_t_set_paddingright(), uiImageNode_t_is_keepratio(), uiImageNode_t_is_mousefx(), uiImageNode_t_set_keepratio(), uiImageNode_t_set_mousefx(), uiImageNode_t_set_texh(), uiImageNode_t_set_texl(), uiImageNode_t_texh(), uiImageNode_t_texl(), uiItemNode_t_is_containerlike(), uiItemNode_t_set_containerlike(), uiLineChartNode_t_is_showaxes(), uiLineChartNode_t_set_axescolor(), uiLineChartNode_t_set_showaxes(), uiModelNode_t_angles(), uiModelNode_t_animation(), uiModelNode_t_is_autoscale(), uiModelNode_t_is_mouserotate(), uiModelNode_t_model(), uiModelNode_t_omega(), uiModelNode_t_origin(), uiModelNode_t_scale(), uiModelNode_t_set_angles(), uiModelNode_t_set_autoscale(), uiModelNode_t_set_mouserotate(), uiModelNode_t_set_omega(), uiModelNode_t_set_origin(), uiModelNode_t_set_scale(), uiModelNode_t_skin(), uiModelNode_t_tag(), uiOptionNode_t_count(), uiOptionNode_t_is_collapsed(), uiOptionNode_t_is_flipicion(), uiOptionNode_t_is_truncated(), uiOptionNode_t_label(), uiOptionNode_t_set_collapsed(), uiOptionNode_t_set_flipicion(), uiOptionNode_t_set_truncated(), uiOptionNode_t_value(), uiPanelNode_t_is_wheelscrollable(), uiPanelNode_t_layout(), uiPanelNode_t_layoutcolumns(), uiPanelNode_t_layoutmargin(), uiPanelNode_t_set_layout(), uiPanelNode_t_set_layoutcolumns(), uiPanelNode_t_set_layoutmargin(), uiPanelNode_t_set_wheelscrollable(), uiRadioButtonNode_t_as_float(), uiRadioButtonNode_t_as_string(), uiRadioButtonNode_t_is_flipicon(), uiRadioButtonNode_t_set_flipicon(), uiRowsNode_t_current(), uiRowsNode_t_lineheight(), uiRowsNode_t_set_current(), uiRowsNode_t_set_lineheight(), uiSequenceNode_t_is_playing(), uiSequenceNode_t_lua_onEnd_get(), uiSequenceNode_t_lua_onEnd_set(), uiSpinnerNode_t_is_horizontal(), uiSpinnerNode_t_is_inverted(), uiSpinnerNode_t_mode(), uiSpinnerNode_t_set_horizontal(), uiSpinnerNode_t_set_inverted(), uiSpinnerNode_t_set_mode(), uiStringNode_t_longlines(), uiStringNode_t_set_longlines(), uiTBarNode_t_set_texh(), uiTBarNode_t_set_texl(), uiTBarNode_t_texh(), uiTBarNode_t_texl(), uiTextEntryNode_t_cursorposition(), uiTextEntryNode_t_is_clickoutabort(), uiTextEntryNode_t_is_password(), uiTextEntryNode_t_lua_onTextEntryAbort_get(), uiTextEntryNode_t_lua_onTextEntryAbort_set(), uiTextEntryNode_t_set_clickoutabort(), uiTextEntryNode_t_set_password(), uiTextNode_t_dataid(), uiTextNode_t_lineheight(), uiTextNode_t_lineselected(), uiTextNode_t_longlines(), uiTextNode_t_set_dataid(), uiTextNode_t_set_lineheight(), uiTextNode_t_set_longlines(), uiTextNode_t_set_tabwidth(), uiTextNode_t_tabwidth(), uiTextNode_t_textselected(), uiTimerNode_t_lua_onEvent_get(), uiTimerNode_t_lua_onEvent_set(), uiTimerNode_t_set_timeout(), uiTimerNode_t_timeout(), uiVideoNode_t_is_nosound(), uiVideoNode_t_lua_onEnd_get(), uiVideoNode_t_lua_onEnd_set(), uiVideoNode_t_set_nosound(), uiWindowNode_t_is_fullscreen(), uiWindowNode_t_is_modal(), uiWindowNode_t_is_starlayout(), uiWindowNode_t_lua_onWindowActivate_get(), uiWindowNode_t_lua_onWindowActivate_set(), uiWindowNode_t_lua_onWindowClosed_get(), uiWindowNode_t_lua_onWindowClosed_set(), uiWindowNode_t_lua_onWindowOpened_get(), uiWindowNode_t_lua_onWindowOpened_set(), uiWindowNode_t_set_dropdown(), uiWindowNode_t_set_fullscreen(), uiWindowNode_t_set_modal(), uiWindowNode_t_set_noticepos(), uiWindowNode_t_set_preventtypingescape(), uiWindowNode_t_set_starlayout(), uiZoneNode_t_clickdelay(), uiZoneNode_t_is_repeat(), uiZoneNode_t_set_clickdelay(), and uiZoneNode_t_set_repeat().

◆ UI_EXTRADATA_POINTER

#define UI_EXTRADATA_POINTER ( NODE,
TYPE )
Value:
((TYPE*)((char*)NODE + sizeof(uiNode_t)))
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80

Return extradata structure from a node.

Parameters
TYPEExtradata type
NODEPointer to the node

Definition at line 184 of file ui_nodes.h.

◆ UI_EXTRADATACONST

#define UI_EXTRADATACONST ( NODE,
TYPE )
Value:
(*UI_EXTRADATACONST_POINTER(NODE, const TYPE))
#define UI_EXTRADATACONST_POINTER(NODE, TYPE)
Definition ui_nodes.h:186

Definition at line 187 of file ui_nodes.h.

◆ UI_EXTRADATACONST_POINTER

#define UI_EXTRADATACONST_POINTER ( NODE,
TYPE )
Value:
((TYPE*)((const char*)NODE + sizeof(uiNode_t)))

Definition at line 186 of file ui_nodes.h.

Function Documentation

◆ UI_AllocNode()

uiNode_t * UI_AllocNode ( const char * name,
const char * type,
bool isDynamic )

Allocate a node into the UI memory.

Note
It's not a dynamic memory allocation. Please only use it at the loading time
Todo
Assert out when we are not in parsing/loading stage
Parameters
[in]nameName of the new node, else nullptr if we don't want to edit it.
[in]typeName of the node behavior
[in]isDynamicAllocate a node in static or dynamic memory
Todo
This method can be merged with UI_AllocNodeWithoutNew. Since all nodes are dynamic, there is no real reason to distinguish between types of allocation.

Definition at line 381 of file ui_nodes.cpp.

References uiNode_t::dynamic, name, type, UI_AllocNodeWithoutNew(), UI_Node_InitNode(), UI_Node_InitNodeDynamic(), and UI_Node_Loading().

Referenced by uiConFuncNode::onLoaded(), UI_AbstractNodeCallCreateChild(), UI_AllocOptionNode(), UI_CreateComponent(), UI_CreateControl(), UI_CreateWindow(), UI_ParseComponent(), UI_ParseNode(), UI_ParseWindow(), UI_Window_SetCloseButton(), and UI_Window_SetDragButton().

◆ UI_CheckVisibility()

bool UI_CheckVisibility ( uiNode_t * node)

Check the if conditions for a given node.

See also
V_UI_IF
Returns
false if the node is not drawn due to not meet if conditions

Definition at line 152 of file ui_nodes.cpp.

References uiNode_t::lua_onVisibleWhen, uiCallContext_t::source, UI_ExecuteLuaEventScript_ReturnBool(), UI_GetBooleanFromExpression(), uiCallContext_t::useCmdParam, and uiNode_t::visibilityCondition.

Referenced by UI_CheckMouseMove(), UI_DrawModelNode(), UI_DrawNode(), and UI_GetNodeInTreeAtPosition().

◆ UI_CloneNode()

uiNode_t * UI_CloneNode ( const uiNode_t * node,
uiNode_t * newWindow,
bool recursive,
const char * newName,
bool isDynamic )

Clone a node.

Parameters
[in]nodeNode to clone
[in]recursiveTrue if we also must clone subnodes
[in]newWindowWindow where the nodes must be add (this function only link node into window, not window into the new node)
[in]newNameNew node name, else nullptr to use the source name
[in]isDynamicAllocate a node in static or dynamic memory
Todo

exclude rect is not safe cloned.

actions are not cloned. It is be a problem if we use add/remove listener into a cloned node.

Definition at line 409 of file ui_nodes.cpp.

References Com_Printf(), uiNode_t::dynamic, uiNode_t::firstChild, HASH_CloneTable(), uiNode_t::lastChild, uiNode_t::name, uiNode_t::next, uiNode_t::nodeMethods, uiNode_t::parent, Q_strncpyz(), uiNode_t::root, uiNode_t::super, UI_AllocNodeWithoutNew(), UI_AppendNode(), UI_CloneNode(), UI_Node_Clone(), UI_Node_GetMemorySize(), UI_Node_GetWidgetName(), and UI_Node_InitNodeDynamic().

Referenced by UI_AbstractNodeCallCreateChild(), UI_CloneNode(), UI_CreateComponent(), UI_CreateControl(), UI_CreateWindow(), UI_ParseComponent(), UI_ParseNode(), and UI_ParseWindow().

◆ UI_DeleteAllChild()

void UI_DeleteAllChild ( uiNode_t * node)

Remove all child from a node (only remove dynamic memory allocation nodes).

Parameters
nodeThe node we want to clean

Definition at line 596 of file ui_nodes.cpp.

References uiNode_t::firstChild, uiNode_t::next, and UI_DeleteNode().

Referenced by UI_AbstractNodeCallRemovaAllChild(), UI_DeleteNode(), and uiNode_t_remove_children().

◆ UI_DeleteNode()

◆ UI_GetNodeAtPosition()

uiNode_t * UI_GetNodeAtPosition ( int x,
int y )

◆ UI_GetNodeBehaviour()

uiBehaviour_t * UI_GetNodeBehaviour ( const char * name)

Return a node behaviour by name.

Note
Use a dichotomic search. nodeBehaviourList must be sorted by name.
Parameters
[in]nameBehaviour name requested
Returns
The bahaviour found, else nullptr

Definition at line 559 of file ui_nodes.cpp.

References name, nodeBehaviourList, and NUMBER_OF_BEHAVIOURS.

Referenced by TEST_F(), UFO_AnalyseTestWindow(), UI_AllocNodeWithoutNew(), UI_CreateComponent(), UI_CreateControl(), UI_InitializeNodeBehaviour(), UI_ParseComponent(), UI_ParseNode(), and UI_Shutdown().

◆ UI_GetNodeBehaviourByIndex()

uiBehaviour_t * UI_GetNodeBehaviourByIndex ( int index)

Definition at line 582 of file ui_nodes.cpp.

References index, and nodeBehaviourList.

◆ UI_GetNodeBehaviourCount()

int UI_GetNodeBehaviourCount ( void )

Definition at line 587 of file ui_nodes.cpp.

References NUMBER_OF_BEHAVIOURS.

◆ UI_GetNodeByPath()

uiNode_t * UI_GetNodeByPath ( const char * path)

Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNodePath.

Returns
The requested node, else nullptr if not found
// get keylist node from options_keys node from options window
node = UI_GetNodeByPath("options.options_keys.keylist");
uiNode_t * UI_GetNodeByPath(const char *path)
Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNo...
Definition ui_nodes.cpp:313
void UI_ReadNodePath(const char *path, const uiNode_t *relativeNode, const uiNode_t *iterationNode, uiNode_t **resultNode, const value_t **resultProperty, value_t *luaMethod=nullptr)
Read a path and return every we can use (node and property).
Definition ui_nodes.cpp:219

Definition at line 313 of file ui_nodes.cpp.

References Com_Printf(), and UI_ReadNodePath().

Referenced by GAME_GetImportData(), UI_AddListener_f(), UI_PushDropDownWindow_f(), UI_RemoveListener_f(), and UI_TextScrollEnd().

◆ UI_GetPath()

const char * UI_GetPath ( const uiNode_t * node)

Return a path from a window to a node.

Returns
A path "windowname.nodename.nodename.givennodename"
Note
Use a static buffer for the result
Todo
we can use something faster than cat

Definition at line 174 of file ui_nodes.cpp.

References i, name, uiNode_t::parent, and Q_strcat().

Referenced by _wrap_nodepath(), uiModelNode::doLayout(), uiTextNode::doLayout(), uiSelectBoxNode::drawOverWindow(), Key_WriteBindings(), uiConFuncNode::onLoaded(), uiFuncNode::onLoaded(), uiImageNode::onLoaded(), uiText2Node::onLoaded(), uiVScrollbarNode::onLoaded(), uiTabNode::onWindowOpened(), UI_AbstractOption_GetCurrentValue(), UI_AddLineChartCoord(), UI_AddLineChartLine(), UI_AddListener(), UI_ColumnLayout(), UI_CreateControl(), UI_CvarListenerNodeBind(), UI_DeleteNode(), UI_ExecuteActions(), UI_ExecuteCallAction(), UI_ExecuteLuaConFunc(), UI_ExecuteLuaEventScript(), UI_ExecuteLuaEventScript_DragDrop(), UI_ExecuteLuaEventScript_DragDrop_IsDropped(), UI_ExecuteLuaEventScript_DragDrop_XY(), UI_ExecuteLuaEventScript_DxDy(), UI_ExecuteLuaEventScript_Key(), UI_ExecuteLuaEventScript_ParamList(), UI_ExecuteLuaEventScript_ReturnBool(), UI_ExecuteLuaEventScript_XY(), UI_ExecuteLuaMethod(), UI_ExecuteSetAction(), UI_GenInjectedString(), UI_GetFloatFromNodeProperty(), UI_GetNodeAbsPos(), UI_GetNodeFromExpression(), UI_GetNodeScreenPos(), UI_GetStringFromNodeProperty(), UI_InitRawActionValue(), UI_Node_GetText(), UI_NodeSetProperty(), UI_NodeSetPropertyFromRAW(), UI_ParseActionList(), UI_ParseCallAction(), UI_ParseEventProperty(), UI_ParseExcludeRect(), UI_ParseNode(), UI_ParseNodeBody(), UI_ParseNodeProperties(), UI_ParseSetAction(), UI_ShowChartDots(), and UI_ShowChartLine().

◆ UI_InitNodes()

◆ UI_ReadNodePath()

void UI_ReadNodePath ( const char * path,
const uiNode_t * relativeNode,
const uiNode_t * iterationNode,
uiNode_t ** resultNode,
const value_t ** resultProperty,
value_t * luaMethod )

Read a path and return every we can use (node and property).

The path token must be a window name, and then node child. Reserved token 'root' and 'parent' can be used to navigate. If relativeNode is set, the path can start with reserved token 'this', 'root', 'parent' and 'child' (relative to this node). The function can return a node property by using a '@', the path 'foo@pos' will return the window foo and the property 'pos' from the 'window' behaviour.

Parameters
[in]pathPath to read. Contain a node location with dot seprator and a facultative property
[in]relativeNoderelative node where the path start. It allow to use facultative command to start the path (this, parent, root).
[in]iterationNoderelative node referencing child in 'forchildin' iteration, mapped to '*node:child', can be nullptr
[out]resultNodeNode found. Else nullptr.
[out]resultPropertyProperty found. Else nullptr.
[in,out]luaMethodA pointer to a value_t structure that is filled with a lua based method identification, can be nullptr
Note
If luaMethod is set, the method will scan the known lua methods defined on the behaviour. If luaMethod is not set, only registered local properties are scanned.
Todo
Speed up, evilly used function, use strncmp instead of using buffer copy (name[MAX_VAR])
Note
If luaMethod is set, make sure to release the allocated .name string.
Todo
FIXME use a warning instead of an assert

Definition at line 219 of file ui_nodes.cpp.

References MAX_VAR, name, uiNode_t::parent, Q_streq, Q_strncpyz(), uiNode_t::root, value_t::type, UI_GetNode(), UI_GetPropertyOrLuaMethod(), UI_GetWindow(), UI_Node_IsWindow(), and UI_WindowNodeGetIndexedChild().

Referenced by UI_AddListener_f(), UI_ExecuteCallAction(), UI_ExecuteSetAction(), UI_GenInjectedString(), UI_GetBooleanFromExpression(), UI_GetNodeByPath(), UI_GetNodeFromExpression(), UI_RemoveListener_f(), and UI_SetKeyBindingEx().