ES-DE/es-core/src/components/SliderComponent.h

46 lines
1.2 KiB
C
Raw Normal View History

#pragma once
#ifndef ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
#define ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
#include "components/ImageComponent.h"
2017-11-01 22:21:10 +00:00
#include "GuiComponent.h"
class Font;
2017-11-01 22:21:10 +00:00
class TextCache;
2014-01-24 22:21:10 +00:00
// Used to display/edit a value between some min and max values.
class SliderComponent : public GuiComponent
{
public:
//Minimum value (far left of the slider), maximum value (far right of the slider), increment size (how much just pressing L/R moves by), unit to display (optional).
SliderComponent(Window* window, float min, float max, float increment, const std::string& suffix = "");
void setValue(float val);
float getValue();
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;
void render(const Transform4x4f& parentTrans) override;
void onSizeChanged() override;
virtual std::vector<HelpPrompt> getHelpPrompts() override;
private:
void onValueChanged();
float mMin, mMax;
float mValue;
float mSingleIncrement;
float mMoveRate;
int mMoveAccumulator;
2014-03-08 00:16:08 +00:00
ImageComponent mKnob;
std::string mSuffix;
std::shared_ptr<Font> mFont;
std::shared_ptr<TextCache> mValueCache;
};
#endif // ES_CORE_COMPONENTS_SLIDER_COMPONENT_H