mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added a border above buttons on GuiMsgBox.
Reluctantly changed button font to FONT_SIZE_MEDIUM because FONT_SIZE_SMALL has messed up sizing for some unknown reason.
This commit is contained in:
parent
088b146fe9
commit
613787931a
|
@ -2,9 +2,11 @@
|
||||||
#include "../Renderer.h"
|
#include "../Renderer.h"
|
||||||
#include "../Window.h"
|
#include "../Window.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
|
#include "../Log.h"
|
||||||
|
|
||||||
ButtonComponent::ButtonComponent(Window* window, const std::string& text, const std::string& helpText, const std::function<void()>& func) : GuiComponent(window),
|
ButtonComponent::ButtonComponent(Window* window, const std::string& text, const std::string& helpText, const std::function<void()>& func) : GuiComponent(window),
|
||||||
mBox(window, ":/button.png"),
|
mBox(window, ":/button.png"),
|
||||||
|
mFont(Font::get(FONT_SIZE_MEDIUM)),
|
||||||
mFocused(false),
|
mFocused(false),
|
||||||
mEnabled(true),
|
mEnabled(true),
|
||||||
mTextColorFocused(0xFFFFFFFF), mTextColorUnfocused(0x777777FF)
|
mTextColorFocused(0xFFFFFFFF), mTextColorUnfocused(0x777777FF)
|
||||||
|
@ -40,10 +42,9 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
|
||||||
mText = strToUpper(text);
|
mText = strToUpper(text);
|
||||||
mHelpText = helpText;
|
mHelpText = helpText;
|
||||||
|
|
||||||
std::shared_ptr<Font> f = getFont();
|
mTextCache = std::unique_ptr<TextCache>(mFont->buildTextCache(mText, 0, 0, getCurTextColor()));
|
||||||
mTextCache = std::unique_ptr<TextCache>(f->buildTextCache(mText, 0, 0, getCurTextColor()));
|
|
||||||
|
setSize(mTextCache->metrics.size + Eigen::Vector2f(12, 0));
|
||||||
setSize(mTextCache->metrics.size + Eigen::Vector2f(12, 12));
|
|
||||||
|
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
}
|
}
|
||||||
|
@ -94,18 +95,13 @@ void ButtonComponent::render(const Eigen::Affine3f& parentTrans)
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
mTextCache->setColor(getCurTextColor());
|
mTextCache->setColor(getCurTextColor());
|
||||||
getFont()->renderTextCache(mTextCache.get());
|
mFont->renderTextCache(mTextCache.get());
|
||||||
trans = trans.translate(-centerOffset);
|
trans = trans.translate(-centerOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Font> ButtonComponent::getFont()
|
|
||||||
{
|
|
||||||
return Font::get(FONT_SIZE_SMALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int ButtonComponent::getCurTextColor() const
|
unsigned int ButtonComponent::getCurTextColor() const
|
||||||
{
|
{
|
||||||
if(!mFocused)
|
if(!mFocused)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Font> getFont();
|
std::shared_ptr<Font> mFont;
|
||||||
std::function<void()> mPressedFunc;
|
std::function<void()> mPressedFunc;
|
||||||
|
|
||||||
bool mFocused;
|
bool mFocused;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "../components/ButtonComponent.h"
|
#include "../components/ButtonComponent.h"
|
||||||
#include "../components/MenuComponent.h" // for makeButtonGrid
|
#include "../components/MenuComponent.h" // for makeButtonGrid
|
||||||
|
|
||||||
#define BUTTON_VERT_PADDING 16.0f
|
#define BUTTON_VERT_PADDING 32.0f
|
||||||
|
|
||||||
GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
|
GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
|
||||||
const std::string& name1, const std::function<void()>& func1,
|
const std::string& name1, const std::function<void()>& func1,
|
||||||
|
@ -28,7 +28,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
|
||||||
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
||||||
|
|
||||||
mGrid.setEntry(mMsg, Eigen::Vector2i(0, 0), false, true);
|
mGrid.setEntry(mMsg, Eigen::Vector2i(0, 0), false, true);
|
||||||
mGrid.setEntry(mButtonGrid, Eigen::Vector2i(0, 1), true, false);
|
mGrid.setEntry(mButtonGrid, Eigen::Vector2i(0, 1), true, false, Eigen::Vector2i(1, 1), GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
if(mMsg->getSize().x() > width)
|
if(mMsg->getSize().x() > width)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
|
||||||
void GuiMsgBox::onSizeChanged()
|
void GuiMsgBox::onSizeChanged()
|
||||||
{
|
{
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
mBackground.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(-16, -32));
|
mBackground.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(-32, -32));
|
||||||
|
|
||||||
mGrid.setRowHeightPerc(1, (mButtonGrid->getSize().y() + BUTTON_VERT_PADDING) / mSize.y());
|
mGrid.setRowHeightPerc(1, (mButtonGrid->getSize().y() + BUTTON_VERT_PADDING) / mSize.y());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue