* Draw a scrollbar widget to the display, relative to its parent. * * @param w The widget (which is a scrollbar) to draw. */
| 360 | * @param w The widget (which is a scrollbar) to draw. |
| 361 | */ |
| 362 | void GUI_Widget_Scrollbar_Draw(Widget *w) |
| 363 | { |
| 364 | WidgetScrollbar *scrollbar; |
| 365 | uint16 positionX, positionY; |
| 366 | uint16 width, height; |
| 367 | uint16 scrollLeft, scrollTop; |
| 368 | uint16 scrollRight, scrollBottom; |
| 369 | |
| 370 | if (w == NULL) return; |
| 371 | if (w->flags.invisible) return; |
| 372 | |
| 373 | scrollbar = w->data; |
| 374 | |
| 375 | width = w->width; |
| 376 | height = w->height; |
| 377 | |
| 378 | positionX = w->offsetX; |
| 379 | if (w->offsetX < 0) positionX += g_widgetProperties[w->parentID].width << 3; |
| 380 | positionX += g_widgetProperties[w->parentID].xBase<< 3; |
| 381 | |
| 382 | positionY = w->offsetY; |
| 383 | if (w->offsetY < 0) positionY += g_widgetProperties[w->parentID].height; |
| 384 | positionY += g_widgetProperties[w->parentID].yBase; |
| 385 | |
| 386 | if (width > height) { |
| 387 | scrollLeft = scrollbar->position + 1; |
| 388 | scrollTop = 1; |
| 389 | scrollRight = scrollLeft + scrollbar->size - 1; |
| 390 | scrollBottom = height - 2; |
| 391 | } else { |
| 392 | scrollLeft = 1; |
| 393 | scrollTop = scrollbar->position + 1; |
| 394 | scrollRight = width - 2; |
| 395 | scrollBottom = scrollTop + scrollbar->size - 1; |
| 396 | } |
| 397 | |
| 398 | if (GFX_Screen_IsActive(SCREEN_0)) { |
| 399 | GUI_Mouse_Hide_InRegion(positionX, positionY, positionX + width - 1, positionY + height - 1); |
| 400 | } |
| 401 | |
| 402 | /* Draw background */ |
| 403 | GUI_DrawFilledRectangle(positionX, positionY, positionX + width - 1, positionY + height - 1, w->bgColourNormal); |
| 404 | |
| 405 | /* Draw where we currently are */ |
| 406 | GUI_DrawFilledRectangle(positionX + scrollLeft, positionY + scrollTop, positionX + scrollRight, positionY + scrollBottom, (scrollbar->pressed == 0) ? w->fgColourNormal : w->fgColourSelected); |
| 407 | |
| 408 | if (GFX_Screen_IsActive(SCREEN_0)) { |
| 409 | GUI_Mouse_Show_InRegion(); |
| 410 | } |
| 411 | |
| 412 | /* Call custom callback function if set */ |
| 413 | if (scrollbar->drawProc != NULL) scrollbar->drawProc(w); |
| 414 | |
| 415 | scrollbar->dirty = 0; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Gets the action type used to determine how to draw the panel on the right side of the screen. |
no test coverage detected