summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/ConfigControls/ConfigSlider.h
blob: 2adaf5643e7cfcd01c831895fbc4643a3d796a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <vector>

#include <QLabel>
#include <QPointer>

#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"

#include "Common/CommonTypes.h"
#include "Common/Config/ConfigInfo.h"

class ConfigSlider final : public ConfigControl<ToolTipSlider>
{
  Q_OBJECT
public:
  ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick = 0);
  ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, Config::Layer* layer,
               int tick = 0);

  // Generates a slider with tick_values.size() ticks. Each tick corresponds to the integer at that
  // index in the vector.
  ConfigSlider(std::vector<int> tick_values, const Config::Info<int>& setting,
               Config::Layer* layer);

  void Update(int value);

protected:
  void OnConfigChanged() override;

private:
  const Config::Info<int> m_setting;

  // Mappings for slider ticks to config values. Identity mapping is assumed if this is empty.
  std::vector<int> m_tick_values;
};

class ConfigSliderU32 final : public ConfigControl<ToolTipSlider>
{
  Q_OBJECT
public:
  ConfigSliderU32(u32 minimum, u32 maximum, const Config::Info<u32>& setting, u32 scale = 1);
  ConfigSliderU32(u32 minimum, u32 maximum, const Config::Info<u32>& setting, Config ::Layer* layer,
                  u32 scale = 1);

  void Update(u32 value);

protected:
  void OnConfigChanged() override;

private:
  const Config::Info<u32> m_setting;

  u32 m_scale = 1;
};

class ConfigSliderLabel final : public QLabel
{
  Q_OBJECT

public:
  ConfigSliderLabel(const QString& text, ConfigSlider* slider);

private:
  QPointer<ConfigSlider> m_slider;
};