UFO: Alien Invasion
ui_input.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uiKeyBinding_t
 

Macros

#define UI_MAX_KEYBINDING   128
 

Functions

void UI_SetKeyBinding (const char *path, int key, const char *description)
 Set a binding from a key to a node to active. More...
 
void UI_MouseScroll (int deltaX, int deltaY)
 Called when we are in UI mode and scroll via mousewheel. More...
 
void UI_MouseMove (int x, int y)
 Is called every time the mouse position change. More...
 
void UI_MouseDown (int x, int y, int button)
 Called when we are in UI mode and down a mouse button. More...
 
void UI_MouseUp (int x, int y, int button)
 Called when we are in UI mode and up a mouse button. More...
 
void UI_InvalidateMouse (void)
 Force to invalidate the mouse position and then to update hover nodes... More...
 
bool UI_CheckMouseMove (void)
 Call mouse move only if the mouse position change. More...
 
uiNode_tUI_GetHoveredNode (void)
 Get the current hovered node. More...
 
void UI_ResetInput (void)
 
void UI_RequestFocus (uiNode_t *node)
 request the focus for a node More...
 
bool UI_HasFocus (uiNode_t const *node)
 check if a node got the focus More...
 
void UI_RemoveFocus (void)
 
bool UI_KeyRelease (unsigned int key, unsigned short unicode)
 Called by the client when the user released a key. More...
 
bool UI_KeyPressed (unsigned int key, unsigned short unicode)
 Called by the client when the user type a key. More...
 
int UI_GetKeyBindingCount (void)
 
uiKeyBinding_tUI_GetKeyBindingByIndex (int index)
 
uiNode_tUI_GetMouseCapture (void)
 Return the captured node. More...
 
void UI_SetMouseCapture (uiNode_t *node)
 Captured the mouse into a node. More...
 
void UI_MouseRelease (void)
 Release the captured node. More...
 
void UI_ReleaseInput (void)
 Release all captured input (keyboard or mouse) More...
 

Macro Definition Documentation

◆ UI_MAX_KEYBINDING

#define UI_MAX_KEYBINDING   128

Definition at line 30 of file ui_input.h.

Function Documentation

◆ UI_CheckMouseMove()

bool UI_CheckMouseMove ( void  )

Call mouse move only if the mouse position change.

Definition at line 569 of file ui_input.cpp.

References hoveredNode, uiNode_t::invis, mousePosX, mousePosY, oldMousePosX, oldMousePosY, UI_CheckVisibility(), UI_InvalidateMouse(), and UI_MouseMove().

Referenced by UI_Draw().

◆ UI_GetHoveredNode()

uiNode_t * UI_GetHoveredNode ( void  )

Get the current hovered node.

Returns
A node, else nullptr if the mouse hover nothing

Definition at line 552 of file ui_input.cpp.

References hoveredNode.

Referenced by UI_BeforeDeletingNode(), UI_Draw(), and UI_IsMouseOnWindow().

◆ UI_GetKeyBindingByIndex()

uiKeyBinding_t * UI_GetKeyBindingByIndex ( int  index)

Definition at line 277 of file ui_input.cpp.

References index, uiGlobal_t::keyBindings, and ui_global.

Referenced by CLMN_AddUIBindings(), and Key_WriteBindings().

◆ UI_GetKeyBindingCount()

int UI_GetKeyBindingCount ( void  )

Definition at line 272 of file ui_input.cpp.

References uiGlobal_t::numKeyBindings, and ui_global.

Referenced by CLMN_AddUIBindings(), and Key_WriteBindings().

◆ UI_GetMouseCapture()

◆ UI_HasFocus()

bool UI_HasFocus ( uiNode_t const *  node)

check if a node got the focus

Definition at line 230 of file ui_input.cpp.

References focusNode.

Referenced by uiTextEntryNode::draw(), uiTextEntryNode::onLeftClick(), UI_TextEntryNodeFocus(), and UI_TextEntryNodeUnFocus().

◆ UI_InvalidateMouse()

void UI_InvalidateMouse ( void  )

Force to invalidate the mouse position and then to update hover nodes...

Definition at line 560 of file ui_input.cpp.

References oldMousePosX, and oldMousePosY.

Referenced by UI_BeforeDeletingNode(), UI_CheckMouseMove(), UI_CloseWindowByRef(), UI_DeleteWindowFromStack(), UI_DNDAbort(), UI_DNDDrop(), UI_MouseRelease(), UI_PushWindow(), and UI_Reinit().

◆ UI_KeyPressed()

bool UI_KeyPressed ( unsigned int  key,
unsigned short  unicode 
)

Called by the client when the user type a key.

Parameters
[in]keykey code, either K_ value or lowercase ascii
[in]unicodetranslated meaning of keypress in unicode
Returns
true, if we used the event
Todo:
think about what we should do when the mouse is captured

Definition at line 430 of file ui_input.cpp.

