* Draw frame rectangle. * @param left Left edge of the frame * @param top Top edge of the frame * @param right Right edge of the frame * @param bottom Bottom edge of the frame * @param colour Colour table to use. @see Colours * @param flags Flags controlling how to draw the frame. @see FrameFlags */
| 305 | * @param flags Flags controlling how to draw the frame. @see FrameFlags |
| 306 | */ |
| 307 | void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags) |
| 308 | { |
| 309 | if (flags.Test(FrameFlag::Transparent)) { |
| 310 | GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR); |
| 311 | } else { |
| 312 | assert(colour < COLOUR_END); |
| 313 | |
| 314 | const PixelColour dark = GetColourGradient(colour, SHADE_DARK); |
| 315 | const PixelColour medium_dark = GetColourGradient(colour, SHADE_LIGHT); |
| 316 | const PixelColour medium_light = GetColourGradient(colour, SHADE_LIGHTER); |
| 317 | const PixelColour light = GetColourGradient(colour, SHADE_LIGHTEST); |
| 318 | PixelColour interior; |
| 319 | |
| 320 | Rect outer = {left, top, right, bottom}; // Outside rectangle |
| 321 | Rect inner = outer.Shrink(WidgetDimensions::scaled.bevel); // Inside rectangle |
| 322 | |
| 323 | if (flags.Test(FrameFlag::Lowered)) { |
| 324 | GfxFillRect(outer.left, outer.top, inner.left - 1, outer.bottom, dark); // Left |
| 325 | GfxFillRect(inner.left, outer.top, outer.right, inner.top - 1, dark); // Top |
| 326 | GfxFillRect(inner.right + 1, inner.top, outer.right, inner.bottom, light); // Right |
| 327 | GfxFillRect(inner.left, inner.bottom + 1, outer.right, outer.bottom, light); // Bottom |
| 328 | interior = (flags.Test(FrameFlag::Darkened) ? medium_dark : medium_light); |
| 329 | } else { |
| 330 | GfxFillRect(outer.left, outer.top, inner.left - 1, inner.bottom, light); // Left |
| 331 | GfxFillRect(inner.left, outer.top, inner.right, inner.top - 1, light); // Top |
| 332 | GfxFillRect(inner.right + 1, outer.top, outer.right, inner.bottom, dark); // Right |
| 333 | GfxFillRect(outer.left, inner.bottom + 1, outer.right, outer.bottom, dark); // Bottom |
| 334 | interior = medium_dark; |
| 335 | } |
| 336 | if (!flags.Test(FrameFlag::BorderOnly)) { |
| 337 | GfxFillRect(inner.left, inner.top, inner.right, inner.bottom, interior); // Inner |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringAlignment align) |
| 343 | { |
no test coverage detected