Made the window corners slightly more rounded.

This commit is contained in:
Leon Styhre 2021-12-06 18:58:51 +01:00
parent 7e8d1f6434
commit 4227a609a2
4 changed files with 14 additions and 8 deletions

View file

@ -31,6 +31,7 @@ ButtonComponent::ButtonComponent(Window* window,
, mFlatColorUnfocused{0x60606025} , mFlatColorUnfocused{0x60606025}
{ {
mBox.setSharpCorners(true);
setPressedFunc(func); setPressedFunc(func);
setText(text, helpText, upperCase); setText(text, helpText, upperCase);

View file

@ -17,12 +17,13 @@ NinePatchComponent::NinePatchComponent(Window* window,
const std::string& path, const std::string& path,
unsigned int edgeColor, unsigned int edgeColor,
unsigned int centerColor) unsigned int centerColor)
: GuiComponent(window) : GuiComponent{window}
, mVertices(nullptr) , mVertices{nullptr}
, mPath(path) , mPath{path}
, mCornerSize(16.0f, 16.0f) , mCornerSize{16.0f, 16.0f}
, mEdgeColor(edgeColor) , mSharpCorners{false}
, mCenterColor(centerColor) , mEdgeColor{edgeColor}
, mCenterColor{centerColor}
{ {
if (!mPath.empty()) if (!mPath.empty())
buildVertices(); buildVertices();
@ -63,8 +64,9 @@ void NinePatchComponent::buildVertices()
else { else {
// Scale the corner size relative to the screen resolution (using the medium sized // Scale the corner size relative to the screen resolution (using the medium sized
// default font as size reference). // default font as size reference).
relCornerSize = glm::round( relCornerSize =
mCornerSize * (Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.0568f / 2.0f)); glm::round(mCornerSize * (Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() *
(mSharpCorners == true ? 0.0568f : 0.09f) / 2.0f));
} }
mTexture = TextureResource::get(mPath, false, false, false); mTexture = TextureResource::get(mPath, false, false, false);

View file

@ -57,6 +57,7 @@ public:
mCornerSize = size; mCornerSize = size;
buildVertices(); buildVertices();
} }
void setSharpCorners(bool state) { mSharpCorners = state; }
private: private:
void buildVertices(); void buildVertices();
@ -66,6 +67,7 @@ private:
std::string mPath; std::string mPath;
glm::vec2 mCornerSize; glm::vec2 mCornerSize;
bool mSharpCorners;
unsigned int mEdgeColor; unsigned int mEdgeColor;
unsigned int mCenterColor; unsigned int mCenterColor;
std::shared_ptr<TextureResource> mTexture; std::shared_ptr<TextureResource> mTexture;

View file

@ -29,6 +29,7 @@ TextEditComponent::TextEditComponent(Window* window)
, mBox{window, ":/graphics/textinput.svg"} , mBox{window, ":/graphics/textinput.svg"}
, mFont{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} , mFont{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}
{ {
mBox.setSharpCorners(true);
addChild(&mBox); addChild(&mBox);
onFocusLost(); onFocusLost();
setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())); setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()));