MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / OnDraw

Method OnDraw

engine/Poseidon/UI/Controls/UIControlsImpl.cpp:397–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void CListBox::OnDraw(float alpha)
398{
399 const int w = GLOB_ENGINE->Width2D();
400 const int h = GLOB_ENGINE->Height2D();
401
402 float xx = toInt(_x * w) + 0.5;
403 float yy = toInt(_y * h) + 0.5;
404 float ww = toInt(_w * w);
405 float hh = toInt(_h * h);
406
407 PackedColor ftColor = ModAlpha(_ftColor, alpha);
408 PackedColor selColor = ModAlpha(_selColor, alpha);
409
410 // draw list
411 DrawRect(xx, yy, xx + ww, yy + hh, ftColor);
412
413 // draw scrollbar
414 Rect2DFloat rect(_x, _y, _w, _h);
415 if (GetSize() > _showStrings)
416 {
417 _scrollbar.Enable(true);
418 _scrollbar.SetPosition((_x + _w - sbWidth) * _scale, _y * _scale, sbWidth * _scale, _h * _scale);
419 _scrollbar.SetRange(0, GetSize(), _showStrings);
420 _scrollbar.SetPos(_topString);
421 _scrollbar.OnDraw(alpha);
422 rect.w -= sbWidth;
423 }
424 else
425 {
426 _scrollbar.Enable(false);
427 }
428 int i = toIntFloor(_topString);
429 float top = _y - (_topString - i) * _rowHeight;
430 bool canSelect = IsEnabled() /* && !IsReadOnly()*/;
431 while (top < _y + _h && i < GetSize())
432 {
433 DrawItem(alpha, i, i == GetCurSel() && canSelect, top, rect);
434 top += _rowHeight;
435 i++;
436 }
437}
438
439void CListBox::DrawItem(float alpha, int i, bool selected, float top, Rect2DFloat& rect)
440{

Callers

nothing calls this directly

Calls 15

IsEnabledFunction · 0.85
DrawItemClass · 0.85
floatMinFunction · 0.85
saturateMaxFunction · 0.85
floatMaxFunction · 0.85
saturateMinFunction · 0.85
ModAlphaFunction · 0.70
DrawRectFunction · 0.70
Point2DFloatClass · 0.70
Rect2DFloatClass · 0.70
toIntFunction · 0.50
Rect2DPixelClass · 0.50

Tested by

no test coverage detected