/** * @param[in] node Our scrollbar * @param[in] hoveredElement beginarrow, mid, scroll, mid, endarrow * @param[in] allowCapture idk */ static inline void UI_VScrollbarNodeAction (uiNode_t* node, int hoveredElement, bool allowCapture) { switch (hoveredElement) { case 0: UI_VScrollbarNodeDiff(node, -1); if (allowCapture) { UI_SetMouseCapture(node); capturedElement = hoveredElement; capturedTimer = UI_AllocTimer(node, 500, UI_VScrollbarNodeRepeat); UI_TimerStart(capturedTimer); } break; case 1: UI_VScrollbarNodeDiff(node, -10); if (allowCapture) { UI_SetMouseCapture(node); capturedElement = hoveredElement; capturedTimer = UI_AllocTimer(node, 500, UI_VScrollbarNodeRepeat); UI_TimerStart(capturedTimer); } break; case 2: if (allowCapture) { UI_SetMouseCapture(node); /* save start value */ oldMouseY = mousePosY; oldPos = EXTRADATA(node).pos; capturedElement = hoveredElement; } break; case 3: UI_VScrollbarNodeDiff(node, 10); if (allowCapture) { UI_SetMouseCapture(node); capturedElement = hoveredElement; capturedTimer = UI_AllocTimer(node, 500, UI_VScrollbarNodeRepeat); UI_TimerStart(capturedTimer); } break; case 4: UI_VScrollbarNodeDiff(node, 1); if (allowCapture) { UI_SetMouseCapture(node); capturedElement = hoveredElement; capturedTimer = UI_AllocTimer(node, 500, UI_VScrollbarNodeRepeat); UI_TimerStart(capturedTimer); } break; default: assert(false); break; } }
void uiContainerNode::onMouseDown (uiNode_t *node, int x, int y, int button) { switch (button) { case K_MOUSE1: { /* start drag and drop */ int fromX, fromY; dragInfoIC = UI_ContainerNodeGetItemAtPosition(node, x, y, &fromX, &fromY); if (dragInfoIC) { dragInfoFromX = fromX; dragInfoFromY = fromY; oldMouseX = x; oldMouseY = y; UI_SetMouseCapture(node); EXTRADATA(node).lastSelectedId = dragInfoIC->item.item->idx; if (EXTRADATA(node).onSelect) { UI_ExecuteEventActions(node, EXTRADATA(node).onSelect); } } break; } case K_MOUSE2: if (UI_DNDIsDragging()) { UI_DNDAbort(); } else { /* auto place */ UI_ContainerNodeAutoPlace(node, x, y); } break; default: break; } }
/** * @brief Track mouse down/up events to implement drag&drop-like scrolling, for touchscreen devices * @sa UI_OptionListNodeMouseUp, UI_OptionListNodeCapturedMouseMove */ void uiOptionListNode::onMouseDown (uiNode_t* node, int x, int y, int button) { if (!UI_GetMouseCapture() && button == K_MOUSE1 && EXTRADATA(node).scrollY.fullSize > EXTRADATA(node).scrollY.viewSize) { UI_SetMouseCapture(node); mouseScrollX = x; mouseScrollY = y; } }
/** * @brief Track mouse down/up events to implement drag&drop-like scrolling, for touchscreen devices * @sa UI_OptionListNodeMouseUp, UI_OptionListNodeCapturedMouseMove */ static void UI_OptionListNodeMouseDown (struct uiNode_s *node, int x, int y, int button) { if (!UI_GetMouseCapture() && button == K_MOUSE1 && EXTRADATA(node).scrollY.fullSize > EXTRADATA(node).scrollY.viewSize) { UI_SetMouseCapture(node); mouseScrollX = x; mouseScrollY = y; } }
void uiRadarNode::onMouseDown (uiNode_t* node, int x, int y, int button) { if (node->disabled) return; if (button == K_MOUSE1) { UI_SetMouseCapture(node); onCapturedMouseMove(node, x, y); } }
void uiBarNode::onMouseDown (uiNode_t* node, int x, int y, int button) { if (node->disabled || EXTRADATA(node).readOnly) return; if (button == K_MOUSE1) { UI_SetMouseCapture(node); onCapturedMouseMove(node, x, y); } }
static void UI_ZoneNodeDown (uiNode_t *node, int x, int y, int button) { if (!EXTRADATA(node).repeat) return; if (button == K_MOUSE1) { UI_SetMouseCapture(node); capturedTimer = UI_AllocTimer(node, EXTRADATA(node).clickDelay, UI_ZoneNodeRepeat); UI_TimerStart(capturedTimer); } }
void uiModelNode::onMouseDown (uiNode_t* node, int x, int y, int button) { if (button != K_MOUSE1) return; if (!EXTRADATA(node).rotateWithMouse) return; UI_SetMouseCapture(node); oldMousePosX = x; oldMousePosY = y; }
void uiControlNode::onMouseDown (uiNode_t* node, int x, int y, int button) { if (button == K_MOUSE1) { UI_SetMouseCapture(node); /* save position between mouse and node pos */ UI_NodeAbsoluteToRelativePos(node, &x, &y); deltaMouseX = x + node->box.pos[0]; deltaMouseY = y + node->box.pos[1]; } }
void uiGeoscapeNode::startMouseShifting (uiNode_t* node, int x, int y) { UI_SetMouseCapture(node); if (UI_MAPEXTRADATACONST(node).flatgeoscape) mode = MODE_SHIFT2DMAP; else mode = MODE_SHIFT3DMAP; UI_MAPEXTRADATA(node).smoothRotation = false; oldMousePosX = x; oldMousePosY = y; }
/** * @brief Handles selectboxes clicks */ static void UI_SelectBoxNodeClick (uiNode_t *node, int x, int y) { uiNode_t* option; int clickedAtOption; vec2_t pos; /* dropdown the node */ if (UI_GetMouseCapture() == NULL) { UI_SetMouseCapture(node); return; } UI_GetNodeAbsPos(node, pos); clickedAtOption = (y - pos[1]); /* we click outside */ if (x < pos[0] || y < pos[1] || x >= pos[0] + node->size[0] || y >= pos[1] + node->size[1] * (EXTRADATA(node).count + 1)) { UI_MouseRelease(); return; } /* we click on the head */ if (clickedAtOption < node->size[1]) { UI_MouseRelease(); return; } clickedAtOption = (clickedAtOption - node->size[1]) / node->size[1]; if (clickedAtOption < 0 || clickedAtOption >= EXTRADATA(node).count) return; if (UI_AbstractOptionGetCurrentValue(node) == NULL) return; /* select the right option */ option = UI_AbstractOptionGetFirstOption(node); for (; option; option = option->next) { if (option->invis) continue; if (clickedAtOption == 0) break; clickedAtOption--; } /* update the status */ if (option) UI_AbstractOptionSetCurrentValue(node, OPTIONEXTRADATA(option).value); /* close the dropdown */ UI_MouseRelease(); }
void uiSpinnerNode::onMouseDown (uiNode_t *node, int x, int y, int button) { const bool disabled = node->disabled || node->parent->disabled; if (disabled) return; if (button == K_MOUSE1) { UI_SetMouseCapture(node); UI_NodeAbsoluteToRelativePos(node, &x, &y); capturedDownButton = !isPositionIncrease(node, x, y); step(node, capturedDownButton); capturedTimer = UI_AllocTimer(node, 500, UI_SpinnerNodeRepeat); UI_TimerStart(capturedTimer); } }
bool uiGeoscapeNode::onStartDragging (uiNode_t* node, int startX, int startY, int x, int y, int button) { switch (button) { case K_MOUSE1: case K_MOUSE3: startMouseShifting(node, startX, startY); return true; case K_MOUSE2: UI_SetMouseCapture(node); mode = MODE_ZOOMMAP; oldMousePosX = startX; oldMousePosY = startY; return true; } return false; }
static void UI_EditorNodeStart (uiNode_t* node, const uiCallContext_t* context) { UI_SetMouseCapture(node); }