diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 1cc4532f6..1024d84f3 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -443,8 +443,9 @@ void SystemView::getDefaultElements(void) // System Info Bar mSystemInfo.setSize(mSize.x(), mSystemInfo.getFont()->getLetterHeight()*2.2f); - mSystemInfo.setPosition(0, (mCarousel.pos.y() + mCarousel.size.y())); + mSystemInfo.setPosition(0, (mCarousel.pos.y() + mCarousel.size.y() - 0.2f)); mSystemInfo.setBackgroundColor(0xDDDDDDD8); + mSystemInfo.setRenderBackground(true); mSystemInfo.setFont(Font::get((int)(0.035f * mSize.y()), Font::getDefaultPath())); mSystemInfo.setColor(0x000000FF); } diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index c7b7a490d..bb1edfb5d 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -8,13 +8,13 @@ #include "Settings.h" TextComponent::TextComponent(Window* window) : GuiComponent(window), - mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(ALIGN_LEFT), mLineSpacing(1.5f), mBgColor(0) + mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(ALIGN_LEFT), mLineSpacing(1.5f), mBgColor(0), mRenderBackground(false) { } TextComponent::TextComponent(Window* window, const std::string& text, const std::shared_ptr& font, unsigned int color, Alignment align, Eigen::Vector3f pos, Eigen::Vector2f size, unsigned int bgcolor) : GuiComponent(window), - mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(align), mLineSpacing(1.5f), mBgColor(0) + mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mAlignment(align), mLineSpacing(1.5f), mBgColor(0), mRenderBackground(false) { setFont(font); setColor(color); @@ -51,6 +51,11 @@ void TextComponent::setBackgroundColor(unsigned int color) mBgColorOpacity = mBgColor & 0x000000FF; } +void TextComponent::setRenderBackground(bool render) +{ + mRenderBackground = render; +} + // Scale the opacity void TextComponent::setOpacity(unsigned char opacity) { @@ -60,10 +65,10 @@ void TextComponent::setOpacity(unsigned char opacity) unsigned char o = (unsigned char)((float)opacity / 255.f * (float) mColorOpacity); mColor = (mColor & 0xFFFFFF00) | (unsigned char) o; - + unsigned char bgo = (unsigned char)((float)opacity / 255.f * (float)mBgColorOpacity); mBgColor = (mBgColor & 0xFFFFFF00) | (unsigned char)bgo; - + onColorChanged(); GuiComponent::setOpacity(opacity); @@ -90,10 +95,10 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans) { Eigen::Affine3f trans = parentTrans * getTransform(); - if (mBgColor) + if (mRenderBackground) { - Renderer::drawRect(getPosition().x(), getPosition().y() - 1, - getSize().x(), getSize().y(), mBgColor); + Renderer::setMatrix(trans); + Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), mBgColor); } if(mTextCache) @@ -233,8 +238,11 @@ void TextComponent::applyTheme(const std::shared_ptr& theme, const st if (properties & COLOR && elem->has("color")) setColor(elem->get("color")); - if (properties & COLOR && elem->has("backgroundColor")) + setRenderBackground(false); + if (properties & COLOR && elem->has("backgroundColor")) { setBackgroundColor(elem->get("backgroundColor")); + setRenderBackground(true); + } if(properties & ALIGNMENT && elem->has("alignment")) { diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index a0dc4a554..2f2f8e4e6 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -26,6 +26,7 @@ public: void setAlignment(Alignment align); void setLineSpacing(float spacing); void setBackgroundColor(unsigned int color); + void setRenderBackground(bool render); void render(const Eigen::Affine3f& parentTrans) override; @@ -49,6 +50,7 @@ private: unsigned int mBgColor; unsigned char mColorOpacity; unsigned char mBgColorOpacity; + bool mRenderBackground; std::shared_ptr mFont; bool mUppercase;