OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../window_gui.h"
12 #include "../window_func.h"
13 #include "../strings_func.h"
14 #include "../zoom_func.h"
15 #include "slider_func.h"
17 #include "../safeguards.h"
19 static const int SLIDER_WIDTH = 3;
29 const int ha = (r.bottom - r.top) / 5;
30 int wx1 = r.left, wx2 = r.right;
35 const std::vector<Point> wedge{
Point{wx1, r.bottom - ha},
Point{wx2, r.top + ha},
Point{wx2, r.bottom - ha} };
37 GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light);
39 GfxDrawLine(wedge[0].x, wedge[0].y, wedge[1].x, wedge[1].y, shadow);
44 const int x = r.left + (value * (r.right - r.left - sw) / 127);
45 DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE);
58 byte new_vol =
Clamp((pt.x - r.left - sw / 2) * 127 / (r.right - r.left - sw), 0, 127);
61 if (new_vol != value) {
void GfxFillPolygon(const std::vector< Point > &shape, int colour, FillRectMode mode)
Fill a polygon with colour.
void DrawVolumeSliderWidget(Rect r, byte value)
Draw a volume slider widget with know at given value.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Coordinates of a point in 2D.
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
Handle click on a volume slider widget to change the value.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Specification of a rectangle with absolute coordinates of all edges.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.