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

Function WidgetButtonDraw

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

* * rct2: 0x006EB8E5 */

Source from the content-addressed store, hash-verified

199 * rct2: 0x006EB8E5
200 */
201 static void WidgetButtonDraw(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex)
202 {
203 // Get the widget
204 const auto& widget = w.widgets[widgetIndex];
205
206 // Resolve the absolute ltrb
207 ScreenRect rect{ w.windowPos + ScreenCoordsXY{ widget.left, widget.top },
208 w.windowPos + ScreenCoordsXY{ widget.right, widget.bottom } };
209
210 // Check if the button is pressed down
211 auto borderStyle = widgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex) ? Rectangle::BorderStyle::inset
212 : Rectangle::BorderStyle::outset;
213
214 auto colour = w.colours[widget.colour];
215
216 // Dead code?
217 if (static_cast<int32_t>(widget.image.GetIndex()) == -2)
218 {
219 // Draw border with no fill
220 Rectangle::fillInset(rt, rect, colour, borderStyle, Rectangle::FillBrightness::light, Rectangle::FillMode::none);
221 return;
222 }
223
224 // Draw the border with fill
225 Rectangle::fillInset(rt, rect, colour, borderStyle);
226
227 WidgetDrawImage(rt, w, widgetIndex);
228 }
229
230 /**
231 *

Callers 2

widgetDrawFunction · 0.85
WidgetFlatButtonDrawFunction · 0.85

Calls 5

widgetIsPressedFunction · 0.85
isToolActiveFunction · 0.85
fillInsetFunction · 0.85
WidgetDrawImageFunction · 0.85
GetIndexMethod · 0.45

Tested by

no test coverage detected