MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Scroll_TextScroll_ThumbFunc

Function Scroll_TextScroll_ThumbFunc

code/ui/ui_shared.cpp:9947–9995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9945}
9946
9947static void Scroll_TextScroll_ThumbFunc(void *p)
9948{
9949 scrollInfo_t *si = (scrollInfo_t*)p;
9950 rectDef_t r;
9951 int pos;
9952 int max;
9953
9954 textScrollDef_t *scrollPtr = (textScrollDef_t*)si->item->typeData;
9955
9956 if (DC->cursory != si->yStart)
9957 {
9958 r.x = si->item->window.rect.x + si->item->window.rect.w - SCROLLBAR_SIZE - 1;
9959 r.y = si->item->window.rect.y + SCROLLBAR_SIZE + 1;
9960 r.h = si->item->window.rect.h - (SCROLLBAR_SIZE*2) - 2;
9961 r.w = SCROLLBAR_SIZE;
9962 max = Item_TextScroll_MaxScroll(si->item);
9963 //
9964 pos = (DC->cursory - r.y - SCROLLBAR_SIZE/2) * max / (r.h - SCROLLBAR_SIZE);
9965 if (pos < 0)
9966 {
9967 pos = 0;
9968 }
9969 else if (pos > max)
9970 {
9971 pos = max;
9972 }
9973
9974 scrollPtr->startPos = pos;
9975 si->yStart = DC->cursory;
9976 }
9977
9978 if (DC->realTime > si->nextScrollTime)
9979 {
9980 // need to scroll which is done by simulating a click to the item
9981 // this is done a bit sideways as the autoscroll "knows" that the item is a listbox
9982 // so it calls it directly
9983 Item_TextScroll_HandleKey(si->item, si->scrollKey, qtrue, qfalse);
9984 si->nextScrollTime = DC->realTime + si->adjustValue;
9985 }
9986
9987 if (DC->realTime > si->nextAdjustTime)
9988 {
9989 si->nextAdjustTime = DC->realTime + SCROLL_TIME_ADJUST;
9990 if (si->adjustValue > SCROLL_TIME_FLOOR)
9991 {
9992 si->adjustValue -= SCROLL_TIME_ADJUSTOFFSET;
9993 }
9994 }
9995}
9996
9997/*
9998=================

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected