MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / imguiEndScrollArea

Function imguiEndScrollArea

demo/imgui.cpp:376–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376void imguiEndScrollArea()
377{
378 // Disable scissoring.
379 addGfxCmdScissor(-1,-1,-1,-1);
380
381 // Draw scroll bar
382 int x = g_scrollRight+SCROLL_AREA_PADDING/2;
383 int y = g_scrollBottom;
384 int w = SCROLL_AREA_PADDING*2;
385 int h = g_scrollTop - g_scrollBottom;
386
387 int stop = g_scrollAreaTop;
388 int sbot = g_state.widgetY;
389 int sh = stop - sbot; // The scrollable area height.
390
391 float barHeight = (float)h/(float)sh;
392
393 if (barHeight < 1)
394 {
395 float barY = (float)(y - sbot)/(float)sh;
396 if (barY < 0) barY = 0;
397 if (barY > 1) barY = 1;
398
399 // Handle scroll bar logic.
400 unsigned int hid = g_scrollId;
401 int hx = x;
402 int hy = y + (int)(barY*h);
403 int hw = w;
404 int hh = (int)(barHeight*h);
405
406 const int range = h - (hh-1);
407 bool over = inRect(hx, hy, hw, hh);
408 buttonLogic(hid, over);
409 if (isActive(hid))
410 {
411 float u = (float)(hy-y) / (float)range;
412 if (g_state.wentActive)
413 {
414 g_state.dragY = g_state.my;
415 g_state.dragOrig = u;
416 }
417 if (g_state.dragY != g_state.my)
418 {
419 u = g_state.dragOrig + (g_state.my - g_state.dragY) / (float)range;
420 if (u < 0) u = 0;
421 if (u > 1) u = 1;
422 *g_scrollVal = (int)((1-u) * (sh - h));
423 }
424 }
425
426 // BG
427 addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w/2-1, imguiRGBA(0,0,0,196));
428 // Bar
429 if (isActive(hid))
430 addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, imguiRGBA(255,196,0,196));
431 else
432 addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, isHot(hid) ? imguiRGBA(255,196,0,96) : imguiRGBA(255,255,255,64));
433

Callers 1

DoUIFunction · 0.85

Calls 7

addGfxCmdScissorFunction · 0.85
inRectFunction · 0.85
buttonLogicFunction · 0.85
isActiveFunction · 0.85
addGfxCmdRoundedRectFunction · 0.85
imguiRGBAFunction · 0.85
isHotFunction · 0.85

Tested by

no test coverage detected