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

Function DrawArrowButtons

src/settings_gui.cpp:1866–1887  ·  view source on GitHub ↗

* Draw [<][>] boxes. * @param x the x position to draw * @param y the y position to draw * @param button_colour the colour of the button * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked * @param clickable_left is the left button clickable? * @param clickable_right is the right button clickable? */

Source from the content-addressed store, hash-verified

1864 * @param clickable_right is the right button clickable?
1865 */
1866void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
1867{
1868 PixelColour colour = GetColourGradient(button_colour, SHADE_DARKER);
1869 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
1870
1871 Rect lr = {x, y, x + (int)dim.width - 1, y + (int)dim.height - 1};
1872 Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
1873
1874 DrawFrameRect(lr, button_colour, (state == 1) ? FrameFlag::Lowered : FrameFlags{});
1875 DrawFrameRect(rr, button_colour, (state == 2) ? FrameFlag::Lowered : FrameFlags{});
1876 DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, SA_CENTER);
1877 DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, SA_CENTER);
1878
1879 /* Grey out the buttons that aren't clickable */
1880 bool rtl = _current_text_dir == TD_RTL;
1881 if (rtl ? !clickable_right : !clickable_left) {
1882 GfxFillRect(lr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1883 }
1884 if (rtl ? !clickable_left : !clickable_right) {
1885 GfxFillRect(rr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1886 }
1887}
1888
1889/**
1890 * Draw [^][v] buttons

Callers 8

DrawSettingMethod · 0.85
DrawWidgetMethod · 0.85
DrawInfoMethod · 0.85
DrawCheatWidgetMethod · 0.85
DrawSettingMethod · 0.85
DrawWidgetMethod · 0.85
DrawWidgetMethod · 0.85
DrawWidgetMethod · 0.85

Calls 5

GetColourGradientFunction · 0.85
DrawSpriteIgnorePaddingFunction · 0.85
ShrinkMethod · 0.80
DrawFrameRectFunction · 0.70
GfxFillRectFunction · 0.70

Tested by

no test coverage detected