mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55: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 "../Window.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),
|
||||
mBox(window, ":/button.png"),
|
||||
mFont(Font::get(FONT_SIZE_MEDIUM)),
|
||||
mFocused(false),
|
||||
mEnabled(true),
|
||||
mTextColorFocused(0xFFFFFFFF), mTextColorUnfocused(0x777777FF)
|
||||
|
@ -40,10 +42,9 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
|
|||
mText = strToUpper(text);
|
||||
mHelpText = helpText;
|
||||
|
||||
std::shared_ptr<Font> f = getFont();
|
||||
mTextCache = std::unique_ptr<TextCache>(f->buildTextCache(mText, 0, 0, getCurTextColor()));
|
||||
mTextCache = std::unique_ptr<TextCache>(mFont->buildTextCache(mText, 0, 0, getCurTextColor()));
|
||||
|
||||
setSize(mTextCache->metrics.size + Eigen::Vector2f(12, 12));
|
||||
setSize(mTextCache->metrics.size + Eigen::Vector2f(12, 0));
|
||||
|
||||
updateHelpPrompts();
|
||||
}
|
||||
|
@ -94,18 +95,13 @@ void ButtonComponent::render(const Eigen::Affine3f& parentTrans)
|
|||
|
||||
Renderer::setMatrix(trans);
|
||||
mTextCache->setColor(getCurTextColor());
|
||||
getFont()->renderTextCache(mTextCache.get());
|
||||
mFont->renderTextCache(mTextCache.get());
|
||||
trans = trans.translate(-centerOffset);
|
||||
}
|
||||
|
||||
renderChildren(trans);
|
||||
}
|
||||
|
||||
std::shared_ptr<Font> ButtonComponent::getFont()
|
||||
{
|
||||
return Font::get(FONT_SIZE_SMALL);
|
||||
}
|
||||
|
||||
unsigned int ButtonComponent::getCurTextColor() const
|
||||
{
|
||||
if(!mFocused)
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Font> getFont();
|
||||
std::shared_ptr<Font> mFont;
|
||||
std::function<void()> mPressedFunc;
|
||||
|
||||
bool mFocused;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "../components/ButtonComponent.h"
|
||||
#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,
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
|
|||
void GuiMsgBox::onSizeChanged()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue