mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Made it possible to set a 'a/select' help prompt for TextComponent.
This commit is contained in:
parent
d0ccc8a13d
commit
a1ed59553f
|
@ -13,18 +13,19 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
TextComponent::TextComponent(Window* window)
|
TextComponent::TextComponent(Window* window)
|
||||||
: GuiComponent(window)
|
: GuiComponent{window}
|
||||||
, mFont(Font::get(FONT_SIZE_MEDIUM))
|
, mFont{Font::get(FONT_SIZE_MEDIUM)}
|
||||||
, mColor(0x000000FF)
|
, mColor{0x000000FF}
|
||||||
, mBgColor(0)
|
, mBgColor{0}
|
||||||
, mMargin(0.0f)
|
, mMargin{0.0f}
|
||||||
, mRenderBackground(false)
|
, mRenderBackground{false}
|
||||||
, mUppercase(false)
|
, mUppercase{false}
|
||||||
, mAutoCalcExtent(true, true)
|
, mAutoCalcExtent{1, 1}
|
||||||
, mHorizontalAlignment(ALIGN_LEFT)
|
, mHorizontalAlignment{ALIGN_LEFT}
|
||||||
, mVerticalAlignment(ALIGN_CENTER)
|
, mVerticalAlignment{ALIGN_CENTER}
|
||||||
, mLineSpacing(1.5f)
|
, mLineSpacing{1.5f}
|
||||||
, mNoTopMargin(false)
|
, mNoTopMargin{false}
|
||||||
|
, mSelectable{false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,18 +38,19 @@ TextComponent::TextComponent(Window* window,
|
||||||
glm::vec2 size,
|
glm::vec2 size,
|
||||||
unsigned int bgcolor,
|
unsigned int bgcolor,
|
||||||
float margin)
|
float margin)
|
||||||
: GuiComponent(window)
|
: GuiComponent{window}
|
||||||
, mFont(nullptr)
|
, mFont{nullptr}
|
||||||
, mColor(0x000000FF)
|
, mColor{0x000000FF}
|
||||||
, mBgColor(0)
|
, mBgColor{0}
|
||||||
, mMargin(margin)
|
, mMargin{margin}
|
||||||
, mRenderBackground(false)
|
, mRenderBackground{false}
|
||||||
, mUppercase(false)
|
, mUppercase{false}
|
||||||
, mAutoCalcExtent(true, true)
|
, mAutoCalcExtent{1, 1}
|
||||||
, mHorizontalAlignment(align)
|
, mHorizontalAlignment{align}
|
||||||
, mVerticalAlignment(ALIGN_CENTER)
|
, mVerticalAlignment{ALIGN_CENTER}
|
||||||
, mLineSpacing(1.5f)
|
, mLineSpacing{1.5f}
|
||||||
, mNoTopMargin(false)
|
, mNoTopMargin{false}
|
||||||
|
, mSelectable{false}
|
||||||
{
|
{
|
||||||
setFont(font);
|
setFont(font);
|
||||||
setColor(color);
|
setColor(color);
|
||||||
|
@ -282,6 +284,14 @@ void TextComponent::setNoTopMargin(bool margin)
|
||||||
onTextChanged();
|
onTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<HelpPrompt> TextComponent::getHelpPrompts()
|
||||||
|
{
|
||||||
|
std::vector<HelpPrompt> prompts;
|
||||||
|
if (mSelectable)
|
||||||
|
prompts.push_back(HelpPrompt("a", "select"));
|
||||||
|
return prompts;
|
||||||
|
}
|
||||||
|
|
||||||
void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
|
|
|
@ -60,11 +60,15 @@ public:
|
||||||
unsigned char getOpacity() const override { return mColor & 0x000000FF; }
|
unsigned char getOpacity() const override { return mColor & 0x000000FF; }
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(unsigned char opacity) override;
|
||||||
|
|
||||||
|
void setSelectable(bool status) { mSelectable = status; }
|
||||||
|
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
unsigned int properties) override;
|
unsigned int properties) override;
|
||||||
|
|
||||||
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
||||||
unsigned int getColor() const override { return mColor; }
|
unsigned int getColor() const override { return mColor; }
|
||||||
std::shared_ptr<Font> getFont() const override { return mFont; }
|
std::shared_ptr<Font> getFont() const override { return mFont; }
|
||||||
Alignment getHorizontalAlignment() { return mHorizontalAlignment; }
|
Alignment getHorizontalAlignment() { return mHorizontalAlignment; }
|
||||||
|
@ -95,6 +99,7 @@ private:
|
||||||
Alignment mVerticalAlignment;
|
Alignment mVerticalAlignment;
|
||||||
float mLineSpacing;
|
float mLineSpacing;
|
||||||
bool mNoTopMargin;
|
bool mNoTopMargin;
|
||||||
|
bool mSelectable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H
|
||||||
|
|
Loading…
Reference in a new issue