2013-06-14 15:48:13 +00:00
|
|
|
#ifndef _TEXTCOMPONENT_H_
|
|
|
|
#define _TEXTCOMPONENT_H_
|
|
|
|
|
|
|
|
#include "../GuiComponent.h"
|
2013-10-04 23:24:41 +00:00
|
|
|
#include "../resources/Font.h"
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-11-25 20:49:02 +00:00
|
|
|
class ThemeData;
|
|
|
|
|
2013-06-14 15:48:13 +00:00
|
|
|
class TextComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TextComponent(Window* window);
|
2013-09-19 23:41:14 +00:00
|
|
|
TextComponent(Window* window, const std::string& text, std::shared_ptr<Font> font, Eigen::Vector3f pos = Eigen::Vector3f::Zero(), Eigen::Vector2f size = Eigen::Vector2f::Zero());
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-07-03 07:54:55 +00:00
|
|
|
void setFont(std::shared_ptr<Font> font);
|
2013-07-10 11:29:43 +00:00
|
|
|
void onSizeChanged() override;
|
2013-06-14 15:48:13 +00:00
|
|
|
void setText(const std::string& text);
|
|
|
|
void setColor(unsigned int color);
|
2013-07-23 06:27:28 +00:00
|
|
|
void setCentered(bool center); //Default is uncentered.
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
void render(const Eigen::Affine3f& parentTrans) override;
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-08-14 12:16:49 +00:00
|
|
|
std::string getValue() const override;
|
|
|
|
void setValue(const std::string& value) override;
|
2013-10-10 21:14:33 +00:00
|
|
|
|
|
|
|
unsigned char getOpacity() const override;
|
|
|
|
void setOpacity(unsigned char opacity) override;
|
2013-08-14 12:16:49 +00:00
|
|
|
|
2013-07-03 07:54:55 +00:00
|
|
|
std::shared_ptr<Font> getFont() const;
|
2013-09-19 23:41:14 +00:00
|
|
|
|
|
|
|
private:
|
2013-06-19 01:12:30 +00:00
|
|
|
void calculateExtent();
|
|
|
|
|
2013-08-22 01:08:36 +00:00
|
|
|
void onTextChanged();
|
2013-10-10 21:14:33 +00:00
|
|
|
void onColorChanged();
|
2013-08-22 01:08:36 +00:00
|
|
|
|
2013-06-14 15:48:13 +00:00
|
|
|
unsigned int mColor;
|
2013-07-03 07:54:55 +00:00
|
|
|
std::shared_ptr<Font> mFont;
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Matrix<bool, 1, 2> mAutoCalcExtent;
|
2013-06-14 15:48:13 +00:00
|
|
|
std::string mText;
|
2013-09-19 23:41:14 +00:00
|
|
|
std::shared_ptr<TextCache> mTextCache;
|
2013-07-23 06:27:28 +00:00
|
|
|
bool mCentered;
|
2013-06-14 15:48:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|