ui_input.c File Reference

#include "ui_main.h"
#include "ui_internal.h"
#include "ui_actions.h"
#include "ui_input.h"
#include "ui_nodes.h"
#include "ui_parse.h"
#include "ui_draw.h"
#include "ui_dragndrop.h"
#include "ui_sound.h"
#include "../input/cl_keys.h"
#include "../input/cl_input.h"
Include dependency graph for ui_input.c:

Go to the source code of this file.

Defines

#define UI_IsMouseInvalidate   (oldMousePosX == -1)

Functions

static qboolean UI_FocusExecuteActionNode (void)
 Execute the current focused action node.
static qboolean UI_FocusNextActionNode (void)
 Set the focus to the next action node.
void UI_RequestFocus (uiNode_t *node)
 request the focus for a node
qboolean UI_HasFocus (const uiNode_t *node)
 check if a node got the focus
void UI_RemoveFocus (void)
static uiKeyBinding_tUI_AllocStaticKeyBinding (void)
int UI_GetKeyBindingCount (void)
uiKeyBinding_tUI_GetKeyBindingByIndex (int index)
void UI_SetKeyBinding (const char *path, int key)
static qboolean UI_KeyPressedInWindow (unsigned int key, const uiNode_t *window)
 Check if a key binding exists for a window and execute it.
qboolean UI_KeyPressed (unsigned int key, unsigned short unicode)
 Called by the client when the user type a key.
void UI_ReleaseInput (void)
 Release all captured input (keyboard or mouse).
uiNode_tUI_GetMouseCapture (void)
 Return the captured node.
void UI_SetMouseCapture (uiNode_t *node)
 Captured the mouse into a node.
void UI_MouseRelease (void)
 Release the captured node.
uiNode_tUI_GetHoveredNode (void)
 Get the current hovered node.
void UI_InvalidateMouse (void)
 Force to invalidate the mouse position and then to update hover nodes...
qboolean UI_CheckMouseMove (void)
 Call mouse move only if the mouse position change.
void UI_MouseMove (int x, int y)
 Is called every time the mouse position change.
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 the area of the click (e.g. button-commands, inventory-handling, geoscape-stuff, etc...).
static void UI_RightClick (int x, int y)
static void UI_MiddleClick (int x, int y)
void UI_MouseWheel (qboolean down, int x, int y)
 Called when we are in UI mode and scroll via mousewheel.
void UI_MouseDown (int x, int y, int button)
 Called when we are in UI mode and down a mouse button.
void UI_MouseUp (int x, int y, int button)
 Called when we are in UI mode and up a mouse button.

Variables

static uiNode_tfocusNode
 save the node with the focus
static uiNode_thoveredNode
 save the current hovered node (first node under the mouse)
static uiNode_toldHoveredNode
 save the previous hovered node
static int oldMousePosX
 save old position of the mouse
static int oldMousePosY
static uiNode_tcapturedNode
 save the captured node

Detailed Description

Definition in file ui_input.c.


Define Documentation

#define UI_IsMouseInvalidate   (oldMousePosX == -1)

Definition at line 521 of file ui_input.c.

Referenced by UI_LeftClick(), UI_MiddleClick(), and UI_RightClick().


Function Documentation

static uiKeyBinding_t* UI_AllocStaticKeyBinding ( void   )  [static]
qboolean UI_CheckMouseMove ( void   ) 

Call mouse move only if the mouse position change.

Definition at line 439 of file ui_input.c.

References uiNode_s::invis, mousePosX, mousePosY, oldMousePosX, oldMousePosY, qfalse, qtrue, UI_CheckVisibility(), UI_InvalidateMouse(), and UI_MouseMove().

Referenced by UI_Draw().

static qboolean UI_FocusExecuteActionNode ( void   )  [static]

Execute the current focused action node.

Note:
Action nodes are nodes with click defined
See also:
Key_Event
UI_FocusNextActionNode
Todo:
need a cleanup

<

Todo:
need a cleanup

