MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawFrameRect

Function DrawFrameRect

src/widget.cpp:307–340  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

305 * @param flags Flags controlling how to draw the frame. @see FrameFlags
306 */
307void 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
342void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringAlignment align)
343{

Callers 15

DrawWidgetMethod · 0.70
DrawShipImageFunction · 0.70
DrawWidgetMethod · 0.70
DrawEditBoxMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawRoadVehImageFunction · 0.70
DrawArrowButtonsFunction · 0.70
DrawUpDownButtonsFunction · 0.70

Calls 4

GetColourGradientFunction · 0.85
TestMethod · 0.80
ShrinkMethod · 0.80
GfxFillRectFunction · 0.70

Tested by

no test coverage detected