Redid SystemView to keep "selected" versions of logos.

Should make SVG logos look better + no more pixelated text.
This commit is contained in:
Aloshi 2014-03-29 16:55:32 -05:00
parent e719a867be
commit aa65a80039
2 changed files with 33 additions and 25 deletions

View file

@ -37,17 +37,32 @@ void SystemView::populate()
ImageComponent* logo = new ImageComponent(mWindow); ImageComponent* logo = new ImageComponent(mWindow);
logo->setMaxSize(logoSize()); logo->setMaxSize(logoSize());
logo->applyTheme((*it)->getTheme(), "system", "logo", ThemeFlags::PATH); logo->applyTheme((*it)->getTheme(), "system", "logo", ThemeFlags::PATH);
logo->setPosition((logoSize().x() - logo->getSize().x()) / 2, (logoSize().y() - logo->getSize().y()) / 2); // vertically and horizontally center logo->setPosition((logoSize().x() - logo->getSize().x()) / 2, (logoSize().y() - logo->getSize().y()) / 2); // center
e.data.logo = std::shared_ptr<GuiComponent>(logo); e.data.logo = std::shared_ptr<GuiComponent>(logo);
ImageComponent* logoSelected = new ImageComponent(mWindow);
logoSelected->setMaxSize(logoSize() * SELECTED_SCALE);
logoSelected->applyTheme((*it)->getTheme(), "system", "logo", ThemeFlags::PATH);
logoSelected->setPosition((logoSize().x() - logoSelected->getSize().x()) / 2,
(logoSize().y() - logoSelected->getSize().y()) / 2); // center
e.data.logoSelected = std::shared_ptr<GuiComponent>(logoSelected);
}else{ }else{
// no logo in theme; use text // no logo in theme; use text
TextComponent* text = new TextComponent(mWindow); TextComponent* text = new TextComponent(mWindow,
text->setFont(Font::get(FONT_SIZE_LARGE)); (*it)->getName(),
text->setText((*it)->getName()); Font::get(FONT_SIZE_LARGE),
text->setSize(logoSize().x(), 0); 0x000000FF,
text->setPosition(0, (logoSize().y() - text->getSize().y()) / 2); // vertically center TextComponent::ALIGN_CENTER);
text->setAlignment(TextComponent::ALIGN_CENTER); text->setSize(logoSize());
e.data.logo = std::shared_ptr<GuiComponent>(text); e.data.logo = std::shared_ptr<GuiComponent>(text);
TextComponent* textSelected = new TextComponent(mWindow,
(*it)->getName(),
Font::get((int)(FONT_SIZE_LARGE * SELECTED_SCALE)),
0x000000FF,
TextComponent::ALIGN_CENTER);
textSelected->setSize(logoSize());
e.data.logoSelected = std::shared_ptr<GuiComponent>(textSelected);
} }
// make background extras // make background extras
@ -178,25 +193,17 @@ void SystemView::render(const Eigen::Affine3f& parentTrans)
logoTrans.translation() = trans.translation() + Eigen::Vector3f(i * logoSizeX + xOff, yOff, 0); logoTrans.translation() = trans.translation() + Eigen::Vector3f(i * logoSizeX + xOff, yOff, 0);
std::shared_ptr<GuiComponent> comp = mEntries.at(index).data.logo; if(index == mCursor) //scale our selection up
if(comp)
{ {
if(index == mCursor) //scale our selection up // selected
{ const std::shared_ptr<GuiComponent>& comp = mEntries.at(index).data.logoSelected;
comp->setOpacity(0xFF); comp->setOpacity(0xFF);
comp->render(logoTrans);
// fix the centering because we go by left corner and not center (bleh) }else{
// CAN SOMEONE WHO ACTUALLY UNDERSTANDS MATRICES GIVE AN ACTUAL IMPLEMENTATION OF THIS THAT ACTUALLY WORKS? // not selected
logoTrans.translation() -= Eigen::Vector3f(((comp->getSize().x() + comp->getPosition().x()) * (1/SELECTED_SCALE)) / 2, const std::shared_ptr<GuiComponent>& comp = mEntries.at(index).data.logo;
((comp->getSize().y() + comp->getPosition().y()) * (1/SELECTED_SCALE)) / 2, 0); comp->setOpacity(0x80);
comp->render(logoTrans);
logoTrans.scale(Eigen::Vector3f(SELECTED_SCALE, SELECTED_SCALE, 1.0f));
mEntries.at(index).data.logo->render(logoTrans);
logoTrans.scale(Eigen::Vector3f(1/SELECTED_SCALE, 1/SELECTED_SCALE, 1.0f));
}else{
comp->setOpacity(0x80);
mEntries.at(index).data.logo->render(logoTrans);
}
} }
} }
} }

View file

@ -12,6 +12,7 @@ class SystemData;
struct SystemViewData struct SystemViewData
{ {
std::shared_ptr<GuiComponent> logo; std::shared_ptr<GuiComponent> logo;
std::shared_ptr<GuiComponent> logoSelected;
std::shared_ptr<ThemeExtras> backgroundExtras; std::shared_ptr<ThemeExtras> backgroundExtras;
}; };