Definition at line 78 of file ui_input.c.

References uiNode_s::onClick, uiNode_s::onMouseLeave, qfalse, qtrue, UI_ExecuteEventActions(), and UI_GetMouseCapture().

Referenced by UI_KeyPressed().

static qboolean UI_FocusNextActionNode ( void   )  [static]

Set the focus to the next action node.

Note:
Action nodes are nodes with click defined
See also:
Key_Event
UI_FocusExecuteActionNode

<

Todo:
need a cleanup

Definition at line 124 of file ui_input.c.

References uiNode_s::firstChild, i, mouseSpace, MS_UI, qfalse, qtrue, UI_GetLastFullScreenWindow(), UI_GetMouseCapture(), ui_global, UI_RemoveFocus(), uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_KeyPressed().

uiNode_t* UI_GetHoveredNode ( void   )  [read]

Get the current hovered node.

Returns:
A node, else NULL if the mouse hover nothing

Definition at line 422 of file ui_input.c.

Referenced by UI_Draw(), and UI_IsPointOnWindow().

uiKeyBinding_t* UI_GetKeyBindingByIndex ( int  index  ) 

Definition at line 238 of file ui_input.c.

References uiGlobal_s::keyBindings, and ui_global.

Referenced by Key_WriteBindings().

int UI_GetKeyBindingCount ( void   ) 

Definition at line 233 of file ui_input.c.

References uiGlobal_s::numKeyBindings, and ui_global.

Referenced by Key_WriteBindings().

uiNode_t* UI_GetMouseCapture ( void   )  [read]
qboolean UI_HasFocus ( const uiNode_t node  ) 

check if a node got the focus

Definition at line 189 of file ui_input.c.

Referenced by UI_KeyBindingNodeClick(), UI_KeyBindingNodeDraw(), UI_TextEntryNodeClick(), UI_TextEntryNodeDraw(), and UI_TextEntryNodeFocus().

void UI_InvalidateMouse ( void   ) 

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

Definition at line 430 of file ui_input.c.

References oldMousePosX, and oldMousePosY.

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

qboolean UI_KeyPressed ( unsigned int  key,
unsigned short  unicode 
)

Called by the client when the user type a key.

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

Definition at line 316 of file ui_input.c.

References uiNode_s::behaviour, K_ENTER, K_ESCAPE, K_KP_ENTER, K_TAB, uiBehaviour_s::keyPressed, qfalse, qtrue, UI_DNDAbort(), UI_DNDIsDragging(), UI_FocusExecuteActionNode(), UI_FocusNextActionNode(), UI_GetLastFullScreenWindow(), UI_GetMouseCapture(), ui_global, UI_KeyPressedInWindow(), UI_MouseRelease(), UI_PopWindowWithEscKey(), UI_WindowIsModal(), uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by Key_Event().

static qboolean UI_KeyPressedInWindow ( unsigned int  key,
const uiNode_t window 
) [static]
static void UI_LeftClick ( int  x,
int  y 
) [static]

Is called every time one clicks on a window/screen. Then checks if anything needs to be executed in the area of the click (e.g. button-commands, inventory-handling, geoscape-stuff, etc...).

See also:
UI_ExecuteEventActions
UI_RightClick
Key_Message

Todo:
need to refactoring it with the focus code (cleaner)
Todo:
at least should be moved on the mouse down event (when the focus should change)

Definition at line 530 of file ui_input.c.

References uiNode_s::behaviour, uiNode_s::disabled, uiBehaviour_s::leftClick, uiNode_s::onClick, uiNode_s::parent, qfalse, UI_ExecuteEventActions(), ui_global, UI_IsMouseInvalidate, UI_PopWindow(), UI_WindowIsDropDown(), uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_MouseDown().

static void UI_MiddleClick ( int  x,
int  y 
) [static]
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
CL_ZoomInQuant
CL_ZoomOutQuant

Todo:
should be send this event when the mouse up (after a down on the same node)

Definition at line 662 of file ui_input.c.

