From 4227a609a2427fd06d2a064153010d24f56b66c8 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 6 Dec 2021 18:58:51 +0100 Subject: [PATCH] Made the window corners slightly more rounded. --- es-core/src/components/ButtonComponent.cpp | 1 + es-core/src/components/NinePatchComponent.cpp | 18 ++++++++++-------- es-core/src/components/NinePatchComponent.h | 2 ++ es-core/src/components/TextEditComponent.cpp | 1 + 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index 3143f52a9..7bbad8a5a 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -31,6 +31,7 @@ ButtonComponent::ButtonComponent(Window* window, , mFlatColorUnfocused{0x60606025} { + mBox.setSharpCorners(true); setPressedFunc(func); setText(text, helpText, upperCase); diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index dba285fe2..ebeeea030 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -17,12 +17,13 @@ NinePatchComponent::NinePatchComponent(Window* window, const std::string& path, unsigned int edgeColor, unsigned int centerColor) - : GuiComponent(window) - , mVertices(nullptr) - , mPath(path) - , mCornerSize(16.0f, 16.0f) - , mEdgeColor(edgeColor) - , mCenterColor(centerColor) + : GuiComponent{window} + , mVertices{nullptr} + , mPath{path} + , mCornerSize{16.0f, 16.0f} + , mSharpCorners{false} + , mEdgeColor{edgeColor} + , mCenterColor{centerColor} { if (!mPath.empty()) buildVertices(); @@ -63,8 +64,9 @@ void NinePatchComponent::buildVertices() else { // Scale the corner size relative to the screen resolution (using the medium sized // default font as size reference). - relCornerSize = glm::round( - mCornerSize * (Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.0568f / 2.0f)); + relCornerSize = + glm::round(mCornerSize * (Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * + (mSharpCorners == true ? 0.0568f : 0.09f) / 2.0f)); } mTexture = TextureResource::get(mPath, false, false, false); diff --git a/es-core/src/components/NinePatchComponent.h b/es-core/src/components/NinePatchComponent.h index a02009eb2..ce19cab43 100644 --- a/es-core/src/components/NinePatchComponent.h +++ b/es-core/src/components/NinePatchComponent.h @@ -57,6 +57,7 @@ public: mCornerSize = size; buildVertices(); } + void setSharpCorners(bool state) { mSharpCorners = state; } private: void buildVertices(); @@ -66,6 +67,7 @@ private: std::string mPath; glm::vec2 mCornerSize; + bool mSharpCorners; unsigned int mEdgeColor; unsigned int mCenterColor; std::shared_ptr mTexture; diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index e333a96d0..ad84d9c7d 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -29,6 +29,7 @@ TextEditComponent::TextEditComponent(Window* window) , mBox{window, ":/graphics/textinput.svg"} , mFont{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} { + mBox.setSharpCorners(true); addChild(&mBox); onFocusLost(); setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()));