/** * @brief Called when the user wheel the mouse over the node */ static void UI_VScrollbarNodeWheel (uiNode_t *node, int deltaX, int deltaY) { if (deltaY == 0) return; if (EXTRADATA(node).fullsize == 0 || EXTRADATA(node).fullsize < EXTRADATA(node).viewsize) return; UI_VScrollbarNodeSet(node, EXTRADATA(node).pos + deltaY); }
/** * @brief Called when the user wheel the mouse over the node */ bool uiVScrollbarNode::onScroll (uiNode_t* node, int deltaX, int deltaY) { if (deltaY == 0) return false; if (EXTRADATA(node).fullsize == 0 || EXTRADATA(node).fullsize < EXTRADATA(node).viewsize) return false; UI_VScrollbarNodeSet(node, EXTRADATA(node).pos + deltaY); return true; }
/** * @brief Called when the node is captured by the mouse */ void uiVScrollbarNode::onCapturedMouseMove (uiNode_t* node, int x, int y) { if (capturedElement != 2) return; const int posSize = EXTRADATA(node).fullsize; const int graphicSize = node->box.size[1] - (4 * ELEMENT_HEIGHT); /* compute mouse mouse */ y -= oldMouseY; /* compute pos projection */ const int pos = oldPos + (((float)y * (float)posSize) / (float)graphicSize); UI_VScrollbarNodeSet(node, pos); }
/** * @brief Translate the position to a value */ static inline void UI_VScrollbarNodeDiff (uiNode_t *node, int value) { UI_VScrollbarNodeSet(node, EXTRADATA(node).pos + value); }