Merge pull request #122 from jrassa/gamelist-scroll-bug

fix black boxes appearing on gamelist after scrolling
This commit is contained in:
Jools Wills 2017-05-01 05:27:33 +01:00 committed by GitHub
commit 631369825c
3 changed files with 20 additions and 9 deletions

View file

@ -443,8 +443,9 @@ void SystemView::getDefaultElements(void)
// System Info Bar // System Info Bar
mSystemInfo.setSize(mSize.x(), mSystemInfo.getFont()->getLetterHeight()*2.2f); 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.setBackgroundColor(0xDDDDDDD8);
mSystemInfo.setRenderBackground(true);
mSystemInfo.setFont(Font::get((int)(0.035f * mSize.y()), Font::getDefaultPath())); mSystemInfo.setFont(Font::get((int)(0.035f * mSize.y()), Font::getDefaultPath()));
mSystemInfo.setColor(0x000000FF); mSystemInfo.setColor(0x000000FF);
} }

View file

@ -8,13 +8,13 @@
#include "Settings.h" #include "Settings.h"
TextComponent::TextComponent(Window* window) : GuiComponent(window), 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>& font, unsigned int color, Alignment align, TextComponent::TextComponent(Window* window, const std::string& text, const std::shared_ptr<Font>& font, unsigned int color, Alignment align,
Eigen::Vector3f pos, Eigen::Vector2f size, unsigned int bgcolor) : GuiComponent(window), 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); setFont(font);
setColor(color); setColor(color);
@ -51,6 +51,11 @@ void TextComponent::setBackgroundColor(unsigned int color)
mBgColorOpacity = mBgColor & 0x000000FF; mBgColorOpacity = mBgColor & 0x000000FF;
} }
void TextComponent::setRenderBackground(bool render)
{
mRenderBackground = render;
}
// Scale the opacity // Scale the opacity
void TextComponent::setOpacity(unsigned char opacity) void TextComponent::setOpacity(unsigned char opacity)
{ {
@ -90,10 +95,10 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans)
{ {
Eigen::Affine3f trans = parentTrans * getTransform(); Eigen::Affine3f trans = parentTrans * getTransform();
if (mBgColor) if (mRenderBackground)
{ {
Renderer::drawRect(getPosition().x(), getPosition().y() - 1, Renderer::setMatrix(trans);
getSize().x(), getSize().y(), mBgColor); Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), mBgColor);
} }
if(mTextCache) if(mTextCache)
@ -233,8 +238,11 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const st
if (properties & COLOR && elem->has("color")) if (properties & COLOR && elem->has("color"))
setColor(elem->get<unsigned int>("color")); setColor(elem->get<unsigned int>("color"));
if (properties & COLOR && elem->has("backgroundColor")) setRenderBackground(false);
if (properties & COLOR && elem->has("backgroundColor")) {
setBackgroundColor(elem->get<unsigned int>("backgroundColor")); setBackgroundColor(elem->get<unsigned int>("backgroundColor"));
setRenderBackground(true);
}
if(properties & ALIGNMENT && elem->has("alignment")) if(properties & ALIGNMENT && elem->has("alignment"))
{ {

View file

@ -26,6 +26,7 @@ public:
void setAlignment(Alignment align); void setAlignment(Alignment align);
void setLineSpacing(float spacing); void setLineSpacing(float spacing);
void setBackgroundColor(unsigned int color); void setBackgroundColor(unsigned int color);
void setRenderBackground(bool render);
void render(const Eigen::Affine3f& parentTrans) override; void render(const Eigen::Affine3f& parentTrans) override;
@ -49,6 +50,7 @@ private:
unsigned int mBgColor; unsigned int mBgColor;
unsigned char mColorOpacity; unsigned char mColorOpacity;
unsigned char mBgColorOpacity; unsigned char mBgColorOpacity;
bool mRenderBackground;
std::shared_ptr<Font> mFont; std::shared_ptr<Font> mFont;
bool mUppercase; bool mUppercase;