UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 /* prototype */
29 struct uiNode_t;
30 
31 bool UI_Node_IsVirtual (uiNode_t const* node);
32 bool UI_Node_IsDrawable (uiNode_t const* node);
33 bool UI_Node_IsAbstract (uiNode_t const* node);
34 bool UI_Node_IsFunction (uiNode_t const* node);
35 bool UI_Node_IsWindow (uiNode_t const* node);
36 bool UI_Node_IsOptionContainer (uiNode_t const* node);
37 bool UI_Node_IsBattleScape (uiNode_t const* node);
38 bool UI_Node_IsScrollableContainer (uiNode_t const* node);
39 bool UI_Node_IsDrawItselfChild (uiNode_t const* node);
40 bool UI_Node_IsDisabled (uiNode_t const* node);
41 bool UI_Node_IsInvisible (uiNode_t const* node);
42 bool UI_Node_IsGhost (uiNode_t const* node);
43 bool UI_Node_IsFlashing (uiNode_t const* node);
44 
45 const char* UI_Node_GetWidgetName (uiNode_t const* node);
46 intptr_t UI_Node_GetMemorySize (uiNode_t const* node);
47 
48 void UI_Node_Draw (uiNode_t* node);
49 void UI_Node_DrawTooltip (const uiNode_t* node, int x, int y);
50 void UI_Node_DrawOverWindow (uiNode_t* node);
51 void UI_Node_LeftClick (uiNode_t* node, int x, int y);
52 void UI_Node_RightClick (uiNode_t* node, int x, int y);
53 void UI_Node_MiddleClick (uiNode_t* node, int x, int y);
54 bool UI_Node_Scroll (uiNode_t* node, int deltaX, int deltaY);
55 void UI_Node_MouseMove (uiNode_t* node, int x, int y);
56 void UI_Node_MouseDown (uiNode_t* node, int x, int y, int button);
57 void UI_Node_MouseUp (uiNode_t* node, int x, int y, int button);
58 bool UI_Node_MouseLongPress (uiNode_t* node, int x, int y, int button);
59 void UI_Node_MouseEnter (uiNode_t* node);
60 void UI_Node_MouseLeave (uiNode_t* node);
61 bool UI_Node_StartDragging (uiNode_t* node, int startX, int startY, int currentX, int currentY, int button);
62 void UI_Node_CapturedMouseMove (uiNode_t* node, int x, int y);
64 void UI_Node_Loading (uiNode_t* node);
65 void UI_Node_Loaded (uiNode_t* node);
66 void UI_Node_Clone (uiNode_t const* source, uiNode_t* clone);
67 void UI_Node_InitNode (uiNode_t* node);
69 void UI_Node_DeleteNode (uiNode_t* node);
70 void UI_Node_WindowOpened (uiNode_t* node, linkedList_t* params);
71 void UI_Node_WindowClosed (uiNode_t* node);
72 void UI_Node_WindowActivate (uiNode_t* node);
73 void UI_Node_DoLayout (uiNode_t* node);
74 void UI_Node_Activate (uiNode_t* node);
75 void UI_Node_PropertyChanged (uiNode_t* node, const value_t* property);
76 void UI_Node_PosChanged (uiNode_t* node);
77 void UI_Node_SizeChanged (uiNode_t* node);
78 void UI_Node_GetClientPosition (uiNode_t const* node, vec2_t position);
79 bool UI_Node_DndEnter (uiNode_t* node);
80 bool UI_Node_DndMove (uiNode_t* node, int x, int y);
81 void UI_Node_DndLeave (uiNode_t* node);
82 bool UI_Node_DndDrop (uiNode_t* node, int x, int y);
83 bool UI_Node_DndFinished (uiNode_t* node, bool isDroped);
84 void UI_Node_FocusGained (uiNode_t* node);
85 void UI_Node_FocusLost (uiNode_t* node);
86 bool UI_Node_KeyPressed (uiNode_t* node, unsigned int key, unsigned short unicode);
87 bool UI_Node_KeyReleased (uiNode_t* node, unsigned int key, unsigned short unicode);
88 int UI_Node_GetCellWidth (uiNode_t* node);
90 
91 const char* UI_Node_GetText (uiNode_t* node);
92 void UI_Node_SetText (uiNode_t* node, const char* text);
93 const char* UI_Node_GetTooltip (uiNode_t* node);
94 void UI_Node_SetTooltip (uiNode_t* node, const char* tooltip);
95 void UI_Node_SetFont (uiNode_t* node, const char* name);
96 void UI_Node_SetImage (uiNode_t* node, const char* name);
97 void UI_Node_SetDisabled (uiNode_t* node, const bool value);
98 
99 #ifdef DEBUG
100 void UI_Node_DebugCountWidget (uiNode_t* node, int count);
101 #endif
102 
103 bool UI_NodeInstanceOf(const uiNode_t* node, const char* behaviourName);
104 bool UI_NodeInstanceOfPointer(const uiNode_t* node, const uiBehaviour_t* behaviour);
105 bool UI_NodeSetProperty(uiNode_t* node, const value_t* property, const char* value);
106 void UI_NodeSetPropertyFromRAW(uiNode_t* node, const value_t* property, const void* rawValue, int rawType);
107 float UI_GetFloatFromNodeProperty(uiNode_t const* node, const value_t* property);
108 const char* UI_GetStringFromNodeProperty(const uiNode_t* node, const value_t* property);
109 
110 /* visibility */
111 void UI_UnHideNode(uiNode_t* node);
112 void UI_HideNode(uiNode_t* node);
113 void UI_Invalidate(uiNode_t* node);
114 void UI_Validate(uiNode_t* node);
115 void UI_NodeSetPos(uiNode_t* node, vec2_t pos);
116 void UI_NodeSetPos(uiNode_t* node, float x, float y);
117 void UI_NodeSetSize(uiNode_t* node, vec2_t size);
118 void UI_NodeSetSize (uiNode_t* node, float w, float h);
119 void UI_NodeSetBox (uiNode_t* node, float x, float y, float w, float h);
120 
121 /* position */
122 void UI_GetNodeAbsPos(uiNode_t const* node, vec2_t pos);
123 void UI_GetNodeScreenPos(const uiNode_t* node, vec2_t pos);
124 void UI_NodeAbsoluteToRelativePos(uiNode_t const* node, int* x, int* y);
125 void UI_NodeRelativeToAbsolutePoint(const uiNode_t* node, vec2_t pos);
126 void UI_NodeGetPoint(const uiNode_t* node, vec2_t pos, int pointDirection);
127 
128 /* navigation */
129 uiNode_t* UI_GetNode(const uiNode_t* node, const char* name);
130 uiNode_t* UI_GetPrevNode(const uiNode_t* node);
131 uiNode_t* UI_FindNode(const uiNode_t* node, const char* name);
132 void UI_InsertNode(uiNode_t* parent, uiNode_t* prevNode, uiNode_t* newNode);
133 void UI_AppendNode(uiNode_t* parent, uiNode_t* newNode);
134 uiNode_t* UI_RemoveNode(uiNode_t* node, uiNode_t* child);
135 void UI_MoveNode(uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* node);
136 void UI_UpdateRoot(uiNode_t* node, uiNode_t* newRoot);
137 
138 /* extended node behaviour */
139 void UI_Node_SetItem (uiNode_t* node, const char* name, LUA_METHOD fcn);
140 LUA_METHOD UI_Node_GetItem (uiNode_t* node, const char* name);
141 
142 void UI_AddNodeMethod (uiNode_t* node, const char* name, LUA_METHOD fcn);
143 bool UI_GetNodeMethod (const uiNode_t* node, const char* name, LUA_METHOD &fcn);
144 bool UI_HasNodeMethod (uiNode_t* node, const char* name);
void UI_Node_Clone(uiNode_t const *source, uiNode_t *clone)
Definition: ui_node.cpp:220
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
Definition: ui_node.cpp:441
static int startX
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
Definition: ui_node.cpp:77
bool UI_Node_IsBattleScape(uiNode_t const *node)
Definition: ui_node.cpp:66
uiNode_t * parent
Definition: ui_nodes.h:92
const char * UI_Node_GetTooltip(uiNode_t *node)
Definition: ui_node.cpp:397
void UI_Node_DoLayout(uiNode_t *node)
Definition: ui_node.cpp:263
uiNode_t * UI_FindNode(const uiNode_t *node, const char *name)
Recursive searches for a child node by name in the entire subtree.
Definition: ui_node.cpp:733
bool UI_Node_DndEnter(uiNode_t *node)
Definition: ui_node.cpp:303
void UI_Node_MiddleClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:140
void UI_InsertNode(uiNode_t *parent, uiNode_t *prevNode, uiNode_t *newNode)
Insert a node next another one into a node. If prevNode is nullptr add the node on the head of the wi...
Definition: ui_node.cpp:752
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
Definition: ui_node.cpp:575
void UI_Node_SetImage(uiNode_t *node, const char *name)
Definition: ui_node.cpp:392
void UI_HideNode(uiNode_t *node)
Hides a given node.
Definition: ui_node.cpp:623
void UI_Node_FocusLost(uiNode_t *node)
Definition: ui_node.cpp:341
uiBehaviour_t * behaviour
Definition: ui_nodes.h:83
void UI_Node_InitNodeDynamic(uiNode_t *node)
Definition: ui_node.cpp:226
const char * UI_Node_GetText(uiNode_t *node)
Definition: ui_node.cpp:373
char * tooltip
Definition: ui_nodes.h:99
void UI_Node_Loading(uiNode_t *node)
Definition: ui_node.cpp:208
void UI_Node_SetItem(uiNode_t *node, const char *name, LUA_METHOD fcn)
This functions adds a lua based method to the internal uiNode behaviour.
Definition: ui_node.cpp:1147
void UI_GetNodeAbsPos(uiNode_t const *node, vec2_t pos)
Returns the absolute position of a node.
Definition: ui_node.cpp:514
unsigned short unicode
Definition: cl_input.cpp:69
bool UI_Node_IsGhost(uiNode_t const *node)
Definition: ui_node.cpp:414
int UI_Node_GetCellWidth(uiNode_t *node)
Definition: ui_node.cpp:361
bool UI_Node_IsAbstract(uiNode_t const *node)
Definition: ui_node.cpp:72
void UI_Node_CapturedMouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:194
bool UI_Node_KeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:347
bool UI_Node_DndDrop(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:321
bool UI_Node_DndMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:309
void UI_NodeSetPropertyFromRAW(uiNode_t *node, const value_t *property, const void *rawValue, int rawType)
Definition: ui_node.cpp:861
void UI_Node_RightClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:134
void UI_AppendNode(uiNode_t *parent, uiNode_t *newNode)
add a node at the end of the node child
Definition: ui_node.cpp:856
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
Definition: ui_node.cpp:666
void UI_Node_DeleteNode(uiNode_t *node)
Definition: ui_node.cpp:237
void UI_MoveNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *node)
Moves a node in the tree.
Definition: ui_node.cpp:828
bool UI_Node_KeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:353
void UI_NodeSetPos(uiNode_t *node, vec2_t pos)
Update the node size and fire the pos callback.
Definition: ui_node.cpp:646
unsigned int key
Definition: cl_input.cpp:68
void UI_Node_Activate(uiNode_t *node)
Definition: ui_node.cpp:271
void UI_Node_LeftClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:128
intptr_t UI_Node_GetMemorySize(uiNode_t const *node)
Definition: ui_node.cpp:104
static int startY
GLsizei size
Definition: r_gl.h:152
void UI_NodeAbsoluteToRelativePos(uiNode_t const *node, int *x, int *y)
Update an absolute position to a relative one.
Definition: ui_node.cpp:592
float UI_GetFloatFromNodeProperty(uiNode_t const *node, const value_t *property)
Return a float from a node property.
Definition: ui_node.cpp:1019
void UI_NodeSetBox(uiNode_t *node, float x, float y, float w, float h)
Update the node size and height and fire callbacks.
Definition: ui_node.cpp:687
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
Definition: ui_node.cpp:890
bool UI_Node_IsFunction(uiNode_t const *node)
Definition: ui_node.cpp:85
uiNode_t * UI_RemoveNode(uiNode_t *node, uiNode_t *child)
Remove a node from a parent node.
Definition: ui_node.cpp:790
void UI_Node_CapturedMouseLost(uiNode_t *node)
Definition: ui_node.cpp:200
bool UI_Node_IsVirtual(uiNode_t const *node)
Definition: ui_node.cpp:42
void UI_Node_FocusGained(uiNode_t *node)
Definition: ui_node.cpp:335
void UI_Node_WindowActivate(uiNode_t *node)
Definition: ui_node.cpp:257
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition: ui_node.cpp:99
void UI_Node_MouseEnter(uiNode_t *node)
Definition: ui_node.cpp:170
int LUA_METHOD
holds a reference to a lua event handler
Definition: scripts_lua.h:53
void UI_UnHideNode(uiNode_t *node)
Unhides a given node.
Definition: ui_node.cpp:635
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...
Definition: ui_node.cpp:542
bool UI_Node_Scroll(uiNode_t *node, int deltaX, int deltaY)
Definition: ui_node.cpp:146
bool UI_Node_IsWindow(uiNode_t const *node)
Definition: ui_node.cpp:60
bool UI_HasNodeMethod(uiNode_t *node, const char *name)
Returns true if a node method of given name is available on this node or its super.
Definition: ui_node.cpp:1127
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition: ui_node.cpp:1053
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
uiNode_t * UI_GetPrevNode(const uiNode_t *node)
Returns the previous node based on the order of nodes in the parent.
Definition: ui_node.cpp:721
void UI_Node_WindowClosed(uiNode_t *node)
Definition: ui_node.cpp:251
bool UI_Node_DndFinished(uiNode_t *node, bool isDroped)
Definition: ui_node.cpp:327
QGL_EXTERN GLuint count
Definition: r_gl.h:99
bool UI_Node_IsInvisible(uiNode_t const *node)
Definition: ui_node.cpp:410
bool UI_Node_IsDisabled(uiNode_t const *node)
Definition: ui_node.cpp:406
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
Definition: ui_node.cpp:702
void UI_Node_MouseLeave(uiNode_t *node)
Definition: ui_node.cpp:176
void UI_Node_SetFont(uiNode_t *node, const char *name)
Definition: ui_node.cpp:387
void UI_Node_SetDisabled(uiNode_t *node, const bool value)
Definition: ui_node.cpp:422
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
Definition: ui_node.cpp:295
LUA_METHOD UI_Node_GetItem(uiNode_t *node, const char *name)
This functions queries a lua based method in the internal uiNode behaviour.
Definition: ui_node.cpp:1159
void UI_Node_SetText(uiNode_t *node, const char *text)
Definition: ui_node.cpp:382
void UI_Node_Loaded(uiNode_t *node)
Definition: ui_node.cpp:214
void UI_AddNodeMethod(uiNode_t *node, const char *name, LUA_METHOD fcn)
Adds a lua based method to the list of available node methods for calling.
Definition: ui_node.cpp:1082
void UI_Node_PropertyChanged(uiNode_t *node, const value_t *property)
Definition: ui_node.cpp:277
node behaviour, how a node work
Definition: ui_behaviour.h:39
void UI_Node_Draw(uiNode_t *node)
Definition: ui_node.cpp:109
void UI_Node_MouseDown(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:158
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
bool UI_GetNodeMethod(const uiNode_t *node, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this node or its super.
Definition: ui_node.cpp:1104
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
Definition: ui_node.cpp:93
void UI_Node_PosChanged(uiNode_t *node)
Definition: ui_node.cpp:283
void UI_Node_DndLeave(uiNode_t *node)
Definition: ui_node.cpp:315
bool UI_Node_IsDrawable(uiNode_t const *node)
Definition: ui_node.cpp:48
bool UI_Node_StartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Definition: ui_node.cpp:188
bool UI_NodeInstanceOfPointer(const uiNode_t *node, const uiBehaviour_t *behaviour)
Check the node inheritance.
Definition: ui_node.cpp:456
vec_t vec2_t[2]
Definition: ufotypes.h:38
void UI_Node_InitNode(uiNode_t *node)
Definition: ui_node.cpp:231
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition: ui_node.cpp:978
void UI_Validate(uiNode_t *node)
Validate a node tree.
Definition: ui_node.cpp:1066
int UI_Node_GetCellHeight(uiNode_t *node)
Definition: ui_node.cpp:367
void UI_Node_MouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:152
void UI_Node_DrawOverWindow(uiNode_t *node)
Definition: ui_node.cpp:121
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int pointDirection)
return a relative position of a point into a node.
Definition: ui_node.cpp:472
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
Definition: ui_node.cpp:245
bool UI_Node_MouseLongPress(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:182
void UI_Node_MouseUp(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:164
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
Definition: ui_node.cpp:115
bool UI_Node_IsFlashing(uiNode_t const *node)
Definition: ui_node.cpp:418
void UI_Node_SizeChanged(uiNode_t *node)
Definition: ui_node.cpp:289
char * text
Definition: ui_nodes.h:121
void UI_Node_SetTooltip(uiNode_t *node, const char *tooltip)
Definition: ui_node.cpp:401
void UI_UpdateRoot(uiNode_t *node, uiNode_t *newRoot)
Definition: ui_node.cpp:841
bool UI_Node_IsOptionContainer(uiNode_t const *node)
Definition: ui_node.cpp:54