MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / drawThumb

Method drawThumb

src/Interface/ScrollBar.cpp:265–328  ·  view source on GitHub ↗

* Draws the thumb (button) as a hollow square. */

Source from the content-addressed store, hash-verified

263 * Draws the thumb (button) as a hollow square.
264 */
265void ScrollBar::drawThumb()
266{
267 double scale = (double)getHeight() / _list->getRows();
268 _thumbRect.x = 0;
269 _thumbRect.y = (int)floor(_list->getScroll() * scale);
270 _thumbRect.w = _thumb->getWidth();
271 _thumbRect.h = (int)ceil(_list->getVisibleRows() * scale);
272
273 // Draw base button
274 _thumb->clear();
275 _thumb->lock();
276
277 SDL_Rect square = _thumbRect;
278 int color = _color + 2;
279
280 square.w--;
281 square.h--;
282
283 _thumb->drawRect(&square, color);
284
285 square.x++;
286 square.y++;
287 color = _color + 5;
288
289 _thumb->drawRect(&square, color);
290
291 square.w--;
292 square.h--;
293 color = _color + 4;
294
295 _thumb->drawRect(&square, color);
296
297 _thumb->setPixel(_thumbRect.x, _thumbRect.y, _color + 1);
298 _thumb->setPixel(_thumbRect.x, _thumbRect.y + _thumbRect.h - 1, _color + 4);
299 _thumb->setPixel(_thumbRect.x + _thumbRect.w - 1, _thumbRect.y, _color + 4);
300
301 // Hollow it out
302 color = _color + 5;
303
304 square.x++;
305 square.y++;
306 square.w-=3;
307 square.h-=3;
308
309 _thumb->drawRect(&square, color);
310
311 square.x++;
312 square.y++;
313 color = _color + 2;
314
315 _thumb->drawRect(&square, color);
316
317 square.w--;
318 square.h--;
319 color = 0;
320
321 _thumb->drawRect(&square, color);
322

Callers

nothing calls this directly

Calls 9

getRowsMethod · 0.80
getScrollMethod · 0.80
getVisibleRowsMethod · 0.80
drawRectMethod · 0.80
setPixelMethod · 0.80
unlockMethod · 0.80
getWidthMethod · 0.45
clearMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected