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

Function DrawUpDownButtons

src/settings_gui.cpp:1898–1914  ·  view source on GitHub ↗

* Draw [^][v] buttons * @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_up is the up button clickable? * @param clickable_down is the down button clickable? */

Source from the content-addressed store, hash-verified

1896 * @param clickable_down is the down button clickable?
1897 */
1898void DrawUpDownButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_up, bool clickable_down)
1899{
1900 PixelColour colour = GetColourGradient(button_colour, SHADE_DARKER);
1901
1902 Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
1903 Rect ur = r.WithWidth(SETTING_BUTTON_WIDTH / 2, (_current_text_dir == TD_RTL));
1904 Rect dr = r.WithWidth(SETTING_BUTTON_WIDTH / 2, (_current_text_dir != TD_RTL));
1905
1906 DrawFrameRect(ur, button_colour, (state == 1) ? FrameFlag::Lowered : FrameFlags{});
1907 DrawFrameRect(dr, button_colour, (state == 2) ? FrameFlag::Lowered : FrameFlags{});
1908 DrawSpriteIgnorePadding(SPR_ARROW_UP, PAL_NONE, ur, SA_CENTER);
1909 DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, dr, SA_CENTER);
1910
1911 /* Grey out the buttons that aren't clickable */
1912 if (!clickable_up) GfxFillRect(ur.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1913 if (!clickable_down) GfxFillRect(dr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1914}
1915
1916/**
1917 * Draw a dropdown button.

Callers 1

DrawMethod · 0.85

Calls 6

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

Tested by

no test coverage detected