2014-06-25 16:29:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
#include "resources/TextureResource.h"
|
|
|
|
|
|
|
|
#define NUM_RATING_STARS 5
|
|
|
|
|
|
|
|
// Used to visually display/edit some sort of "score" - e.g. 5/10, 3/5, etc.
|
|
|
|
// setSize(x, y) works a little differently than you might expect:
|
|
|
|
// * (0, y != 0) - x will be automatically calculated (5*y).
|
|
|
|
// * (x != 0, 0) - y will be automatically calculated (x/5).
|
|
|
|
// * (x != 0, y != 0) - you better be sure x = y*5
|
|
|
|
class RatingComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RatingComponent(Window* window);
|
|
|
|
|
|
|
|
std::string getValue() const override;
|
|
|
|
void setValue(const std::string& value) override; // Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped.
|
|
|
|
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
2017-10-28 20:24:35 +00:00
|
|
|
void render(const Transform4x4f& parentTrans);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
void onSizeChanged() override;
|
|
|
|
|
2017-06-08 23:18:27 +00:00
|
|
|
void setOpacity(unsigned char opacity) override;
|
|
|
|
|
|
|
|
// Multiply all pixels in the image by this color when rendering.
|
|
|
|
void setColorShift(unsigned int color);
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties) override;
|
|
|
|
|
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateVertices();
|
2017-06-08 23:18:27 +00:00
|
|
|
void updateColors();
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
float mValue;
|
|
|
|
|
|
|
|
struct Vertex
|
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f pos;
|
|
|
|
Vector2f tex;
|
2014-06-25 16:29:58 +00:00
|
|
|
} mVertices[12];
|
|
|
|
|
2017-06-08 23:18:27 +00:00
|
|
|
|
|
|
|
GLubyte mColors[12*4];
|
|
|
|
|
|
|
|
unsigned int mColorShift;
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
std::shared_ptr<TextureResource> mFilledTexture;
|
|
|
|
std::shared_ptr<TextureResource> mUnfilledTexture;
|
|
|
|
};
|
|
|
|
|