* * rct2: 0x006EB861 */
| 281 | * rct2: 0x006EB861 |
| 282 | */ |
| 283 | static void WidgetFlatButtonDraw(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex) |
| 284 | { |
| 285 | const auto& widget = w.widgets[widgetIndex]; |
| 286 | // First check is needed as this function handles both WidgetType::flatBtn and WidgetType::hiddenButton |
| 287 | const bool alwaysDrawAs3d = widget.type == WidgetType::flatBtn && (ThemeGetFlags() & UITHEME_FLAG_USE_3D_IMAGE_BUTTONS); |
| 288 | if (alwaysDrawAs3d || (!widgetIsDisabled(w, widgetIndex) && widgetIsHighlighted(w, widgetIndex))) |
| 289 | { |
| 290 | WidgetButtonDraw(rt, w, widgetIndex); |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | // Resolve the absolute ltrb |
| 295 | ScreenRect rect{ w.windowPos + ScreenCoordsXY{ widget.left, widget.top }, |
| 296 | w.windowPos + ScreenCoordsXY{ widget.right, widget.bottom } }; |
| 297 | |
| 298 | auto colour = w.colours[widget.colour]; |
| 299 | |
| 300 | // Check if the button is pressed down |
| 301 | if (widgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex)) |
| 302 | { |
| 303 | // Dead code? |
| 304 | if (static_cast<int32_t>(widget.image.GetIndex()) == -2) |
| 305 | { |
| 306 | // Draw border with no fill |
| 307 | Rectangle::fillInset( |
| 308 | rt, rect, colour, Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light, |
| 309 | Rectangle::FillMode::none); |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | // Draw the border with fill |
| 314 | Rectangle::fillInset(rt, rect, colour, Rectangle::BorderStyle::inset); |
| 315 | } |
| 316 | |
| 317 | // Draw image |
| 318 | WidgetDrawImage(rt, w, widgetIndex); |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * |
no test coverage detected