summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/ConfigControls/ConfigSlider.h
blob: ec1ba827ad4b2f152a54a0e04f69ea77ce352c6a (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
// 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/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 ConfigSliderLabel final : public QLabel
{
  Q_OBJECT

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

private:
  QPointer<ConfigSlider> m_slider;
};