Fixed incorrect star texture path.

RatingComponent now rasterizes SVGs to the ideal size.
TextComponent's text is now vertically centered always.
This commit is contained in:
Aloshi 2014-03-22 14:31:13 -05:00
parent 2aa72928e5
commit ec4ee70259
5 changed files with 18 additions and 8 deletions

View file

@ -69,7 +69,7 @@ std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char * d
} }
else else
{ {
LOG(LogError) << "Error - File type unknown/unsupported!"; LOG(LogError) << "Error - File type " << (format == FIF_UNKNOWN ? "unknown" : "unsupported") << "!";
} }
//free FIMEMORY again //free FIMEMORY again
FreeImage_CloseMemory(fiMemory); FreeImage_CloseMemory(fiMemory);

View file

@ -2,11 +2,12 @@
#include "../Renderer.h" #include "../Renderer.h"
#include "../Window.h" #include "../Window.h"
#include "../Util.h" #include "../Util.h"
#include "../resources/SVGResource.h"
RatingComponent::RatingComponent(Window* window) : GuiComponent(window) RatingComponent::RatingComponent(Window* window) : GuiComponent(window)
{ {
mFilledTexture = TextureResource::get(":/star_filled.png", true); mFilledTexture = TextureResource::get(":/star_filled.svg", true);
mUnfilledTexture = TextureResource::get(":/star_unfilled.png", true); mUnfilledTexture = TextureResource::get(":/star_unfilled.svg", true);
mValue = 0.5f; mValue = 0.5f;
mSize << 64 * 5.0f, 64; mSize << 64 * 5.0f, 64;
updateVertices(); updateVertices();
@ -40,6 +41,15 @@ void RatingComponent::onSizeChanged()
else if(mSize.x() == 0) else if(mSize.x() == 0)
mSize[0] = mSize.y() * 5.0f; mSize[0] = mSize.y() * 5.0f;
auto filledSVG = dynamic_cast<SVGResource*>(mFilledTexture.get());
auto unfilledSVG = dynamic_cast<SVGResource*>(mUnfilledTexture.get());
size_t sz = (size_t)round(mSize.y());
if(filledSVG)
filledSVG->rasterizeAt(sz, sz);
if(unfilledSVG)
unfilledSVG->rasterizeAt(sz, sz);
updateVertices(); updateVertices();
} }

View file

@ -68,8 +68,8 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans)
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0); Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
dim = trans * dim - trans.translation(); dim = trans * dim - trans.translation();
//Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()), Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()),
// Eigen::Vector2i((int)(dim.x() + 0.5f), (int)(dim.y() + 0.5f))); Eigen::Vector2i((int)(dim.x() + 0.5f), (int)(dim.y() + 0.5f)));
if(mTextCache) if(mTextCache)
{ {
@ -97,7 +97,7 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans)
mFont->renderTextCache(mTextCache.get()); mFont->renderTextCache(mTextCache.get());
} }
//Renderer::popClipRect(); Renderer::popClipRect();
} }
void TextComponent::calculateExtent() void TextComponent::calculateExtent()

View file

@ -41,7 +41,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
{ {
ed = std::make_shared<RatingComponent>(window); ed = std::make_shared<RatingComponent>(window);
ed->setSize(0, lbl->getSize().y()); ed->setSize(0, lbl->getSize().y());
row.addElement(ed, false, false); row.addElement(ed, false, true);
mMenu.addRow(row); mMenu.addRow(row);
break; break;
} }

View file

@ -62,7 +62,7 @@ void TextureResource::initFromMemory(const char* data, size_t length)
if(imageRGBA.size() == 0) if(imageRGBA.size() == 0)
{ {
LOG(LogError) << "Could not initialize texture from memory (invalid data)!"; LOG(LogError) << "Could not initialize texture from memory, invalid data! (" << mPath << ")";
return; return;
} }