mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35: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();
|
||||
}
|
||||
|
||||
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;
|
||||
mHelpText = helpText;
|
||||
|
@ -74,10 +77,12 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
|
|||
|
||||
const float minWidth {mFont->sizeText("DELETE").x +
|
||||
(12.0f * mRenderer->getScreenResolutionModifier())};
|
||||
setSize(
|
||||
std::max(mTextCache->metrics.size.x + (12.0f * mRenderer->getScreenResolutionModifier()),
|
||||
minWidth),
|
||||
mTextCache->metrics.size.y);
|
||||
if (resize) {
|
||||
setSize(std::max(mTextCache->metrics.size.x +
|
||||
(12.0f * mRenderer->getScreenResolutionModifier()),
|
||||
minWidth),
|
||||
mTextCache->metrics.size.y);
|
||||
}
|
||||
|
||||
updateHelpPrompts();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ public:
|
|||
void onFocusGained() 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; }
|
||||
|
||||
void setPressedFunc(std::function<void()> f) { mPressedFunc = f; }
|
||||
|
|
Loading…
Reference in a new issue