UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_dragndrop.cpp File Reference
#include "ui_internal.h"
#include "ui_dragndrop.h"
#include "ui_input.h"
#include "ui_node.h"
#include "ui_sound.h"
#include "node/ui_node_abstractnode.h"
#include "node/ui_node_container.h"
#include "../input/cl_input.h"
Include dependency graph for ui_dragndrop.cpp:

Go to the source code of this file.

Functions

bool UI_DNDIsDragging (void)
 Return true if we are dragging something.
bool UI_DNDIsTargetNode (uiNode_t *node)
 Return true if the requested node is the current target of the DND.
bool UI_DNDIsSourceNode (uiNode_t *node)
 Return true if the requested node is the source of the DND.
int UI_DNDGetType (void)
 Return the current type of the dragging object, else DND_NOTHING.
uiNode_tUI_DNDGetTargetNode (void)
 Return target of the DND.
uiNode_tUI_DNDGetSourceNode (void)
 Return source of the DND.
static void UI_DNDDrag (uiNode_t *node)
 Private function to initialize a the start of a DND.
void UI_DNDDragItem (uiNode_t *node, const Item *item)
 Start to drag an item.
static void UI_DNDCleanup (void)
 Cleanup data about DND.
void UI_DNDAbort (void)
 Drop the object at the current position.
void UI_DNDDrop (void)
 Drop the object at the current position.
ItemUI_DNDGetItem (void)
static void UI_DNDMouseMove (int mousePosX, int mousePosY)
 Manage the DND when we move the mouse.
void UI_DrawDragAndDrop (int mousePosX, int mousePosY)
 Draw to dragging object and catch mouse move event.

Variables

static int oldMousePosX = -1
static int oldMousePosY = -1
static bool nodeAcceptDND = false
static bool positionAcceptDND = false
static uiDNDType_t objectType
static Item draggingItem
static uiNode_tsourceNode
static uiNode_ttargetNode

Function Documentation

◆ UI_DNDAbort()

◆ UI_DNDCleanup()

void UI_DNDCleanup ( void )
inlinestatic

Cleanup data about DND.

Definition at line 135 of file ui_dragndrop.cpp.

References DND_NOTHING, objectType, sourceNode, and targetNode.

Referenced by UI_DNDAbort(), and UI_DNDDrop().

◆ UI_DNDDrag()

void UI_DNDDrag ( uiNode_t * node)
static

Private function to initialize a the start of a DND.

See also
UI_DNDDragItem
UI_DNDDrop
UI_DNDAbort

Definition at line 109 of file ui_dragndrop.cpp.

References DND_SOMETHING, objectType, sourceNode, UI_DNDIsDragging(), and UI_PlaySound().

Referenced by UI_DNDDragItem().

◆ UI_DNDDragItem()

void UI_DNDDragItem ( uiNode_t * node,
const Item * item )

◆ UI_DNDDrop()

◆ UI_DNDGetItem()

◆ UI_DNDGetSourceNode()

uiNode_t * UI_DNDGetSourceNode ( void )

Return source of the DND.

Definition at line 97 of file ui_dragndrop.cpp.

References sourceNode, and UI_DNDIsDragging().

Referenced by uiBaseInventoryNode::onDndEnter(), and uiContainerNode::onDndEnter().

◆ UI_DNDGetTargetNode()

uiNode_t * UI_DNDGetTargetNode ( void )

Return target of the DND.

Definition at line 88 of file ui_dragndrop.cpp.

References targetNode, and UI_DNDIsDragging().

Referenced by uiContainerNode::onDndFinished().

◆ UI_DNDGetType()

int UI_DNDGetType ( void )

Return the current type of the dragging object, else DND_NOTHING.

Definition at line 80 of file ui_dragndrop.cpp.

References objectType.

Referenced by uiBaseInventoryNode::draw(), uiContainerNode::draw(), uiBaseInventoryNode::onDndEnter(), and uiContainerNode::onDndEnter().

◆ UI_DNDIsDragging()

◆ UI_DNDIsSourceNode()

bool UI_DNDIsSourceNode ( uiNode_t * node)

Return true if the requested node is the source of the DND.

Definition at line 70 of file ui_dragndrop.cpp.

References sourceNode, and UI_DNDIsDragging().

Referenced by UI_ContainerNodeDrawFreeSpace().

◆ UI_DNDIsTargetNode()

bool UI_DNDIsTargetNode ( uiNode_t * node)

Return true if the requested node is the current target of the DND.

Definition at line 60 of file ui_dragndrop.cpp.

References targetNode, and UI_DNDIsDragging().

Referenced by uiContainerNode::draw().

◆ UI_DNDMouseMove()

void UI_DNDMouseMove ( int mousePosX,
int mousePosY )
static

Manage the DND when we move the mouse.

Definition at line 199 of file ui_dragndrop.cpp.

References mousePosX, mousePosY, nodeAcceptDND, positionAcceptDND, targetNode, UI_GetNodeAtPosition(), UI_Node_DndEnter(), UI_Node_DndLeave(), and UI_Node_DndMove().

Referenced by UI_DrawDragAndDrop().

◆ UI_DrawDragAndDrop()

void UI_DrawDragAndDrop ( int mousePosX,
int mousePosY )

Draw to dragging object and catch mouse move event.

Definition at line 230 of file ui_dragndrop.cpp.

References DND_ITEM, draggingItem, mousePosX, mousePosY, objectType, oldMousePosX, oldMousePosY, positionAcceptDND, scale, UI_DNDMouseMove(), UI_DrawItem(), and VectorSet.

Referenced by UI_DrawCursor().

Variable Documentation

◆ draggingItem

Item draggingItem
static

Save the dragging object

Definition at line 43 of file ui_dragndrop.cpp.

Referenced by UI_DNDDragItem(), UI_DNDGetItem(), and UI_DrawDragAndDrop().

◆ nodeAcceptDND

bool nodeAcceptDND = false
static

Save if the current target node can accept the DND object

Definition at line 39 of file ui_dragndrop.cpp.

Referenced by UI_DNDAbort(), and UI_DNDMouseMove().

◆ objectType

uiDNDType_t objectType
static

Save the type of the object we are dragging

Definition at line 42 of file ui_dragndrop.cpp.

Referenced by UI_DNDAbort(), UI_DNDCleanup(), UI_DNDDrag(), UI_DNDDragItem(), UI_DNDDrop(), UI_DNDGetItem(), UI_DNDGetType(), UI_DNDIsDragging(), and UI_DrawDragAndDrop().

◆ oldMousePosX

int oldMousePosX = -1
static

Save position X of the mouse to know when it move

Definition at line 36 of file ui_dragndrop.cpp.

◆ oldMousePosY

int oldMousePosY = -1
static

Save position Y of the mouse to know when it move

Definition at line 37 of file ui_dragndrop.cpp.

◆ positionAcceptDND

bool positionAcceptDND = false
static

Save if the current position accept the DND object

Definition at line 40 of file ui_dragndrop.cpp.

Referenced by UI_DNDDrop(), UI_DNDMouseMove(), and UI_DrawDragAndDrop().

◆ sourceNode

uiNode_t* sourceNode
static

Node where come from the DND object

Definition at line 45 of file ui_dragndrop.cpp.

Referenced by UI_DNDAbort(), UI_DNDCleanup(), UI_DNDDrag(), UI_DNDDrop(), UI_DNDGetSourceNode(), and UI_DNDIsSourceNode().

◆ targetNode

uiNode_t* targetNode
static