Replaced hard-coded background + title in SystemView with a ThemeExtras

layer.
This commit is contained in:
Aloshi 2014-02-27 14:20:31 -06:00
parent 0266b2e802
commit 4c3b4834be
4 changed files with 11 additions and 31 deletions

View file

@ -167,6 +167,7 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/components/IList.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/IList.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageGridComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageGridComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/MenuComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/OptionListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/OptionListComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h
@ -245,6 +246,7 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/HelpComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/HelpComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/MenuComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.cpp

View file

@ -310,9 +310,7 @@ Reference
#### system #### system
* `image name="header"` - PATH * `image name="header"` - PATH
- A header (logo) image, to be displayed in the system logo carousel. - A header (logo) image, to be displayed in the system logo carousel.
* `image name="systemImage"` - PATH * You can use extra elements (elements with `extra="true"`) to add your own backgrounds, etc. They will be displayed behind the carousel, and scroll relative to the carousel.
- A background image displayed behind the carousel. Intended to be a picture of the console on a transparent background (an image with no obvious border).
--- ---
#### fastSelect #### fastSelect

View file

@ -49,23 +49,9 @@ void SystemView::populate()
e.data.logo = std::shared_ptr<GuiComponent>(text); e.data.logo = std::shared_ptr<GuiComponent>(text);
} }
// make title // make background extras
e.data.title = std::shared_ptr<TextComponent>(new TextComponent(mWindow)); e.data.backgroundExtras = std::shared_ptr<ThemeExtras>(new ThemeExtras(mWindow));
e.data.title->setFont(Font::get(FONT_SIZE_LARGE)); e.data.backgroundExtras->setExtras(ThemeData::makeExtras((*it)->getTheme(), "system", mWindow));
e.data.title->setSize(mSize.x(), (float)FONT_SIZE_LARGE);
e.data.title->setText((*it)->getFullName());
e.data.title->setCentered(true);
// make background
if(theme->getElement("system", "systemImage", "image"))
{
e.data.background = std::shared_ptr<ImageComponent>(new ImageComponent(mWindow));
e.data.background->applyTheme(theme, "system", "systemImage", ThemeFlags::PATH);
e.data.background->setOpacity((unsigned char)(255 * 0.75f)); // make it 75% opaque
e.data.background->setPosition((mSize.x() - e.data.background->getSize().x()) / 2, (mSize.y() - e.data.background->getSize().y()) / 2); // center it (it's drawn at (0, 0))
}else{
e.data.background = nullptr;
}
this->add(e); this->add(e);
} }
@ -158,8 +144,8 @@ void SystemView::render(const Eigen::Affine3f& parentTrans)
int logoCount = (int)(mSize.x() / logoSizeX) + 2; // how many logos we need to draw int logoCount = (int)(mSize.x() / logoSizeX) + 2; // how many logos we need to draw
int center = (int)(mCamOffset); int center = (int)(mCamOffset);
// draw titles + background images (same transforms) // draw background extras
Eigen::Affine3f titleTrans = trans; Eigen::Affine3f extrasTrans = trans;
for(int i = center - 1; i < center + 2; i++) for(int i = center - 1; i < center + 2; i++)
{ {
int index = i; int index = i;
@ -168,14 +154,9 @@ void SystemView::render(const Eigen::Affine3f& parentTrans)
while(index >= (int)mEntries.size()) while(index >= (int)mEntries.size())
index -= mEntries.size(); index -= mEntries.size();
titleTrans.translation() = trans.translation() + Eigen::Vector3f((i - mCamOffset) * mSize.x(), 0, 0); extrasTrans.translation() = trans.translation() + Eigen::Vector3f((i - mCamOffset) * mSize.x(), 0, 0);
// background image (might not exist) mEntries.at(index).data.backgroundExtras->render(extrasTrans);
if(mEntries.at(index).data.background)
mEntries.at(index).data.background->render(titleTrans);
// title (always exists)
mEntries.at(index).data.title->render(titleTrans);
} }
// draw logos // draw logos

View file

@ -11,9 +11,8 @@ class SystemData;
struct SystemViewData struct SystemViewData
{ {
std::shared_ptr<TextComponent> title;
std::shared_ptr<GuiComponent> logo; std::shared_ptr<GuiComponent> logo;
std::shared_ptr<ImageComponent> background; std::shared_ptr<ThemeExtras> backgroundExtras;
}; };
class SystemView : public IList<SystemViewData, SystemData*> class SystemView : public IList<SystemViewData, SystemData*>