OpenTTD Source: src/slider_func.h Source File

OpenTTD Source 15.0-RC2

slider_func.h
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef SLIDER_TYPE_H
11#define SLIDER_TYPE_H
12
13#include "core/geometry_type.hpp"
14#include "gfx_type.h"
15
16using SliderMarkFunc = std::optional<std::string>(int nmarks, int mark, int value);
17void DrawSliderWidget(Rect r, Colours wedge_colour, Colours handle_colour, TextColour text_colour, int min_value, int max_value, int nmarks, int value, SliderMarkFunc *mark_func);
18bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, int &value);
19
20inline bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, uint8_t &value)
21{
22 int tmp_value = value;
23 if (!ClickSliderWidget(r, pt, min_value, max_value, nmarks, tmp_value)) return false;
24 value = tmp_value;
25 return true;
26}
27
28#endif /* SLIDER_TYPE_H */
geometry_type.hpp
All geometry types in OpenTTD.
gfx_type.h
Types related to the graphics and/or input devices.
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:307
DrawSliderWidget
void DrawSliderWidget(Rect r, Colours wedge_colour, Colours handle_colour, TextColour text_colour, int min_value, int max_value, int nmarks, int value, SliderMarkFunc *mark_func)
Draw a slider widget with knob at given value.
Definition slider.cpp:34
ClickSliderWidget
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, int &value)
Handle click on a slider widget to change the value.
Definition slider.cpp:94
Coord2D< int >
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101