2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-28 16:39:18 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-28 16:39:18 +00:00
|
|
|
// SliderComponent.h
|
|
|
|
//
|
|
|
|
// Slider to set value in a predefined range.
|
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "GuiComponent.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "components/ImageComponent.h"
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2014-01-10 22:01:28 +00:00
|
|
|
class Font;
|
2017-11-01 22:21:10 +00:00
|
|
|
class TextCache;
|
2014-01-10 22:01:28 +00:00
|
|
|
|
2014-01-24 22:21:10 +00:00
|
|
|
// Used to display/edit a value between some min and max values.
|
2013-06-19 01:12:30 +00:00
|
|
|
class SliderComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2021-09-18 09:49:39 +00:00
|
|
|
using GuiComponent::getValue;
|
|
|
|
using GuiComponent::setValue;
|
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Minimum value (far left of the slider), maximum value (far right of the slider),
|
2021-07-07 18:31:46 +00:00
|
|
|
// increment size (how much pressing L/R moves by), unit to display (optional).
|
2020-06-28 16:39:18 +00:00
|
|
|
SliderComponent(
|
2021-07-07 18:31:46 +00:00
|
|
|
Window* window, float min, float max, float increment, const std::string& suffix = "");
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2021-09-18 09:49:39 +00:00
|
|
|
void setValue(float value);
|
|
|
|
float getValue() { return mValue; }
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void update(int deltaTime) override;
|
2021-08-15 17:30:31 +00:00
|
|
|
void render(const glm::mat4& parentTrans) override;
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void onSizeChanged() override;
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
2014-01-10 22:01:28 +00:00
|
|
|
|
2013-06-19 01:12:30 +00:00
|
|
|
private:
|
2020-06-28 16:39:18 +00:00
|
|
|
void onValueChanged();
|
2014-01-10 22:01:28 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
float mMin, mMax;
|
|
|
|
float mValue;
|
|
|
|
float mSingleIncrement;
|
|
|
|
float mMoveRate;
|
2021-10-23 13:36:16 +00:00
|
|
|
float mBarHeight;
|
2020-06-28 16:39:18 +00:00
|
|
|
int mMoveAccumulator;
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
ImageComponent mKnob;
|
2014-03-08 00:16:08 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
std::string mSuffix;
|
|
|
|
std::shared_ptr<Font> mFont;
|
|
|
|
std::shared_ptr<TextCache> mValueCache;
|
2013-06-19 01:12:30 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
|