References le_t::actorMode, CL_ActorFireModeActivated(), CL_ActorSetMode(), CL_BattlescapeRunning(), focusNode, K_ENTER, K_ESCAPE, K_KP_ENTER, K_TAB, key, M_MOVE, selActor, UI_DNDAbort(), UI_DNDIsDragging(), UI_FocusExecuteActionNode(), UI_FocusNextActionNode(), UI_GetLastFullScreenWindow(), UI_GetMouseCapture(), ui_global, UI_KeyPressedInWindow(), UI_MouseRelease(), UI_Node_KeyPressed(), UI_PopWindowWithEscKey(), UI_WindowIsModal(), unicode, uiGlobal_t::windowStack, and uiGlobal_t::windowStackPos.

Referenced by Key_Event().

◆ UI_KeyRelease()

bool UI_KeyRelease ( unsigned int  key,
unsigned short  unicode 
)

Called by the client when the user released a key.

Parameters
[in]keykey code, either K_ value or lowercase ascii
[in]unicodetranslated meaning of keypress in unicode
Returns
true, if we used the event

Definition at line 413 of file ui_input.cpp.

References focusNode, key, UI_Node_KeyReleased(), and unicode.

Referenced by Key_Event().

◆ UI_MouseDown()

void UI_MouseDown ( int  x,
int  y,
int  button 
)

Called when we are in UI mode and down a mouse button.

See also
UI_LeftClick
UI_RightClick
UI_MiddleClick
Todo:
find a way to create the timer when UI loading and remove "if (longPressTimer)"

Definition at line 801 of file ui_input.cpp.

References capturedNode, hoveredNode, LONGPRESS_DELAY, longPressTimer, pressedNode, pressedNodeButton, pressedNodeLocationX, pressedNodeLocationY, uiNode_t::root, UI_AllocTimer(), UI_LongPressCallback(), UI_MoveWindowOnTop(), UI_Node_MouseDown(), UI_TimerStart(), and UI_TimerStop().

Referenced by CL_LeftClickDown_f(), CL_MiddleClickDown_f(), and CL_RightClickDown_f().

◆ UI_MouseMove()

◆ UI_MouseRelease()

◆ UI_MouseScroll()

void UI_MouseScroll ( int  deltaX,
int  deltaY 
)

Called when we are in UI mode and scroll via mousewheel.

Note
The geoscape zooming code is here, too (also in
See also
CL_ParseInput)
UI_LeftClick
UI_RightClick
UI_MiddleClick

Definition at line 756 of file ui_input.cpp.

References capturedNode, hoveredNode, uiNode_t::parent, and UI_Node_Scroll().

Referenced by CL_WheelDown_f(), and CL_WheelUp_f().

◆ UI_MouseUp()

void UI_MouseUp ( int  x,
int  y,
int  button 
)

Called when we are in UI mode and up a mouse button.

See also
UI_LeftClick
UI_RightClick
UI_MiddleClick
Todo:
it is really need to clean up this subfunctions

Definition at line 839 of file ui_input.cpp.

References capturedNode, hoveredNode, K_MOUSE1, K_MOUSE2, K_MOUSE3, longPressTimer, pressedNode, UI_LeftClick(), UI_MiddleClick(), UI_Node_MouseUp(), UI_RightClick(), and UI_TimerStop().

Referenced by CL_LeftClickUp_f(), CL_MiddleClickUp_f(), and CL_RightClickUp_f().

◆ UI_ReleaseInput()

void UI_ReleaseInput ( void  )

Release all captured input (keyboard or mouse)

Definition at line 496 of file ui_input.cpp.

References UI_DNDAbort(), UI_DNDIsDragging(), UI_MouseRelease(), and UI_RemoveFocus().

Referenced by IN_Frame(), Key_SetDest(), UI_CloseWindowByRef(), UI_PushWindow(), and UI_Reinit().

◆ UI_RemoveFocus()

◆ UI_RequestFocus()

void UI_RequestFocus ( uiNode_t node)

request the focus for a node

Definition at line 206 of file ui_input.cpp.

References focusNode, UI_Node_FocusGained(), and UI_Node_FocusLost().

Referenced by uiTextEntryNode::onLeftClick(), and UI_TextEntryNodeFocus().

◆ UI_ResetInput()

void UI_ResetInput ( void  )

Definition at line 538 of file ui_input.cpp.

References capturedNode, focusNode, hoveredNode, longPressTimer, oldHoveredNode, and pressedNode.

Referenced by UI_Shutdown().

◆ UI_SetKeyBinding()

void UI_SetKeyBinding ( const char *  path,
int  key,
const char *  description 
)

Set a binding from a key to a node to active.

Parameters
pathPath to a node, or a node method
keyThe key number to use (see for example the K_* names are matched up.)
descriptionTextual description of what the key/cmd does (for tooltip)
Todo:

check: only one binding per nodes?

check: key per window must be unique

check: key used into UI_KeyPressed can't be used

Definition at line 362 of file ui_input.cpp.

References key, and UI_SetKeyBindingEx().

Referenced by Key_Bind_f().

◆ UI_SetMouseCapture()