OpenTTD Source: src/widgets/slider.cpp File Reference

OpenTTD Source 13.2.1

Functions | Variables
slider.cpp File Reference
`#include "../stdafx.h"`
`#include "../window_gui.h"`
`#include "../window_func.h"`
`#include "../strings_func.h"`
`#include "../zoom_func.h"`
`#include "slider_func.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
void | DrawSliderWidget (Rect r, int min_value, int max_value, int value, const std::map< int, StringID > &labels)
| Draw a slider widget with knob at given value. More...
bool | ClickSliderWidget (Rect r, Point pt, int min_value, int max_value, int &value)
| Handle click on a slider widget to change the value. More...

## Variables
static const int | SLIDER_WIDTH = 3

## Detailed Description

Implementation of the horizontal slider widget.

Definition in file slider.cpp.

## Function Documentation

## ◆ ClickSliderWidget()

bool ClickSliderWidget | ( | Rect | r,
|  | Point | pt,
|  | int | min_value,
|  | int | max_value,
|  | int & | value
| ) |  |

Handle click on a slider widget to change the value.

Parameters

  r | Rectangle of the widget
  pt | Clicked point
  value[in,out] | Value to modify

Returns
  True if the value setting was modified

Definition at line 79 of file slider.cpp.

References ScaleGUITrad().

Referenced by MusicWindow::OnClick().

## ◆ DrawSliderWidget()

void DrawSliderWidget | ( | Rect | r,
|  | int | min_value,
|  | int | max_value,
|  | int | value,
|  | const std::map< int, StringID > & | labels
| ) |  |

Draw a slider widget with knob at given value.

Parameters

  r | Rectangle to draw the widget in
  min_value | Minimum value of slider
  max_value | Maximum value of slider
  value | Value to put the slider at
  labels | List of positions and labels to draw along the slider.

Definition at line 29 of file slider.cpp.

References FONT_HEIGHT_SMALL, WidgetDimensions::hsep_normal, WidgetDimensions::scaled, and ScaleGUITrad().