mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Added a parameter for whether to resize ButtonComponent when calling setText()
This commit is contained in:
parent
24508baade
commit
69e46d96a5
|
@ -64,7 +64,10 @@ void ButtonComponent::onFocusLost()
|
||||||
updateImage();
|
updateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonComponent::setText(const std::string& text, const std::string& helpText, bool upperCase)
|
void ButtonComponent::setText(const std::string& text,
|
||||||
|
const std::string& helpText,
|
||||||
|
bool upperCase,
|
||||||
|
bool resize)
|
||||||
{
|
{
|
||||||
mText = upperCase ? Utils::String::toUpper(text) : text;
|
mText = upperCase ? Utils::String::toUpper(text) : text;
|
||||||
mHelpText = helpText;
|
mHelpText = helpText;
|
||||||
|
@ -74,10 +77,12 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
|
||||||
|
|
||||||
const float minWidth {mFont->sizeText("DELETE").x +
|
const float minWidth {mFont->sizeText("DELETE").x +
|
||||||
(12.0f * mRenderer->getScreenResolutionModifier())};
|
(12.0f * mRenderer->getScreenResolutionModifier())};
|
||||||
setSize(
|
if (resize) {
|
||||||
std::max(mTextCache->metrics.size.x + (12.0f * mRenderer->getScreenResolutionModifier()),
|
setSize(std::max(mTextCache->metrics.size.x +
|
||||||
|
(12.0f * mRenderer->getScreenResolutionModifier()),
|
||||||
minWidth),
|
minWidth),
|
||||||
mTextCache->metrics.size.y);
|
mTextCache->metrics.size.y);
|
||||||
|
}
|
||||||
|
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ public:
|
||||||
void onFocusGained() override;
|
void onFocusGained() override;
|
||||||
void onFocusLost() override;
|
void onFocusLost() override;
|
||||||
|
|
||||||
void setText(const std::string& text, const std::string& helpText, bool upperCase = true);
|
void setText(const std::string& text,
|
||||||
|
const std::string& helpText,
|
||||||
|
bool upperCase = true,
|
||||||
|
bool resize = true);
|
||||||
const std::string& getText() const { return mText; }
|
const std::string& getText() const { return mText; }
|
||||||
|
|
||||||
void setPressedFunc(std::function<void()> f) { mPressedFunc = f; }
|
void setPressedFunc(std::function<void()> f) { mPressedFunc = f; }
|
||||||
|
|
Loading…
Reference in a new issue