| 71 | } |
| 72 | |
| 73 | void Frame::drawBackground(Gfx::DrawingContext& drawingCtx, const Widget& widget, const WidgetState& widgetState) |
| 74 | { |
| 75 | const auto* window = widgetState.window; |
| 76 | const auto pos = window->position() + widget.position(); |
| 77 | const auto size = widget.size(); |
| 78 | |
| 79 | const auto& rt = drawingCtx.currentRenderTarget(); |
| 80 | const auto clipped = Gfx::clipRenderTarget(rt, Ui::Rect(pos.x, pos.y, size.width, 41)); |
| 81 | if (clipped) |
| 82 | { |
| 83 | uint32_t imageId = widget.image; |
| 84 | if (window->hasFlags(WindowFlags::lighterFrame)) |
| 85 | { |
| 86 | imageId = Gfx::recolour(ImageIds::frame_background_image, widgetState.colour.c()); |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | imageId = Gfx::recolour(ImageIds::frame_background_image_alt, widgetState.colour.c()); |
| 91 | } |
| 92 | |
| 93 | drawingCtx.pushRenderTarget(*clipped); |
| 94 | |
| 95 | // Derive the number of background images to paint |
| 96 | const auto backgroundImageWidth = Gfx::getG1Element(imageId)->width; |
| 97 | const auto numPassesNeeded = (widget.width() + backgroundImageWidth - 1) / backgroundImageWidth; |
| 98 | |
| 99 | // Draw background image repeatedly to account for large windows |
| 100 | // NB: starting on the right side to counter the border on the left side of the sprite |
| 101 | for (auto i = numPassesNeeded; i >= 0; i--) |
| 102 | { |
| 103 | drawingCtx.drawImage(i * (backgroundImageWidth - 1), 0, imageId); |
| 104 | } |
| 105 | |
| 106 | drawingCtx.popRenderTarget(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | void Frame::drawSolid(Gfx::DrawingContext& drawingCtx, const Widget& widget, const WidgetState& widgetState) |
| 111 | { |
nothing calls this directly
no test coverage detected