UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_input.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 #include "ui_main.h"
26 #include "ui_internal.h"
27 #include "ui_actions.h"
28 #include "ui_input.h"
29 #include "ui_internal.h"
30 #include "ui_nodes.h"
31 #include "ui_node.h"
32 #include "ui_parse.h"
33 #include "ui_draw.h"
34 #include "ui_dragndrop.h"
35 #include "ui_timer.h"
36 
37 #include "../input/cl_keys.h"
38 #include "../input/cl_input.h"
39 #include "../cl_shared.h"
40 #include "../battlescape/cl_localentity.h"
41 #include "../battlescape/cl_camera.h"
42 #include "../battlescape/cl_actor.h"
43 #include "../battlescape/cl_battlescape.h"
44 
49 
57 
62 
67 
77 
82 
87 
92 
96 static int pressedNodeButton;
97 
101 #define UI_STARTDRAG_ALREADY_SENT -1
102 
107 #define LONGPRESS_DELAY 800
108 
113 
114 
121 static bool UI_FocusExecuteActionNode (void)
122 {
123 #if 0
124  if (IN_GetMouseSpace() != MS_UI)
125  return false;
126 
127  if (UI_GetMouseCapture())
128  return false;
129 
130  if (focusNode) {
131  if (focusNode->onClick) {
132  UI_ExecuteEventActions(focusNode, focusNode->onClick);
133  }
134  UI_ExecuteEventActions(focusNode, focusNode->onMouseLeave);
135  focusNode = nullptr;
136  return true;
137  }
138 #endif
139  return false;
140 }
141 
142 #if 0
147 static uiNode_t* UI_GetNextActionNode (uiNode_t* node)
148 {
149  if (node)
150  node = node->next;
151  while (node) {
152  if (UI_CheckVisibility(node) && !node->invis
153  && ((node->onClick && node->onMouseEnter) || node->onMouseEnter))
154  return node;
155  node = node->next;
156  }
157  return nullptr;
158 }
159 #endif
160 
167 static bool UI_FocusNextActionNode (void)
168 {
169 #if 0
170  static int i = UI_MAX_WINDOWSTACK + 1; /* to cycle between all windows */
171 
172  if (IN_GetMouseSpace() != MS_UI)
173  return false;
174 
175  if (UI_GetMouseCapture())
176  return false;
177 
178  if (i >= ui_global.windowStackPos)
180 
181  assert(i >= 0);
182 
183  if (focusNode) {
184  uiNode_t* node = UI_GetNextActionNode(focusNode);
185  if (node)
186  return UI_FocusSetNode(node);
187  }
188 
189  while (i < ui_global.windowStackPos) {
190  uiNode_t* window;
191  window = ui_global.windowStack[i++];
192  if (UI_FocusSetNode(UI_GetNextActionNode(window->firstChild)))
193  return true;
194  }
196 
197  /* no node to focus */
198  UI_RemoveFocus();
199 #endif
200  return false;
201 }
202 
207 {
208  uiNode_t* tmp;
209  assert(node);
210  if (node == focusNode)
211  return;
212 
213  /* invalidate the data before calling the event */
214  tmp = focusNode;
215  focusNode = nullptr;
216 
217  /* lost the focus */
218  if (tmp) {
219  UI_Node_FocusLost(tmp);
220  }
221 
222  /* get the focus */
223  focusNode = node;
224  UI_Node_FocusGained(focusNode);
225 }
226 
230 bool UI_HasFocus (const uiNode_t* node)
231 {
232  return node == focusNode;
233 }
234 
241 void UI_RemoveFocus (void)
242 {
243  uiNode_t* tmp;
244 
245  if (UI_GetMouseCapture())
246  return;
247 
248  if (!focusNode)
249  return;
250 
251  /* invalidate the data before calling the event */
252  tmp = focusNode;
253  focusNode = nullptr;
254 
255  /* callback the lost of the focus */
256  UI_Node_FocusLost(tmp);
257 }
258 
260 {
261  uiKeyBinding_t* result;
263  Com_Error(ERR_FATAL, "UI_AllocStaticKeyBinding: UI_MAX_KEYBINDING hit");
264 
267 
268  OBJZERO(*result);
269  return result;
270 }
271 
273 {
274  return ui_global.numKeyBindings;
275 }
276 
278 {
279  return &ui_global.keyBindings[index];
280 }
281 
306 static void UI_SetKeyBindingEx (const char* path, int key, const char* description, bool inherited)
307 {
308  uiNode_t* node;
309  const value_t* property = nullptr;
310 
311  UI_ReadNodePath(path, nullptr, nullptr, &node, &property);
312  if (node == nullptr) {
313  Com_Printf("UI_SetKeyBinding: node \"%s\" not found.\n", path);
314  return;
315  }
316 
317  if (property != nullptr && property->type != V_UI_NODEMETHOD)
318  Com_Error(ERR_FATAL, "UI_SetKeyBinding: Only node and method are supported. Property @%s not found in path \"%s\".", property->string, path);
319 
320  /* init and link the keybinding */
322  binding->node = node;
323  binding->property = property;
324  binding->key = key;
325  binding->inherited = inherited;
326  node->key = binding;
327 
328  if (Q_strnull(description))
329  Com_Printf("Warning: Empty description for UI keybinding: %s (%s)\n", path, Key_KeynumToString(key));
330  else
331  binding->description = Mem_PoolStrDup(description, ui_dynPool, 0);
332 
333  UI_WindowNodeRegisterKeyBinding(node->root, binding);
334 
335  /* search and update windows that extend node->root */
336  for (int windowId = 0; windowId < ui_global.numWindows; windowId++) {
337  uiNode_t* window = ui_global.windows[windowId];
338 
339  /* skip windows which are not direct extends of the main window */
340  if (window->super != node->root)
341  continue;
342 
343  /* create a new patch from the new windows */
344  char newPath[256];
345  newPath[0] = '\0';
346  Q_strcat(newPath, sizeof(newPath), "%s%s", window->name, path + strlen(node->root->name));
347  UI_SetKeyBindingEx(newPath, key, description, true);
348  }
349 }
350 
362 void UI_SetKeyBinding (const char* path, int key, const char* description)
363 {
364  UI_SetKeyBindingEx(path, key, description, false);
365 }
366 
370 static bool UI_KeyPressedInWindow (uiNode_t* window, unsigned int key, unsigned int unicode)
371 {
372  uiNode_t* node;
373  const uiKeyBinding_t* binding;
374 
375  /* search requested key binding */
376  binding = UI_WindowNodeGetKeyBinding(window, key);
377  if (!binding) {
378  /* no binding found, perhaps a lua event handler is attached to this window */
379  UI_Node_KeyPressed (window, key, unicode);
380  return false;
381  }
382 
383  /* check node visibility */
384  node = binding->node;
385  while (node) {
386  if (node->disabled || node->invis)
387  return false;
388  node = node->parent;
389  }
390 
391  /* execute event */
392  node = binding->node;
393  if (binding->property == nullptr)
394  UI_Node_Activate(node);
395  else if (binding->property->type == V_UI_NODEMETHOD) {
396  uiCallContext_t newContext;
397  uiNodeMethod_t func = (uiNodeMethod_t) binding->property->ofs;
398  newContext.source = node;
399  newContext.useCmdParam = false;
400  func(node, &newContext);
401  } else
402  Com_Printf("UI_KeyPressedInWindow: @%s not supported.", binding->property->string);
403 
404  return true;
405 }
406 
413 bool UI_KeyRelease (unsigned int key, unsigned short unicode)
414 {
415  /* translate event into the node with focus */
416  if (focusNode) {
417  return UI_Node_KeyReleased(focusNode, key, unicode);
418  }
419 
420  return false;
421 }
422 
430 bool UI_KeyPressed (unsigned int key, unsigned short unicode)
431 {
432  if (UI_DNDIsDragging()) {
433  if (key == K_ESCAPE) {
434  UI_DNDAbort();
435  return true;
436  }
437  return false;
438  }
439 
440  if (key == K_ESCAPE && CL_BattlescapeRunning()
442  /* Cancel firing with Escape, needed for Android, where right mouse click is bound to multitouch, which is non-obvious */
444  return true;
445  }
446 
447  /* translate event into the node with focus */
448  /* note: this is not executed if the top node is a modal window, see code below */
449  if (focusNode) {
450  if (UI_Node_KeyPressed(focusNode, key, unicode)) {
451  return true;
452  }
453  }
454 
455  /* else use common behaviour */
456  switch (key) {
457  case K_TAB:
459  return true;
460  break;
461  case K_ENTER:
462  case K_KP_ENTER:
464  return true;
465  break;
466  case K_ESCAPE:
467  if (UI_GetMouseCapture() != nullptr) {
468  UI_MouseRelease();
469  return true;
470  }
472  return true;
473  }
474 
475  int lastWindowId = UI_GetLastFullScreenWindow();
476  if (lastWindowId < 0)
477  return false;
478 
479  /* check "active" window from top to down */
480  for (int windowId = ui_global.windowStackPos - 1; windowId >= lastWindowId; windowId--) {
481  uiNode_t* window = ui_global.windowStack[windowId];
482  if (!window)
483  return false;
484  if (UI_KeyPressedInWindow(window, key, unicode))
485  return true;
486  if (UI_WindowIsModal(window))
487  break;
488  }
489 
490  return false;
491 }
492 
496 void UI_ReleaseInput (void)
497 {
498  UI_RemoveFocus();
499  UI_MouseRelease();
500  if (UI_DNDIsDragging())
501  UI_DNDAbort();
502 }
503 
509 {
510  return capturedNode;
511 }
512 
517 {
518  assert(capturedNode == nullptr);
519  assert(node != nullptr);
520  capturedNode = node;
521 }
522 
526 void UI_MouseRelease (void)
527 {
528  uiNode_t* tmp = capturedNode;
529 
530  if (capturedNode == nullptr)
531  return;
532 
533  capturedNode = nullptr;
536 }
537 
538 void UI_ResetInput (void)
539 {
540  hoveredNode = nullptr;
541  oldHoveredNode = nullptr;
542  focusNode = nullptr;
543  capturedNode = nullptr;
544  pressedNode = nullptr;
545  longPressTimer = nullptr;
546 }
547 
553 {
554  return hoveredNode;
555 }
556 
561 {
562  oldMousePosX = -1;
563  oldMousePosY = -1;
564 }
565 
569 bool UI_CheckMouseMove (void)
570 {
571  /* is hovered node no more draw */
572  if (hoveredNode && (hoveredNode->invis || !UI_CheckVisibility(hoveredNode)))
574 
579  return true;
580  }
581 
582  return false;
583 }
584 
588 void UI_MouseMove (int x, int y)
589 {
590  if (UI_DNDIsDragging())
591  return;
592 
593  if (pressedNode && !capturedNode) {
595  UI_TimerStop(longPressTimer);
596  int dist = abs(pressedNodeLocationX - x) + abs(pressedNodeLocationY - y);
597  if (dist > 4) {
598  uiNode_t* node = pressedNode;
599  while (node) {
601  break;
602  node = node->parent;
603  }
605  }
606  }
607  }
608 
609  /* send the captured move mouse event */
610  if (capturedNode) {
611  UI_Node_CapturedMouseMove(capturedNode, x, y);
612  return;
613  }
614 
615  hoveredNode = UI_GetNodeAtPosition(x, y);
616 
617  /* update houvered node by sending messages */
618  if (oldHoveredNode != hoveredNode) {
619  uiNode_t* commonNode = hoveredNode;
620  uiNode_t* node;
621 
622  /* search the common node */
623  while (commonNode) {
624  node = oldHoveredNode;
625  while (node) {
626  if (node == commonNode)
627  break;
628  node = node->parent;
629  }
630  if (node != nullptr)
631  break;
632  commonNode = commonNode->parent;
633  }
634 
635  /* send 'leave' event from old node to common node */
636  node = oldHoveredNode;
637  while (node != commonNode) {
638  UI_Node_MouseLeave(node);
639  node = node->parent;
640  }
641  if (oldHoveredNode)
642  oldHoveredNode->state = false;
643 
644  /* send 'enter' event from common node to new node */
645  while (commonNode != hoveredNode) {
647  node = hoveredNode;
648  while (node->parent != commonNode)
649  node = node->parent;
650  commonNode = node;
651  UI_Node_MouseEnter(node);
652  }
653  if (hoveredNode) {
654  hoveredNode->state = true;
655  UI_Node_MouseEnter(node);
656  }
657  }
658 
659  oldHoveredNode = hoveredNode;
660 
661  /* send the move event */
662  if (hoveredNode)
663  UI_Node_MouseMove(hoveredNode, x, y);
664 }
665 
666 #define UI_IsMouseInvalidate() (oldMousePosX == -1)
667 
675 static void UI_LeftClick (int x, int y)
676 {
677  if (UI_IsMouseInvalidate())
678  return;
679 
680  /* send it to the captured mouse node */
681  if (capturedNode) {
682  UI_Node_LeftClick(capturedNode, x, y);
683  return;
684  }
685 
686  /* if we click outside a dropdown window, we close it */
690  if (!pressedNode && ui_global.windowStackPos != 0) {
692  if (UI_WindowIsDropDown(window)) {
693  UI_PopWindow();
694  }
695  }
696 
697  const bool disabled = (pressedNode == nullptr) || (pressedNode->disabled) || (pressedNode->parent && pressedNode->parent->disabled);
698  if (!disabled) {
699  UI_Node_LeftClick(pressedNode, x, y);
700  }
701 }
702 
710 static void UI_RightClick (int x, int y)
711 {
712  if (UI_IsMouseInvalidate())
713  return;
714 
715  /* send it to the captured mouse node */
716  if (capturedNode) {
717  UI_Node_RightClick(capturedNode, x, y);
718  return;
719  }
720 
721  const bool disabled = (pressedNode == nullptr) || (pressedNode->disabled) || (pressedNode->parent && pressedNode->parent->disabled);
722  if (!disabled) {
723  UI_Node_RightClick(pressedNode, x, y);
724  }
725 }
726 
732 static void UI_MiddleClick (int x, int y)
733 {
734  if (UI_IsMouseInvalidate())
735  return;
736 
737  /* send it to the captured mouse node */
738  if (capturedNode) {
739  UI_Node_MiddleClick(capturedNode, x, y);
740  return;
741  }
742 
743  const bool disabled = (pressedNode == nullptr) || (pressedNode->disabled) || (pressedNode->parent && pressedNode->parent->disabled);
744  if (!disabled) {
745  UI_Node_MiddleClick(pressedNode, x, y);
746  }
747 }
748 
756 void UI_MouseScroll (int deltaX, int deltaY)
757 {
758  uiNode_t* node;
759 
760  /* send it to the captured mouse node */
761  if (capturedNode) {
762  UI_Node_Scroll(capturedNode, deltaX, deltaY);
763  return;
764  }
765 
766  node = hoveredNode;
767 
768  while (node) {
769  if (UI_Node_Scroll(node, deltaX, deltaY)) {
770  break;
771  }
772  node = node->parent;
773  }
774 }
775 
780 {
781  UI_TimerStop(timer);
782 
783  /* make sure the event still make sense */
784  if (pressedNode == nullptr)
785  return;
786 
787  uiNode_t* node = pressedNode;
788  while (node) {
790  break;
791  node = node->parent;
792  }
793 }
794 
801 void UI_MouseDown (int x, int y, int button)
802 {
803  /* disable old long click event */
804  if (longPressTimer)
805  UI_TimerStop(longPressTimer);
806 
807  uiNode_t* node;
808 
809  /* captured or hover node */
810  node = capturedNode ? capturedNode : hoveredNode;
811 
812  if (node != nullptr) {
813  UI_MoveWindowOnTop(node->root);
814  UI_Node_MouseDown(node, x, y, button);
815  }
816 
817  /* select clickableNode on button up, and detect multipress button */
818  if (pressedNode == nullptr) {
819  pressedNode = node;
822  pressedNodeButton = button;
824  if (longPressTimer == nullptr) {
825  longPressTimer = UI_AllocTimer(nullptr, LONGPRESS_DELAY, UI_LongPressCallback);
826  }
827  UI_TimerStart(longPressTimer);
828  } else {
829  pressedNode = nullptr;
830  }
831 }
832 
839 void UI_MouseUp (int x, int y, int button)
840 {
841  /* disable long click event */
842  if (longPressTimer)
843  UI_TimerStop(longPressTimer);
844 
845  /* send click event */
847  if (pressedNode || capturedNode) {
848  switch (button) {
849  case K_MOUSE1:
850  UI_LeftClick(x, y);
851  break;
852  case K_MOUSE2:
853  UI_RightClick(x, y);
854  break;
855  case K_MOUSE3:
856  UI_MiddleClick(x, y);
857  break;
858  }
859  }
860 
861  /* captured or hovered node */
862  uiNode_t* node = nullptr;
863  if (capturedNode) {
864  node = capturedNode;
865  } else if (pressedNode == hoveredNode) {
866  node = hoveredNode;
867  }
868 
869  pressedNode = nullptr;
870  if (node == nullptr)
871  return;
872 
873  UI_Node_MouseUp(node, x, y, button);
874 }
bool Q_strnull(const char *string)
Definition: shared.h:138
uiNode_t * windowStack[UI_MAX_WINDOWSTACK]
Definition: ui_internal.h:77
void UI_RemoveFocus(void)
Definition: ui_input.cpp:241
static uiNode_t * focusNode
save the node with the focus
Definition: ui_input.cpp:48
void UI_MoveWindowOnTop(uiNode_t *window)
Move the window on top of compatible windows. "Compatible" mean non full screen windows, and windows with the same window parent.
Definition: ui_windows.cpp:74
uiKeyBinding_t keyBindings[UI_MAX_KEYBINDING]
Definition: ui_internal.h:89
uiNode_t * parent
Definition: ui_nodes.h:92
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
void UI_Node_MouseUp(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:164
uiNode_t * next
Definition: ui_nodes.h:91
#define UI_STARTDRAG_ALREADY_SENT
Value of pressedNodeLocationX when event already sent.
Definition: ui_input.cpp:101
uiGlobal_t ui_global
Definition: ui_main.cpp:38
void UI_Node_CapturedMouseLost(uiNode_t *node)
Definition: ui_node.cpp:200
bool UI_CheckVisibility(uiNode_t *node)
Check the if conditions for a given node.
Definition: ui_nodes.cpp:152
static bool UI_KeyPressedInWindow(uiNode_t *window, unsigned int key, unsigned int unicode)
Check if a key binding exists for a window and execute it.
Definition: ui_input.cpp:370
int windowStackPos
Definition: ui_internal.h:78
bool UI_Node_MouseLongPress(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:182
uiNode_t * UI_GetNodeAtPosition(int x, int y)
Return the first visible node at a position.
Definition: ui_nodes.cpp:527
bool UI_Node_StartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Definition: ui_node.cpp:188
void UI_WindowNodeRegisterKeyBinding(uiNode_t *node, uiKeyBinding_t *binding)
Add a key binding to a window node. Window node store key bindings for his node child.
#define V_UI_NODEMETHOD
Definition: ui_parse.h:61
bool UI_Node_Scroll(uiNode_t *node, int deltaX, int deltaY)
Definition: ui_node.cpp:146
void UI_DNDAbort(void)
Drop the object at the current position.
char name[MAX_VAR]
Definition: ui_nodes.h:82
struct uiAction_s * onMouseLeave
Definition: ui_nodes.h:140
const struct value_s * property
Definition: ui_input.h:34
void UI_Node_MouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:152
Definition: cl_keys.h:39
const char * description
Definition: ui_input.h:36
static bool UI_FocusNextActionNode(void)
Set the focus to the next action node.
Definition: ui_input.cpp:167
void UI_InvalidateMouse(void)
Force to invalidate the mouse position and then to update hover nodes...
Definition: ui_input.cpp:560
static uiNode_t * oldHoveredNode
save the previous hovered node
Definition: ui_input.cpp:61
uiTimer_t * UI_AllocTimer(uiNode_t *node, int firstDelay, timerCallback_t callback)
Allocate a new time for a node.
Definition: ui_timer.cpp:123
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
static uiNode_t * pressedNode
Store node which receive a mouse down event.
Definition: ui_input.cpp:81
valueTypes_t type
Definition: scripts.h:170
actorModes_t actorMode
static void UI_MiddleClick(int x, int y)
Definition: ui_input.cpp:732
void UI_MouseMove(int x, int y)
Is called every time the mouse position change.
Definition: ui_input.cpp:588
int numKeyBindings
Definition: ui_internal.h:90
struct uiAction_s * onClick
Definition: ui_nodes.h:135
unsigned short unicode
Definition: cl_input.cpp:69
Definition: common.cpp:82
void UI_MouseRelease(void)
Release the captured node.
Definition: ui_input.cpp:526
#define ERR_FATAL
Definition: common.h:210
bool UI_CheckMouseMove(void)
Call mouse move only if the mouse position change.
Definition: ui_input.cpp:569
void UI_Node_RightClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:134
void UI_Node_FocusLost(uiNode_t *node)
Definition: ui_node.cpp:341
Internal data use by the UI package.
C interface to allow to access to cpp node code.
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
static int pressedNodeLocationY
Y position of the mouse when pressedNode != nullptr.
Definition: ui_input.cpp:91
int UI_GetLastFullScreenWindow(void)
Returns the ID of the last fullscreen ID. Before this, window should be hidden.
Definition: ui_windows.cpp:55
static int oldMousePosX
save old position of the mouse
Definition: ui_input.cpp:66
void UI_MouseScroll(int deltaX, int deltaY)
Called when we are in UI mode and scroll via mousewheel.
Definition: ui_input.cpp:756
bool invis
Definition: ui_nodes.h:101
uiNode_t * root
Definition: ui_nodes.h:93
unsigned int key
Definition: cl_input.cpp:68
bool UI_KeyPressed(unsigned int key, unsigned short unicode)
Called by the client when the user type a key.
Definition: ui_input.cpp:430
uiKeyBinding_t * UI_WindowNodeGetKeyBinding(uiNode_t const *const node, unsigned int key)
Search a a key binding from a window node. Window node store key bindings for his node child...
bool state
Definition: ui_nodes.h:106
void UI_SetKeyBinding(const char *path, int key, const char *description)
Set a binding from a key to a node to active.
Definition: ui_input.cpp:362
#define OBJZERO(obj)
Definition: shared.h:178
int mousePosY
Definition: cl_input.cpp:80
void UI_Node_FocusGained(uiNode_t *node)
Definition: ui_node.cpp:335
bool UI_HasFocus(const uiNode_t *node)
check if a node got the focus
Definition: ui_input.cpp:230
bool UI_Node_KeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:347
static int pressedNodeLocationX
X position of the mouse when pressedNode != nullptr.
Definition: ui_input.cpp:86
void UI_Node_Activate(uiNode_t *node)
Definition: ui_node.cpp:271
static int oldMousePosY
Definition: ui_input.cpp:66
void UI_SetMouseCapture(uiNode_t *node)
Captured the mouse into a node.
Definition: ui_input.cpp:516
uiNode_t * source
Definition: ui_actions.h:210
#define UI_MAX_KEYBINDING
Definition: ui_input.h:30
static int pressedNodeButton
Button pressed when pressedNode != nullptr.
Definition: ui_input.cpp:96
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition: ui_actions.cpp:726
#define LONGPRESS_DELAY
Value of the delay to wait before sending a long press event This value is used for Qt 4...
Definition: ui_input.cpp:107
void UI_TimerStop(uiTimer_t *timer)
Stop a timer.
Definition: ui_timer.cpp:163
uiNode_t * UI_GetMouseCapture(void)
Return the captured node.
Definition: ui_input.cpp:508
#define UI_IsMouseInvalidate()
Definition: ui_input.cpp:666
static void UI_RightClick(int x, int y)
Definition: ui_input.cpp:710
bool CL_ActorFireModeActivated(const actorModes_t mode)
Checks whether we are in fire mode or node.
Definition: cl_actor.cpp:1066
memPool_t * ui_dynPool
Definition: ui_main.cpp:41
static uiNode_t * hoveredNode
save the current hovered node (first node under the mouse)
Definition: ui_input.cpp:56
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
uiNode_t * node
Definition: ui_input.h:33
const char * string
Definition: scripts.h:169
void UI_Node_MouseLeave(uiNode_t *node)
Definition: ui_node.cpp:176
bool disabled
Definition: ui_nodes.h:102
uiNode_t * windows[UI_MAX_WINDOWS]
Definition: ui_internal.h:68
bool CL_BattlescapeRunning(void)
Check whether we already have actors spawned on the battlefield.
static bool UI_FocusExecuteActionNode(void)
Execute the current focused action node.
Definition: ui_input.cpp:121
QGL_EXTERN GLuint index
Definition: r_gl.h:110
Contain the context of the calling of a function.
Definition: ui_actions.h:208
static void UI_LeftClick(int x, int y)
Is called every time one clicks on a window/screen. Then checks if anything needs to be executed in t...
Definition: ui_input.cpp:675
size_t ofs
Definition: scripts.h:171
int UI_GetKeyBindingCount(void)
Definition: ui_input.cpp:272
void UI_MouseUp(int x, int y, int button)
Called when we are in UI mode and up a mouse button.
Definition: ui_input.cpp:839
static void UI_LongPressCallback(uiNode_t *, uiTimer_t *timer)
Definition: ui_input.cpp:779
void UI_PopWindowWithEscKey(void)
Definition: ui_windows.cpp:483
le_t * selActor
Definition: cl_actor.cpp:49
int numWindows
Definition: ui_internal.h:69
bool UI_WindowIsModal(uiNode_t const *const node)
True if the window is a modal.
void UI_RequestFocus(uiNode_t *node)
request the focus for a node
Definition: ui_input.cpp:206
QGL_EXTERN GLint i
Definition: r_gl.h:113
void UI_ResetInput(void)
Definition: ui_input.cpp:538
void UI_ReleaseInput(void)
Release all captured input (keyboard or mouse)
Definition: ui_input.cpp:496
uiKeyBinding_t * UI_GetKeyBindingByIndex(int index)
Definition: ui_input.cpp:277
static uiNode_t * capturedNode
save the captured node
Definition: ui_input.cpp:76
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
Definition: shared.cpp:475
static uiTimer_t * longPressTimer
Timer used to manage long press event.
Definition: ui_input.cpp:112
void UI_PopWindow(bool all)
Pops a window from the window stack.
Definition: ui_windows.cpp:452
bool UI_Node_KeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:353
void UI_Node_LeftClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:128
uiNode_t const * super
Definition: ui_nodes.h:84
bool UI_WindowIsDropDown(uiNode_t const *const node)
True if the window is a drop down.
bool inherited
Definition: ui_input.h:37
void UI_Node_MiddleClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:140
const uiKeyBinding_t * binding
uiNode_t * firstChild
Definition: ui_nodes.h:89
void CL_ActorSetMode(le_t *actor, actorModes_t actorMode)
Definition: cl_actor.cpp:835
#define Mem_PoolStrDup(in, pool, tagNum)
Definition: mem.h:50
void UI_Node_MouseDown(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:158
void(* uiNodeMethod_t)(uiNode_t *node, const struct uiCallContext_s *context)
Signature of a function to bind a node method.
Definition: ui_behaviour.h:67
bool UI_DNDIsDragging(void)
Return true if we are dragging something.
const char * Key_KeynumToString(int keynum)
Convert a given keynum to string.
Definition: cl_keys.cpp:485
static void UI_SetKeyBindingEx(const char *path, int key, const char *description, bool inherited)
Set a binding from a key to a node to active.
Definition: ui_input.cpp:306
int mousePosX
Definition: cl_input.cpp:80
#define IN_GetMouseSpace()
Definition: cl_input.h:48
uiNode_t * UI_GetHoveredNode(void)
Get the current hovered node.
Definition: ui_input.cpp:552
void UI_TimerStart(uiTimer_t *timer)
Restart a timer.
Definition: ui_timer.cpp:150
static uiKeyBinding_t * UI_AllocStaticKeyBinding(void)
Definition: ui_input.cpp:259
void UI_Node_CapturedMouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:194
bool UI_KeyRelease(unsigned int key, unsigned short unicode)
Called by the client when the user released a key.
Definition: ui_input.cpp:413
Definition: cl_input.h:33
struct uiKeyBinding_s * key
Definition: ui_nodes.h:100
void UI_MouseDown(int x, int y, int button)
Called when we are in UI mode and down a mouse button.
Definition: ui_input.cpp:801
void UI_Node_MouseEnter(uiNode_t *node)
Definition: ui_node.cpp:170