Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow newline on buttons
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Aug 29, 2022
1 parent 5bf03b6 commit cd1b76f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opengl/Quantum.cpp
Expand Up @@ -97,6 +97,7 @@ void QuantumButton::setLabel(const char* const label2, const bool adjustSizeNow)
{
std::free(label);
label = label2 != nullptr ? strdup(label2) : nullptr;
labelHasNewLine = label != nullptr && std::strchr(label, '\n') != nullptr;

if (adjustSizeNow)
adjustSize();
Expand Down Expand Up @@ -143,7 +144,10 @@ void QuantumButton::onNanoDisplay()
fillColor(theme.textLightColor);
fontSize(theme.fontSize);
textAlign(ALIGN_CENTER|ALIGN_MIDDLE);
text(getWidth() / 2, getHeight() / 2, label, nullptr);
if (labelHasNewLine)
textBox(0, (getHeight() - theme.fontSize) * 0.5f, getWidth(), label, nullptr);
else
text(getWidth() / 2, getHeight() / 2, label, nullptr);
}
}

Expand Down
1 change: 1 addition & 0 deletions opengl/Quantum.hpp
Expand Up @@ -126,6 +126,7 @@ class QuantumButton : public NanoSubWidget,
const QuantumTheme& theme;
Color backgroundColor = theme.widgetDefaultActiveColor;
char* label = nullptr;
bool labelHasNewLine = false;

public:
explicit QuantumButton(TopLevelWidget* parent, const QuantumTheme& theme);
Expand Down

0 comments on commit cd1b76f

Please sign in to comment.