References uiNode_s::behaviour, K_MOUSE1, K_MOUSE2, K_MOUSE3, uiBehaviour_s::mouseDown, uiNode_s::root, UI_LeftClick(), UI_MiddleClick(), UI_MoveWindowOnTop(), UI_PlaySound(), and UI_RightClick().

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

void UI_MouseMove ( int  x,
int  y 
)

Is called every time the mouse position change.

Todo:
we can remove that loop with an array allocation

Definition at line 458 of file ui_input.c.

References uiNode_s::behaviour, uiBehaviour_s::capturedMouseMove, uiBehaviour_s::mouseMove, uiNode_s::onMouseEnter, uiNode_s::onMouseLeave, uiNode_s::parent, qfalse, qtrue, uiNode_s::state, UI_DNDIsDragging(), UI_ExecuteEventActions(), and UI_GetNodeAtPosition().

Referenced by UI_CheckMouseMove().

void UI_MouseRelease ( void   ) 
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
CL_ZoomInQuant
CL_ZoomOutQuant

Definition at line 699 of file ui_input.c.

References uiNode_s::behaviour, and uiBehaviour_s::mouseUp.

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

void UI_MouseWheel ( qboolean  down,
int  x,
int  y 
)

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
CL_ZoomInQuant
CL_ZoomOutQuant

Definition at line 631 of file ui_input.c.

References uiNode_s::behaviour, uiBehaviour_s::mouseWheel, uiNode_s::onWheel, uiNode_s::onWheelDown, uiNode_s::onWheelUp, and UI_ExecuteEventActions().

Referenced by CL_ZoomInQuant_f(), and CL_ZoomOutQuant_f().

void UI_ReleaseInput ( void   ) 

Release all captured input (keyboard or mouse).

Definition at line 374 of file ui_input.c.

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

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

void UI_RemoveFocus ( void   ) 
void UI_RequestFocus ( uiNode_t node  ) 

request the focus for a node

Definition at line 163 of file ui_input.c.

References uiNode_s::behaviour, uiBehaviour_s::focusGained, and uiBehaviour_s::focusLost.

Referenced by UI_KeyBindingNodeClick(), UI_TextEntryNodeClick(), and UI_TextEntryNodeFocus().

static void UI_RightClick ( int  x,
int  y 
) [static]
void UI_SetKeyBinding ( const char *  path,
int  key 
)
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 248 of file ui_input.c.

References binding, Com_Error(), Com_Printf(), ERR_FATAL, uiNode_s::key, uiKeyBinding_s::key, uiKeyBinding_s::node, uiKeyBinding_s::property, uiNode_s::root, UI_AllocStaticKeyBinding(), UI_ReadNodePath(), UI_WindowNodeRegisterKeyBinding(), and V_UI_NODEMETHOD.

Referenced by Key_Bind_f().

void UI_SetMouseCapture ( uiNode_t node  ) 

Variable Documentation

save the captured node

See also:
UI_SetMouseCapture
UI_GetMouseCapture
UI_MouseRelease
Todo:
think about replacing it by a boolean. When capturedNode != NULL => hoveredNode == capturedNode it create unneed case

Definition at line 70 of file ui_input.c.

uiNode_t* focusNode [static]

save the node with the focus

Definition at line 42 of file ui_input.c.

uiNode_t* hoveredNode [static]

save the current hovered node (first node under the mouse)

See also:
UI_GetHoveredNode
UI_MouseMove
UI_CheckMouseMove

Definition at line 50 of file ui_input.c.

save the previous hovered node

Definition at line 55 of file ui_input.c.

int oldMousePosX [static]

save old position of the mouse

Definition at line 60 of file ui_input.c.

Referenced by UI_CheckMouseMove(), and UI_InvalidateMouse().

int oldMousePosY [static]

Definition at line 60 of file ui_input.c.

Referenced by UI_CheckMouseMove(), and UI_InvalidateMouse().


Generated by  doxygen 1.6.2