MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / WidgetFlatButtonDraw

Function WidgetFlatButtonDraw

src/openrct2-ui/interface/Widget.cpp:283–319  ·  view source on GitHub ↗

* * rct2: 0x006EB861 */

Source from the content-addressed store, hash-verified

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 *

Callers 1

widgetDrawFunction · 0.85

Calls 9

ThemeGetFlagsFunction · 0.85
widgetIsDisabledFunction · 0.85
widgetIsHighlightedFunction · 0.85
WidgetButtonDrawFunction · 0.85
widgetIsPressedFunction · 0.85
isToolActiveFunction · 0.85
fillInsetFunction · 0.85
WidgetDrawImageFunction · 0.85
GetIndexMethod · 0.45

Tested by

no test coverage detected