UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node_abstractnode.cpp
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 #include "ui_node_abstractnode.h"
27 #include "../ui_actions.h"
28 #include "../ui_tooltip.h"
29 #include "../ui_behaviour.h"
30 #include "../ui_components.h"
31 #include "../ui_parse.h"
32 #include "../ui_sound.h"
33 #include "../ui_lua.h"
34 
35 #include "../../../common/hashtable.h"
36 #include "../../../common/scripts_lua.h"
37 
38 #ifdef DEBUG
39 
42 static void UI_NodeGetProperty_f (void)
43 {
44  uiNode_t* node;
45  const value_t* property;
46  const char* sValue;
47  float fValue;
48 
49  if (Cmd_Argc() != 2) {
50  Com_Printf("Usage: %s <nodepath@prop>\n", Cmd_Argv(0));
51  return;
52  }
53 
54  UI_ReadNodePath(Cmd_Argv(1), nullptr, nullptr, &node, &property);
55 
56  if (node == nullptr) {
57  Com_Printf("UI_NodeGetProperty_f: Node from path '%s' doesn't exist\n", Cmd_Argv(1));
58  return;
59  }
60 
61  if (property == nullptr) {
62  Com_Printf("UI_NodeGetProperty_f: Property from path '%s' doesn't exist\n", Cmd_Argv(1));
63  return;
64  }
65 
66  /* check string value */
67  sValue = UI_GetStringFromNodeProperty(node, property);
68  if (sValue) {
69  Com_Printf("\"%s\" is \"%s\"\n", Cmd_Argv(1), sValue);
70  return;
71  }
72 
73  /* check float value */
74  fValue = UI_GetFloatFromNodeProperty(node, property);
75  Com_Printf("\"%s\" is \"%f\"\n", Cmd_Argv(1), fValue);
76 }
77 
82 static void UI_NodeSetProperty_f (void)
83 {
84  uiNode_t* node;
85  const value_t* property;
86 
87  if (Cmd_Argc() != 4) {
88  Com_Printf("Usage: %s <nodepath> <prop> <value>\n", Cmd_Argv(0));
89  return;
90  }
91 
92  node = UI_GetNodeByPath(Cmd_Argv(1));
93  if (!node) {
94  Com_Printf("UI_NodeSetProperty_f: Node '%s' not found\n", Cmd_Argv(1));
95  return;
96  }
97 
98  property = UI_GetPropertyFromBehaviour(node->behaviour, Cmd_Argv(2));
99  if (!property) {
100  Com_Printf("Property '%s@%s' doesn't exist\n", UI_GetPath(node), Cmd_Argv(2));
101  return;
102  }
103 
104  UI_NodeSetProperty(node, property, Cmd_Argv(3));
105 }
106 #endif
107 
109 }
110 
112  /* initialize lua events */
113  node->lua_onClick = LUA_NOREF;
114  node->lua_onRightClick = LUA_NOREF;
115  node->lua_onMiddleClick = LUA_NOREF;
116  node->lua_onWheel = LUA_NOREF;
117  node->lua_onWheelDown = LUA_NOREF;
118  node->lua_onWheelUp = LUA_NOREF;
119  node->lua_onFocusGained = LUA_NOREF;
120  node->lua_onFocusLost = LUA_NOREF;
121  node->lua_onKeyPressed = LUA_NOREF;
122  node->lua_onKeyReleased = LUA_NOREF;
123  node->lua_onActivate = LUA_NOREF;
124  node->lua_onLoaded = LUA_NOREF;
125  node->lua_onMouseEnter = LUA_NOREF;
126  node->lua_onMouseLeave = LUA_NOREF;
127  node->lua_onChange = LUA_NOREF;
128  node->lua_onVisibleWhen = LUA_NOREF;
129 
130  node->lua_onDragDropEnter = LUA_NOREF;
131  node->lua_onDragDropLeave = LUA_NOREF;
132  node->lua_onDragDropMove = LUA_NOREF;
133  node->lua_onDragDropDrop = LUA_NOREF;
134  node->lua_onDragDropFinished = LUA_NOREF;
135 }
136 
138 }
139 
140 void uiNode::clone(uiNode_t const* source, uiNode_t* clone) {
141 }
142 
144  if (node->nodeMethods) HASH_DeleteTable(&(node->nodeMethods));
145 }
146 
151 {
152  if (node->onMouseEnter != nullptr) {
154  }
155  if (node->lua_onMouseEnter != LUA_NOREF) {
157  }
158 }
159 
164 {
165  if (node->onMouseLeave != nullptr) {
167  }
168  if (node->lua_onMouseLeave != LUA_NOREF) {
170  }
171 }
172 
174 {
175  if (!node->dragdrop) return false;
176 
177  if (node->lua_onDragDropEnter != LUA_NOREF) {
178  bool result;
180  return result;
181  }
182  return false;
183 }
184 
185 bool uiLocatedNode::onDndMove (uiNode_t* node, int x, int y)
186 {
187  if (!node->dragdrop) return true;
188 
189  if (node->lua_onDragDropMove != LUA_NOREF) {
190  bool result;
191  UI_ExecuteLuaEventScript_DragDrop_XY (node, node->lua_onDragDropMove, x, y, result);
192  return result;
193  }
194  return true;
195 }
196 
198 {
199  if (!node->dragdrop) return;
200 
201  if (node->lua_onDragDropLeave != LUA_NOREF) {
202  bool result;
204  }
205 }
206 
207 bool uiLocatedNode::onDndDrop (uiNode_t* node, int x, int y)
208 {
209  if (!node->dragdrop) return true;
210 
211  if (node->lua_onDragDropDrop != LUA_NOREF) {
212  bool result;
213  UI_ExecuteLuaEventScript_DragDrop_XY (node, node->lua_onDragDropDrop, x, y, result);
214  return result;
215  }
216  return true;
217 }
218 
219 bool uiLocatedNode::onDndFinished (uiNode_t* node, bool isDropped)
220 {
221  if (!node->dragdrop) return isDropped;
222 
223  if (node->lua_onDragDropFinished != LUA_NOREF) {
224  bool result;
226  }
227  return isDropped;
228 }
229 
234 {
235  if (!node->invalidated)
236  return;
237 
238  for (uiNode_t* child = node->firstChild; child; child = child->next) {
239  UI_Node_DoLayout(child);
240  }
241 
242  node->invalidated = false;
243 }
244 
246 {
247  for (uiNode_t* child = node->firstChild; child; child = child->next) {
248  UI_Node_WindowOpened(child, params);
249  }
250 }
251 
253 {
254  for (uiNode_t* child = node->firstChild; child; child = child->next) {
255  UI_Node_WindowClosed(child);
256  }
257 }
258 
260 {
261  for (uiNode_t* child = node->firstChild; child; child = child->next) {
262  UI_Node_WindowActivate(child);
263  }
264 }
265 
270 {
271  if (node->firstChild != nullptr)
272  UI_Invalidate(node);
273 }
274 
276 {
277  if (node->parent != nullptr)
278  UI_Invalidate(node->parent);
279 }
280 
281 static const value_t* propertyWidth;
282 static const value_t* propertyHeight;
283 static const value_t* propertySize;
284 static const value_t* propertyInvis;
285 
286 void uiNode::onPropertyChanged (uiNode_t* node, const value_t* property)
287 {
288  if (property == propertyWidth || property == propertyHeight || property == propertySize) {
289  UI_Node_SizeChanged(node);
290  } else if (property == propertyInvis) {
292  }
293 }
294 
295 static void UI_AbstractNodeCallRemovaAllChild (uiNode_t* node, const uiCallContext_t* context)
296 {
297  if (UI_GetParamNumber(context) != 0) {
298  Com_Printf("UI_AbstractNodeCallRemovaAllChild: Invalid number of parameters\n");
299  return;
300  }
301  UI_DeleteAllChild(node);
302 }
303 
304 static void UI_AbstractNodeCallCreateChild (uiNode_t* node, const uiCallContext_t* context)
305 {
306  uiNode_t* child;
307  uiNode_t* component;
308  const char* name;
309  const char* type;
310 
311  if (UI_GetParamNumber(context) != 2) {
312  Com_Printf("UI_AbstractNodeCallCreateChild: Invalid number of parameters\n");
313  return;
314  }
315 
316  name = UI_GetParam(context, 1);
317  type = UI_GetParam(context, 2);
318 
319  uiNode_t* existingNode = UI_GetNode(node, name);
320  if (existingNode != nullptr) {
321  Com_Printf("UI_AbstractNodeCallCreateChild: Node with name '%s' already exists\n", name);
322  }
323 
324  component = UI_GetComponent(type);
325  if (component) {
326  child = UI_CloneNode(component, node->root, true, name, true);
327  } else {
328  child = UI_AllocNode(name, type, true);
329  }
330 
331  if (child == nullptr) {
332  Com_Printf("UI_AbstractNodeCallCreateChild: Impossible to create the node\n");
333  return;
334  }
335 
336  UI_AppendNode(node, child);
337 }
338 
339 static void UI_AbstractNodeCallDelete (uiNode_t* node, const uiCallContext_t* context)
340 {
341  if (UI_GetParamNumber(context) != 0) {
342  Com_Printf("UI_AbstractNodeCallDelete: Invalid number of parameters\n");
343  return;
344  }
345  UI_DeleteNode(node);
346 }
347 
348 static void UI_AbstractNodeCallDeleteTimed (uiNode_t* node, const uiCallContext_t* context)
349 {
350  if (UI_GetParamNumber(context) != 1) {
351  Com_Printf("UI_AbstractNodeCallDeleteTimed: Invalid number of parameters\n");
352  return;
353  }
354  const char* msStr = UI_GetParam(context, 1);
355  const int ms = atoi(msStr);
356  if (ms <= 0) {
357  UI_DeleteNode(node);
358  } else {
359  node->deleteTime = CL_Milliseconds() + ms;
360  }
361 }
362 
363 bool uiLocatedNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
364 {
365  if (deltaY < 0) {
366  if (node->onWheelUp != nullptr) UI_ExecuteEventActions(node, node->onWheelUp);
367  if (node->lua_onWheelUp != LUA_NOREF) UI_ExecuteLuaEventScript_DxDy (node, node->lua_onWheelUp, deltaX, deltaY);
368  return true;
369  }
370  if (deltaY > 0) {
371  if (node->onWheelDown != nullptr) UI_ExecuteEventActions(node, node->onWheelDown);
372  if (node->lua_onWheelDown != LUA_NOREF) UI_ExecuteLuaEventScript_DxDy (node, node->lua_onWheelDown, deltaX, deltaY);
373  return true;
374  }
375  if (deltaY != 0) {
376  if (node->onWheel != nullptr) UI_ExecuteEventActions(node, node->onWheel);
377  if (node->lua_onWheel != LUA_NOREF) UI_ExecuteLuaEventScript_DxDy (node, node->lua_onWheel, deltaX, deltaY);
378  return true;
379  }
380  return false;
381 }
382 
383 void uiLocatedNode::drawTooltip (const uiNode_t* node, int x, int y) const
384 {
385  UI_Tooltip(node, x, y);
386 }
387 
388 void uiLocatedNode::onLeftClick (uiNode_t* node, int x, int y)
389 {
390  if (node->onClick != nullptr) {
391  UI_ExecuteEventActions(node, node->onClick);
392  UI_PlaySound("click1");
393  }
394  if (node->lua_onClick != LUA_NOREF) {
395  UI_ExecuteLuaEventScript_XY(node, node->lua_onClick, x, y);
396  UI_PlaySound("click1");
397  }
398 }
399 
400 void uiLocatedNode::onRightClick (uiNode_t* node, int x, int y)
401 {
402  if (node->onRightClick != nullptr) {
404  UI_PlaySound("click1");
405  }
406  if (node->lua_onRightClick != LUA_NOREF) {
408  UI_PlaySound("click1");
409  }
410 }
411 
412 void uiLocatedNode::onMiddleClick (uiNode_t* node, int x, int y)
413 {
414  if (node->onMiddleClick != nullptr) {
416  UI_PlaySound("click1");
417  }
418  if (node->lua_onMiddleClick != LUA_NOREF) {
420  UI_PlaySound("click1");
421  }
422 }
423 
425  if (node->lua_onLoaded != LUA_NOREF) {
427  }
428 }
429 
436  if (node->onClick) {
437  UI_ExecuteEventActions(node, node->onClick);
438  }
439  if (node->lua_onActivate != LUA_NOREF) {
441  }
442 }
443 
445  if (node->lua_onFocusGained != LUA_NOREF) {
447  }
448 }
449 
451  if (node->lua_onFocusLost != LUA_NOREF) {
453  }
454 }
455 
456 bool uiLocatedNode::onKeyPressed(uiNode_t* node, unsigned int key, unsigned short unicode) {
457  if (node->lua_onKeyPressed != LUA_NOREF) {
458  UI_ExecuteLuaEventScript_Key(node, node->lua_onKeyPressed, key, unicode);
459  return true;
460  }
461  return false;
462 }
463 
464 bool uiLocatedNode::onKeyReleased(uiNode_t* node, unsigned int key, unsigned short unicode) {
465  if (node->lua_onKeyReleased != LUA_NOREF) {
466  UI_ExecuteLuaEventScript_Key(node, node->lua_onKeyReleased, key, unicode);
467  return true;
468  }
469  return false;
470 }
471 
473 {
474  behaviour->name = "abstractnode";
475  behaviour->isAbstract = true;
476  behaviour->manager = UINodePtr(new uiLocatedNode());
477  behaviour->lua_SWIG_typeinfo = UI_SWIG_TypeQuery("uiNode_t *");
478 
479  /* Top-left position of the node */
480  UI_RegisterNodeProperty(behaviour, "pos", V_POS, uiNode_t, box.pos);
481  /* Size of the node */
482  propertySize = UI_RegisterNodeProperty(behaviour, "size", V_POS, uiNode_t, box.size);
483  /* Width of the node (see also <code>size</code>) */
484  propertyWidth = UI_RegisterNodeProperty(behaviour, "width", V_FLOAT, uiNode_t, box.size[0]);
485  /* Height of the node (see also <code>size</code>) */
486  propertyHeight = UI_RegisterNodeProperty(behaviour, "height", V_FLOAT, uiNode_t, box.size[1]);
487  /* Left position of the node (see also <code>pos</code>) */
488  UI_RegisterNodeProperty(behaviour, "left", V_FLOAT, uiNode_t, box.pos[0]);
489  /* Top position of the node (see also <code>pos</code>) */
490  UI_RegisterNodeProperty(behaviour, "top", V_FLOAT, uiNode_t, box.pos[1]);
491 
492  /* If true, the node name is indexed into the window. We can access to the node with
493  * the path "windowName#nodeName"
494  */
495  UI_RegisterNodeProperty(behaviour, "indexed", V_BOOL, uiNode_t, indexed);
496  /* If true, the node is not displayed nor or activatable. */
497  propertyInvis = UI_RegisterNodeProperty(behaviour, "invis", V_BOOL, uiNode_t, invis);
498  /* If true, the node is disabled. Few nodes support it, fell free to request an update. */
499  UI_RegisterNodeProperty(behaviour, "disabled", V_BOOL, uiNode_t, disabled);
500  /* Text color the node will use when something is disabled. */
501  UI_RegisterNodeProperty(behaviour, "disabledcolor", V_COLOR, uiNode_t, disabledColor);
502  /* If true, the node is not ''tangible''. We click through it, then it will not receive mouse event. */
503  UI_RegisterNodeProperty(behaviour, "ghost", V_BOOL, uiNode_t, ghost);
504  /* Flashing effect. */
505  UI_RegisterNodeProperty(behaviour, "flash", V_BOOL, uiNode_t, flash);
506  /* Speed of the flashing effect */
507  UI_RegisterNodeProperty(behaviour, "flashspeed", V_FLOAT, uiNode_t, flashSpeed);
508  /* Border size we want to display. */
509  UI_RegisterNodeProperty(behaviour, "border", V_INT, uiNode_t, border);
510  /* Padding size we want to use. Few node support it. */
511  UI_RegisterNodeProperty(behaviour, "padding", V_INT, uiNode_t, padding);
512  /* Background color we want to display. */
513  UI_RegisterNodeProperty(behaviour, "bgcolor", V_COLOR, uiNode_t, bgcolor);
514  /* Border color we want to display. */
515  UI_RegisterNodeProperty(behaviour, "bordercolor", V_COLOR, uiNode_t, bordercolor);
516 
517  /*
518  * Used to set the position of the node when the parent use a layout manager.
519  * Else it do nothing.
520  * Available values are: LAYOUTALIGN_TOPLEFT, LAYOUTALIGN_TOP, LAYOUTALIGN_TOPRIGHT,
521  * LAYOUTALIGN_LEFT, LAYOUTALIGN_MIDDLE, LAYOUTALIGN_RIGHT, LAYOUTALIGN_BOTTOMLEFT,
522  * LAYOUTALIGN_BOTTOM, LAYOUTALIGN_BOTTOMRIGHT, LAYOUTALIGN_FILL.
523  * Allowed value depend the layout manager used. The update to date list is into
524  * ui_node_panel.c
525  * @image html http://ufoai.org/wiki/images/Layout.png
526  */
527  UI_RegisterNodeProperty(behaviour, "align", V_INT, uiNode_t, align);
528 
529  /*
530  * Used share an int, only used by 1 behaviour
531  * @todo move it to the right behaviour, delete it
532  */
533  UI_RegisterNodeProperty(behaviour, "num", V_INT, uiNode_t, num);
534 
535  /* Tooltip we want to use. */
536  UI_RegisterNodeProperty(behaviour, "tooltip", V_CVAR_OR_LONGSTRING, uiNode_t, tooltip);
537  /* Text the node will display.
538  */
539  UI_RegisterNodeProperty(behaviour, "string", V_CVAR_OR_LONGSTRING, uiNode_t, text);
540  /* Text font the node will use.
541  * @todo use V_REF_OF_STRING when its possible ('font' is never a cvar).
542  */
543  UI_RegisterNodeProperty(behaviour, "font", V_CVAR_OR_STRING, uiNode_t, font);
544 
545  /* Text color the node will use. */
546  UI_RegisterNodeProperty(behaviour, "color", V_COLOR, uiNode_t, color);
547  /* Text color the node will use when something is selected. */
548  UI_RegisterNodeProperty(behaviour, "selectcolor", V_COLOR, uiNode_t, selectedColor);
549  /* Flashing color */
550  UI_RegisterNodeProperty(behaviour, "flashcolor", V_COLOR, uiNode_t, flashColor);
551  /* Alignement of the text into the node, or elements into blocks. */
552  UI_RegisterNodeProperty(behaviour, "contentalign", V_UI_ALIGN, uiNode_t, contentAlign);
553  /* When <code>invis</code> property is false (default value);
554  * this condition say if the node is visible or not. It use a script expression.
555  */
556  UI_RegisterNodeProperty(behaviour, "visiblewhen", V_UI_IF, uiNode_t, visibilityCondition);
557 
558  /* Called when the user click with left button into the node. */
559  UI_RegisterNodeProperty(behaviour, "onclick", V_UI_ACTION, uiNode_t, onClick);
560  /* Called when the user click with right button into the node. */
561  UI_RegisterNodeProperty(behaviour, "onrclick", V_UI_ACTION, uiNode_t, onRightClick);
562  /* Called when the user click with middle button into the node. */
563  UI_RegisterNodeProperty(behaviour, "onmclick", V_UI_ACTION, uiNode_t, onMiddleClick);
564  /* Called when the user use the mouse wheel over the node. */
565  UI_RegisterNodeProperty(behaviour, "onwheel", V_UI_ACTION, uiNode_t, onWheel);
566  /* Called when the user use the mouse wheel up over the node. */
567  UI_RegisterNodeProperty(behaviour, "onwheelup", V_UI_ACTION, uiNode_t, onWheelUp);
568  /* Called when the user use the mouse wheel down over the node. */
569  UI_RegisterNodeProperty(behaviour, "onwheeldown", V_UI_ACTION, uiNode_t, onWheelDown);
570  /* Called when the mouse enter over the node. */
571  UI_RegisterNodeProperty(behaviour, "onmouseenter", V_UI_ACTION, uiNode_t, onMouseEnter);
572  /* Called when the mouse go out of the node. */
573  UI_RegisterNodeProperty(behaviour, "onmouseleave", V_UI_ACTION, uiNode_t, onMouseLeave);
574  /* Called when the internal content of the nde change. Each behaviour use it how they need it.
575  * @todo Move it where it is need.
576  */
577  UI_RegisterNodeProperty(behaviour, "onchange", V_UI_ACTION, uiNode_t, onChange);
578 
579  /* Special attribute only use into the node description to exclude part of the node
580  * (see also <code>ghost</code>). Rectangle position is relative to the node. */
581  UI_RegisterNodeProperty(behaviour, "excluderect", V_UI_EXCLUDERECT, uiNode_t, firstExcludeRect);
582 
583  /* Remove all child from the node (only dynamic allocated nodes). */
584  UI_RegisterNodeMethod(behaviour, "removeallchild", UI_AbstractNodeCallRemovaAllChild);
585 
586  /* Create a new child with name and type. */
587  UI_RegisterNodeMethod(behaviour, "createchild", UI_AbstractNodeCallCreateChild);
588 
589  /* Delete the node and remove it from his parent. */
590  UI_RegisterNodeMethod(behaviour, "delete", UI_AbstractNodeCallDelete);
591 
592  /* Delete the node in x ms and remove it from his parent. */
593  UI_RegisterNodeMethod(behaviour, "deletetimed", UI_AbstractNodeCallDeleteTimed);
594 
596  Com_RegisterConstInt("ALIGN_UL", ALIGN_UL);
597  Com_RegisterConstInt("ALIGN_UC", ALIGN_UC);
598  Com_RegisterConstInt("ALIGN_UR", ALIGN_UR);
599  Com_RegisterConstInt("ALIGN_CL", ALIGN_CL);
600  Com_RegisterConstInt("ALIGN_CC", ALIGN_CC);
601  Com_RegisterConstInt("ALIGN_CR", ALIGN_CR);
602  Com_RegisterConstInt("ALIGN_LL", ALIGN_LL);
603  Com_RegisterConstInt("ALIGN_LC", ALIGN_LC);
604  Com_RegisterConstInt("ALIGN_LR", ALIGN_LR);
605 
606  /* some commands */
607 #ifdef DEBUG
608  Cmd_AddCommand("debug_mnsetnodeproperty", UI_NodeSetProperty_f, "Set a node property");
609  Cmd_AddCommand("debug_mngetnodeproperty", UI_NodeGetProperty_f, "Get a node property");
610 #endif
611 }
struct uiAction_s * onWheelDown
Definition: ui_nodes.h:142
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
Definition: ui_node.cpp:1019
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition: cmd.cpp:744
bool invalidated
Definition: ui_nodes.h:104
virtual bool onDndDrop(uiNode_t *node, int x, int y)
virtual void onWindowActivate(uiNode_t *node)
virtual void onMouseLeave(uiNode_t *node)
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
Definition: ui_node.cpp:890
uiNode_t * parent
Definition: ui_nodes.h:92
LUA_EVENT lua_onChange
Definition: ui_nodes.h:162
virtual bool onDndMove(uiNode_t *node, int x, int y)
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)
Definition: ui_nodes.cpp:219
virtual void initNodeDynamic(uiNode_t *node)
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
Definition: ui_node.cpp:245
uiNode_t * next
Definition: ui_nodes.h:91
const char * name
Definition: ui_behaviour.h:41
static const value_t * propertyWidth
virtual void onRightClick(uiNode_t *node, int x, int y)
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_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition: ui_node.cpp:1053
virtual void onFocusGained(uiNode_t *node)
virtual void onDndLeave(uiNode_t *node)
uiNode_t * UI_GetComponent(const char *name)
Searches all components for the specified one.
struct uiAction_s * onMouseEnter
Definition: ui_nodes.h:139
virtual void onLoaded(uiNode_t *node)
static void UI_AbstractNodeVisibilityChange(uiNode_t *node)
uiBehaviour_t * behaviour
Definition: ui_nodes.h:83
virtual void onWindowOpened(uiNode_t *node, linkedList_t *params)
struct uiAction_s * onMouseLeave
Definition: ui_nodes.h:140
UINodePtr manager
Definition: ui_behaviour.h:43
LUA_EVENT lua_onKeyPressed
Definition: ui_nodes.h:156
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition: ui_lua.cpp:71
bool UI_ExecuteLuaEventScript_DragDrop_IsDropped(uiNode_t *node, LUA_EVENT event, bool isDropped, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition: ui_lua.cpp:266
#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE)
Initialize a property.
Definition: ui_behaviour.h:91
void UI_PlaySound(const char *soundFile)
Plays a ui sound.
Definition: ui_sound.cpp:35
void HASH_DeleteTable(hashTable_s **t)
Deletes a hash table and sets the pointer to NULL.
Definition: hashtable.cpp:351
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
static void UI_AbstractNodeCallDeleteTimed(uiNode_t *node, const uiCallContext_t *context)
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
Definition: ui_node.cpp:856
void UI_Node_WindowClosed(uiNode_t *node)
Definition: ui_node.cpp:251
bool UI_ExecuteLuaEventScript_DragDrop(uiNode_t *node, LUA_EVENT event, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition: ui_lua.cpp:211
virtual void onLoading(uiNode_t *node)
LUA_EVENT lua_onWheelDown
Definition: ui_nodes.h:152
void UI_DeleteNode(uiNode_t *node)
Definition: ui_nodes.cpp:618
virtual void clone(uiNode_t const *source, uiNode_t *clone)
struct uiAction_s * onClick
Definition: ui_nodes.h:135
LUA_EVENT lua_onMouseLeave
Definition: ui_nodes.h:161
unsigned short unicode
Definition: cl_input.cpp:69
const value_t * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name)
Get a property from a behaviour or his inheritance It use a dichotomic search.
virtual void drawTooltip(const uiNode_t *node, int x, int y) const
LUA_EVENT lua_onMiddleClick
Definition: ui_nodes.h:150
uiNode_t * UI_AllocNode(const char *name, const char *type, bool isDynamic)
Allocate a node into the UI memory.
Definition: ui_nodes.cpp:381
bool dragdrop
Definition: ui_nodes.h:165
uiNode_t * root
Definition: ui_nodes.h:93
static void UI_AbstractNodeCallCreateChild(uiNode_t *node, const uiCallContext_t *context)
unsigned int key
Definition: cl_input.cpp:68
LUA_EVENT lua_onLoaded
Definition: ui_nodes.h:158
LUA_EVENT lua_onRightClick
Definition: ui_nodes.h:149
bool UI_ExecuteLuaEventScript_DxDy(uiNode_t *node, LUA_EVENT event, int dx, int dy)
Executes a lua event handler with (dx,dy) argument.
Definition: ui_lua.cpp:166
LUA_EVENT lua_onFocusGained
Definition: ui_nodes.h:154
#define V_UI_ALIGN
Definition: ui_parse.h:65
struct uiAction_s * onWheelUp
Definition: ui_nodes.h:141
struct uiAction_s * onMiddleClick
Definition: ui_nodes.h:137
LUA_EVENT lua_onDragDropDrop
Definition: ui_nodes.h:173
void UI_DeleteAllChild(uiNode_t *node)
Remove all child from a node (only remove dynamic memory allocation nodes)
Definition: ui_nodes.cpp:596
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition: cmd.cpp:505
SharedPtr< uiNode > UINodePtr
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition: ui_nodes.cpp:174
void * lua_SWIG_typeinfo
Definition: ui_behaviour.h:57
virtual bool onScroll(uiNode_t *node, int deltaX, int deltaY)
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition: ui_actions.cpp:726
#define V_UI_IF
Definition: ui_parse.h:57
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
Definition: ui_lua.cpp:143
LUA_EVENT lua_onKeyReleased
Definition: ui_nodes.h:157
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
Definition: scripts.cpp:198
void UI_Tooltip(const uiNode_t *node, int x, int y)
Wrapper for UI tooltips.
Definition: ui_tooltip.cpp:73
uiNode_t * UI_CloneNode(const uiNode_t *node, uiNode_t *newWindow, bool recursive, const char *newName, bool isDynamic)
Clone a node.
Definition: ui_nodes.cpp:409
Contain the context of the calling of a function.
Definition: ui_actions.h:208
struct uiAction_s * onRightClick
Definition: ui_nodes.h:136
hashTable_s * nodeMethods
Definition: ui_nodes.h:132
virtual bool onDndEnter(uiNode_t *node)
int UI_GetParamNumber(const uiCallContext_t *context)
Definition: ui_actions.cpp:166
void UI_Node_WindowActivate(uiNode_t *node)
Definition: ui_node.cpp:257
virtual void onMiddleClick(uiNode_t *node, int x, int y)
virtual bool onKeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
Definition: ui_actions.cpp:179
void UI_Node_SizeChanged(uiNode_t *node)
Definition: ui_node.cpp:289
#define V_CVAR_OR_LONGSTRING
Definition: ui_parse.h:70
virtual void initNode(uiNode_t *node)
LUA_EVENT lua_onDragDropEnter
Definition: ui_nodes.h:167
#define V_UI_EXCLUDERECT
Definition: ui_parse.h:55
virtual void onFocusLost(uiNode_t *node)
Definition: scripts.h:50
static const value_t * propertyHeight
static const value_t * propertySize
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
Definition: ui_node.cpp:702
node behaviour, how a node work
Definition: ui_behaviour.h:39
LUA_EVENT lua_onVisibleWhen
Definition: ui_nodes.h:163
virtual void onWindowClosed(uiNode_t *node)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
struct uiAction_s * onWheel
Definition: ui_nodes.h:138
virtual void onSizeChanged(uiNode_t *node)
Callback stub.
bool UI_ExecuteLuaEventScript_Key(uiNode_t *node, LUA_EVENT event, unsigned int key, unsigned short unicode)
Executes a lua event handler with (keycode,unicode) argument.
Definition: ui_lua.cpp:189
LUA_EVENT lua_onActivate
Definition: ui_nodes.h:159
LUA_EVENT lua_onMouseEnter
Definition: ui_nodes.h:160
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
LUA_EVENT lua_onDragDropMove
Definition: ui_nodes.h:171
bool UI_ExecuteLuaEventScript_DragDrop_XY(uiNode_t *node, LUA_EVENT event, int x, int y, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition: ui_lua.cpp:238
Definition: scripts.h:52
virtual void deleteNode(uiNode_t *node)
LUA_EVENT lua_onFocusLost
Definition: ui_nodes.h:155
void UI_Node_DoLayout(uiNode_t *node)
Definition: ui_node.cpp:263
virtual void onMouseEnter(uiNode_t *node)
LUA_EVENT lua_onWheelUp
Definition: ui_nodes.h:151
uiNode_t * firstChild
Definition: ui_nodes.h:89
#define V_CVAR_OR_STRING
Definition: ui_parse.h:69
void UI_RegisterAbstractNode(uiBehaviour_t *behaviour)
#define V_UI_ACTION
Definition: ui_parse.h:54
LUA_EVENT lua_onClick
Definition: ui_nodes.h:148
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition: ui_node.cpp:978
static const value_t * propertyInvis
LUA_EVENT lua_onDragDropLeave
Definition: ui_nodes.h:169
static void UI_AbstractNodeCallDelete(uiNode_t *node, const uiCallContext_t *context)
static void UI_AbstractNodeCallRemovaAllChild(uiNode_t *node, const uiCallContext_t *context)
virtual void onLeftClick(uiNode_t *node, int x, int y)
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual bool onDndFinished(uiNode_t *node, bool isDropped)
virtual void onActivate(uiNode_t *node)
Activate the node. Can be used without the mouse (ie. a button will execute onClick) ...
Definition: scripts.h:55
LUA_EVENT lua_onWheel
Definition: ui_nodes.h:153
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
int CL_Milliseconds(void)
Definition: cl_main.cpp:1208
int deleteTime
Definition: ui_nodes.h:113
LUA_EVENT lua_onDragDropFinished
Definition: ui_nodes.h:175
virtual bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)