ui_nodes.c File Reference

#include "ui_main.h"
#include "ui_internal.h"
#include "ui_nodes.h"
#include "ui_parse.h"
#include "ui_input.h"
#include "node/ui_node_abstractnode.h"
#include "node/ui_node_abstractscrollbar.h"
#include "node/ui_node_abstractoption.h"
#include "node/ui_node_abstractvalue.h"
#include "node/ui_node_bar.h"
#include "node/ui_node_base.h"
#include "node/ui_node_baseinventory.h"
#include "node/ui_node_button.h"
#include "node/ui_node_checkbox.h"
#include "node/ui_node_controls.h"
#include "node/ui_node_video.h"
#include "node/ui_node_container.h"
#include "node/ui_node_custombutton.h"
#include "node/ui_node_editor.h"
#include "node/ui_node_ekg.h"
#include "node/ui_node_image.h"
#include "node/ui_node_item.h"
#include "node/ui_node_linechart.h"
#include "node/ui_node_map.h"
#include "node/ui_node_material_editor.h"
#include "node/ui_node_messagelist.h"
#include "node/ui_node_model.h"
#include "node/ui_node_option.h"
#include "node/ui_node_optionlist.h"
#include "node/ui_node_optiontree.h"
#include "node/ui_node_panel.h"
#include "node/ui_node_radar.h"
#include "node/ui_node_radiobutton.h"
#include "node/ui_node_rows.h"
#include "node/ui_node_selectbox.h"
#include "node/ui_node_sequence.h"
#include "node/ui_node_string.h"
#include "node/ui_node_special.h"
#include "node/ui_node_spinner.h"
#include "node/ui_node_tab.h"
#include "node/ui_node_tbar.h"
#include "node/ui_node_text.h"
#include "node/ui_node_text2.h"
#include "node/ui_node_textlist.h"
#include "node/ui_node_textentry.h"
#include "node/ui_node_keybinding.h"
#include "node/ui_node_todo.h"
#include "node/ui_node_vscrollbar.h"
#include "node/ui_node_zone.h"
Include dependency graph for ui_nodes.c:

Go to the source code of this file.

Defines

#define NUMBER_OF_BEHAVIOURS   lengthof(registerFunctions)

Typedefs

typedef void(* registerFunction_t )(uiBehaviour_t *node)

Functions

const value_tUI_GetPropertyFromBehaviour (const uiBehaviour_t *behaviour, const char *name)
 Get a property from a behaviour or his inheritance.
qboolean UI_CheckVisibility (uiNode_t *node)
 Check the if conditions for a given node.
const char * UI_GetPath (const uiNode_t *node)
 Return a path from a window to a node.
void UI_ReadNodePath (const char *path, const uiNode_t *relativeNode, uiNode_t **resultNode, const value_t **resultProperty)
 Read a path and return every we can use (node and property).
uiNode_tUI_GetNodeByPath (const char *path)
 Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNodePath.
static uiNode_tUI_AllocNodeWithoutNew (const char *name, const char *type, qboolean isDynamic)
 Allocate a node into the UI memory (do notr call behaviour->new).
uiNode_tUI_AllocNode (const char *name, const char *type, qboolean isDynamic)
 Allocate a node into the UI memory.
static uiNode_tUI_GetNodeInTreeAtPosition (uiNode_t *node, int rx, int ry)
 Return the first visible node at a position.
uiNode_tUI_GetNodeAtPosition (int x, int y)
 Return the first visible node at a position.
uiBehaviour_tUI_GetNodeBehaviour (const char *name)
 Return a node behaviour by name.
uiBehaviour_tUI_GetNodeBehaviourByIndex (int index)
int UI_GetNodeBehaviourCount (void)
void UI_DeleteAllChild (uiNode_t *node)
 Remove all child from a node (only remove dynamic memory allocation nodes).
void UI_DeleteNode (uiNode_t *node)
uiNode_tUI_CloneNode (const uiNode_t *node, uiNode_t *newWindow, qboolean recursive, const char *newName, qboolean isDynamic)
 Clone a node.
static void UI_InitializeNodeBehaviour (uiBehaviour_t *behaviour)
void UI_InitNodes (void)

Variables

static const registerFunction_t registerFunctions []
 List of functions to register nodes.
static uiBehaviour_t nodeBehaviourList [NUMBER_OF_BEHAVIOURS]
 List of all node behaviours, indexes by nodetype num.
static const int virtualFunctions []
 position of virtual function into node behaviour

Detailed Description

Definition in file ui_nodes.c.


Define Documentation

#define NUMBER_OF_BEHAVIOURS   lengthof(registerFunctions)

Definition at line 136 of file ui_nodes.c.

Referenced by UI_GetNodeBehaviour(), UI_GetNodeBehaviourCount(), and UI_InitNodes().


Typedef Documentation

typedef void(* registerFunction_t)(uiBehaviour_t *node)

