mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15: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"
|
||||
|
||||
TextComponent::TextComponent(Window* window)
|
||||
: GuiComponent(window)
|
||||
, mFont(Font::get(FONT_SIZE_MEDIUM))
|
||||
, mColor(0x000000FF)
|
||||
, mBgColor(0)
|
||||
, mMargin(0.0f)
|
||||
, mRenderBackground(false)
|
||||
, mUppercase(false)
|
||||
, mAutoCalcExtent(true, true)
|
||||
, mHorizontalAlignment(ALIGN_LEFT)
|
||||
, mVerticalAlignment(ALIGN_CENTER)
|
||||
, mLineSpacing(1.5f)
|
||||
, mNoTopMargin(false)
|
||||
: GuiComponent{window}
|
||||
, mFont{Font::get(FONT_SIZE_MEDIUM)}
|
||||
, mColor{0x000000FF}
|
||||
, mBgColor{0}
|
||||
, mMargin{0.0f}
|
||||
, mRenderBackground{false}
|
||||
, mUppercase{false}
|
||||
, mAutoCalcExtent{1, 1}
|
||||
, mHorizontalAlignment{ALIGN_LEFT}
|
||||
, mVerticalAlignment{ALIGN_CENTER}
|
||||
, mLineSpacing{1.5f}
|
||||
, mNoTopMargin{false}
|
||||
, mSelectable{false}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -37,18 +38,19 @@ TextComponent::TextComponent(Window* window,
|
|||
glm::vec2 size,
|
||||
unsigned int bgcolor,
|
||||
float margin)
|
||||
: GuiComponent(window)
|
||||
, mFont(nullptr)
|
||||
, mColor(0x000000FF)
|
||||
, mBgColor(0)
|
||||
, mMargin(margin)
|
||||
, mRenderBackground(false)
|
||||
, mUppercase(false)
|
||||
, mAutoCalcExtent(true, true)
|
||||
, mHorizontalAlignment(align)
|
||||
, mVerticalAlignment(ALIGN_CENTER)
|
||||
, mLineSpacing(1.5f)
|
||||
, mNoTopMargin(false)
|
||||
: GuiComponent{window}
|
||||
, mFont{nullptr}
|
||||
, mColor{0x000000FF}
|
||||
, mBgColor{0}
|
||||
, mMargin{margin}
|
||||
, mRenderBackground{false}
|
||||
, mUppercase{false}
|
||||
, mAutoCalcExtent{1, 1}
|
||||
, mHorizontalAlignment{align}
|
||||
, mVerticalAlignment{ALIGN_CENTER}
|
||||
, mLineSpacing{1.5f}
|
||||
, mNoTopMargin{false}
|
||||
, mSelectable{false}
|
||||
{
|
||||
setFont(font);
|
||||
setColor(color);
|
||||
|
@ -282,6 +284,14 @@ void TextComponent::setNoTopMargin(bool margin)
|
|||
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,
|
||||
const std::string& view,
|
||||
const std::string& element,
|
||||
|
|
|
@ -60,11 +60,15 @@ public:
|
|||
unsigned char getOpacity() const override { return mColor & 0x000000FF; }
|
||||
void setOpacity(unsigned char opacity) override;
|
||||
|
||||
void setSelectable(bool status) { mSelectable = status; }
|
||||
|
||||
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;
|
||||
|
||||
unsigned int getColor() const override { return mColor; }
|
||||
std::shared_ptr<Font> getFont() const override { return mFont; }
|
||||
Alignment getHorizontalAlignment() { return mHorizontalAlignment; }
|
||||
|
@ -95,6 +99,7 @@ private:
|
|||
Alignment mVerticalAlignment;
|
||||
float mLineSpacing;
|
||||
bool mNoTopMargin;
|
||||
bool mSelectable;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H
|
||||
|
|
Loading…
Reference in a new issue