Definition at line 76 of file ui_nodes.c.


Function Documentation

uiNode_t* UI_AllocNode ( const char *  name,
const char *  type,
qboolean  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] name Name of the new node, else NULL if we dont want to edit it.
[in] type Name of the node behavior
[in] isDynamic Allocate a node in static or dynamic memory

Definition at line 376 of file ui_nodes.c.

References uiNode_s::behaviour, uiNode_s::dynamic, uiBehaviour_s::new, and UI_AllocNodeWithoutNew().

Referenced by UI_AbstractNodeCallCreateChild(), UI_AddOption(), UI_ConFuncNodeLoaded(), UI_ParseNode(), UI_ParseWindow(), and UI_WindowNodeLoaded().

static uiNode_t* UI_AllocNodeWithoutNew ( const char *  name,
const char *  type,
qboolean  isDynamic 
) [static]

Allocate a node into the UI memory (do notr call behaviour->new).

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] name Name of the new node, else NULL if we dont want to edit it.
[in] type Name of the node behavior
[in] isDynamic Allocate a node in static or dynamic memory

Todo:
fix this hard coded '8' value

Definition at line 321 of file ui_nodes.c.

References uiGlobal_s::adata, uiGlobal_s::adataize, uiNode_s::behaviour, Com_Error(), Com_Printf(), uiGlobal_s::curadata, uiNode_s::dynamic, ERR_FATAL, uiBehaviour_s::extraDataSize, uiBehaviour_s::isAbstract, uiBehaviour_s::loading, Mem_PoolAlloc, uiNode_s::name, uiGlobal_s::numNodes, Q_strncpyz(), qtrue, ui_dynPool, UI_GetNodeBehaviour(), and ui_global.

Referenced by UI_AllocNode(), and UI_CloneNode().

qboolean UI_CheckVisibility ( uiNode_t node  ) 

Check the if conditions for a given node.

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

Definition at line 167 of file ui_nodes.c.

References qfalse, qtrue, uiCallContext_s::source, UI_GetBooleanFromExpression(), uiCallContext_s::useCmdParam, and uiNode_s::visibilityCondition.

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

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

Clone a node.

Parameters:
[in] node Node to clone
[in] recursive True if we also must clone subnodes
[in] newWindow Window where the nodes must be add (this function only link node into window, not window into the new node)
[in] newName New node name, else NULL to use the source name
[in] isDynamic Allocate 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 594 of file ui_nodes.c.

References uiNode_s::behaviour, uiBehaviour_s::clone, Com_Printf(), uiNode_s::dynamic, uiBehaviour_s::extraDataSize, uiNode_s::firstChild, uiNode_s::lastChild, uiNode_s::name, uiBehaviour_s::name, uiBehaviour_s::new, uiNode_s::next, uiNode_s::parent, Q_strncpyz(), uiNode_s::root, uiNode_s::super, UI_AllocNodeWithoutNew(), and UI_AppendNode().

Referenced by UI_AbstractNodeCallCreateChild(), UI_ParseNode(), and UI_ParseWindow().

void UI_DeleteAllChild ( uiNode_t node  ) 

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

Parameters:
node The node we want to clean

Definition at line 529 of file ui_nodes.c.

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

Referenced by UI_AbstractNodeCallRemovaAllChild(), and UI_DeleteNode().

void UI_DeleteNode ( uiNode_t node  ) 

Delete the node and remove it from his parent

Parameters:
node The node we want to delete

Todo:
We must delete all EA_LISTENER too

Definition at line 544 of file ui_nodes.c.

References uiNode_s::behaviour, byte, Com_Printf(), uiBehaviour_s::delete, uiNode_s::dynamic, uiNode_s::firstChild, uiNode_s::parent, uiBehaviour_s::properties, uiBehaviour_s::super, UI_DeleteAllChild(), UI_FreeStringProperty(), UI_GetPath(), UI_RemoveNode(), V_UI_CVAR, and V_UI_MASK.

Referenced by UI_AbstractNodeCallDelete(), UI_DeleteAllChild(), and UI_DeleteOption().

uiNode_t* UI_GetNodeAtPosition ( int  x,
int  y 
) [read]
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] name Behaviour name requested
Returns:
The bahaviour found, else NULL

Definition at line 492 of file ui_nodes.c.

References NUMBER_OF_BEHAVIOURS.

Referenced by UI_AllocNodeWithoutNew(), UI_InitializeNodeBehaviour(), UI_ParseNode(), and UI_Shutdown().

uiBehaviour_t* UI_GetNodeBehaviourByIndex ( int  index  ) 

Definition at line 515 of file ui_nodes.c.

int UI_GetNodeBehaviourCount ( void   ) 

Definition at line 520 of file ui_nodes.c.

References NUMBER_OF_BEHAVIOURS.

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 NULL if not found
 // get keylist node from options_keys node from options window
 node = UI_GetNodeByPath("options.options_keys.keylist");
 @sa UI_ReadNodePath

FIXME warning if it return a peroperty

Definition at line 304 of file ui_nodes.c.

References UI_ReadNodePath().

Referenced by CL_NationStatsUpdate_f(), GAME_CP_CampaignListClick_f(), UI_ActiveVScrollbarNode_f(), UI_AddListener_f(), UI_FireInit_f(), UI_PushDropDownWindow_f(), UI_RemoveListener_f(), and UI_TextScrollEnd().

static uiNode_t* UI_GetNodeInTreeAtPosition ( uiNode_t node,
int  rx,
int  ry 
) [static]

Return the first visible node at a position.

Parameters:
[in] node Node where we must search
[in] rx Relative x position to the parent of the node
[in] ry Relative y position to the parent of the node
Returns:
The first visible node at position, else NULL

Todo:
we should improve the loop (last-to-first)

Definition at line 394 of file ui_nodes.c.

References uiNode_s::behaviour, uiNode_s::excludeRect, uiNode_s::excludeRectNum, uiNode_s::firstChild, uiBehaviour_s::getClientPosition, uiNode_s::ghost, i, uiNode_s::invis, uiBehaviour_s::isVirtual, uiNode_s::next, uiExcludeRect_s::pos, uiNode_s::pos, uiExcludeRect_s::size, uiNode_s::size, UI_CheckVisibility(), and UI_DebugMode().

Referenced by UI_GetNodeAtPosition().

const char* UI_GetPath ( const uiNode_t node  ) 
const value_t* UI_GetPropertyFromBehaviour ( const uiBehaviour_t behaviour,
const char *  name 
) [read]

Get a property from a behaviour or his inheritance.

Parameters:
[in] behaviour Context behaviour
[in] name Property name we search
Returns:
A value_t with the requested name, else NULL

Definition at line 149 of file ui_nodes.c.

References uiBehaviour_s::properties, uiBehaviour_s::super, and UI_FindPropertyByName().

Referenced by UI_ConFuncNodeClose(), UI_ConFuncNodeInit(), UI_FuncNodeLoaded(), UI_GenInjectedString(), UI_GetReferenceFloat(), UI_GetReferenceString(), UI_InitializeNodeBehaviour(), UI_PanelPropertyChanged(), UI_ParseNodeBody(), UI_ParseNodeProperties(), UI_ReadNodePath(), UI_RegisterAbstractNode(), UI_RegisterOptionNode(), and UI_RegisterPanelNode().

static void UI_InitializeNodeBehaviour ( uiBehaviour_t behaviour  )  [static]

Initializes the inheritance (every node extends the abstract node)

Parameters:
behaviour The behaviour to initialize

Todo:
check (when its possible) properties are ordered by name

<

Todo:
not possible at the moment, not sure its the right way

<

Todo:
not possible at the moment, not sure its the right way

Definition at line 676 of file ui_nodes.c.

References byte, Com_Error(), ERR_FATAL, uiBehaviour_s::extends, uiBehaviour_s::extraDataSize, i, uiBehaviour_s::isInitialized, uiBehaviour_s::name, pos, uiBehaviour_s::properties, uiBehaviour_s::propertyCount, qtrue, value_s::string, uiBehaviour_s::super, UI_GetNodeBehaviour(), UI_GetPropertyFromBehaviour(), V_UI_NODEMETHOD, and virtualFunctions.

Referenced by UI_InitNodes().

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

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' and 'parent' (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] path Path to read. Contain a node location with dot seprator and a facultative property
[in] relativeNode relative node where the path start. It allow to use facultative command to start the path (this, parent, root).
[out] resultNode Node found. Else NULL.
[out] resultProperty Property found. Else NULL. TODO Speed up, evilly used function, use strncmp instead of using buffer copy (name[MAX_VAR])

Todo:
find a way to fix the bad cast. only here to remove "discards qualifiers" warning

FIXME use a warning instead of an assert

Definition at line 222 of file ui_nodes.c.

References uiNode_s::behaviour, MAX_VAR, name, uiNode_s::parent, Q_strncpyz(), uiNode_s::root, UI_GetNode(), UI_GetPropertyFromBehaviour(), UI_GetWindow(), ui_windowBehaviour, and UI_WindowNodeGetIndexedChild().

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


Variable Documentation

uiBehaviour_t nodeBehaviourList[NUMBER_OF_BEHAVIOURS] [static]

List of all node behaviours, indexes by nodetype num.

Definition at line 141 of file ui_nodes.c.

List of functions to register nodes.

Note:
Functions must be sorted by node name

Definition at line 82 of file ui_nodes.c.

Referenced by UI_InitNodes().

const int virtualFunctions[] [static]

position of virtual function into node behaviour

Definition at line 638 of file ui_nodes.c.

Referenced by UI_InitializeNodeBehaviour().


Generated by  doxygen 1.6.2