From 4c3b4834be37816ecd35d0ec1aa9da88a606fd43 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 27 Feb 2014 14:20:31 -0600 Subject: [PATCH] Replaced hard-coded background + title in SystemView with a ThemeExtras layer. --- CMakeLists.txt | 2 ++ THEMES.md | 4 +--- src/views/SystemView.cpp | 33 +++++++-------------------------- src/views/SystemView.h | 3 +-- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e8de9ed9..abf5a2c12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,7 @@ set(ES_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/components/IList.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.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/OptionListComponent.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/HelpComponent.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/RatingComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.cpp diff --git a/THEMES.md b/THEMES.md index 124a1fa48..d3234b55d 100644 --- a/THEMES.md +++ b/THEMES.md @@ -310,9 +310,7 @@ Reference #### system * `image name="header"` - PATH - A header (logo) image, to be displayed in the system logo carousel. -* `image name="systemImage"` - PATH - - 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). - +* 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. --- #### fastSelect diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 156819132..3a643477c 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -49,23 +49,9 @@ void SystemView::populate() e.data.logo = std::shared_ptr(text); } - // make title - e.data.title = std::shared_ptr(new TextComponent(mWindow)); - e.data.title->setFont(Font::get(FONT_SIZE_LARGE)); - 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(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; - } + // make background extras + e.data.backgroundExtras = std::shared_ptr(new ThemeExtras(mWindow)); + e.data.backgroundExtras->setExtras(ThemeData::makeExtras((*it)->getTheme(), "system", mWindow)); 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 center = (int)(mCamOffset); - // draw titles + background images (same transforms) - Eigen::Affine3f titleTrans = trans; + // draw background extras + Eigen::Affine3f extrasTrans = trans; for(int i = center - 1; i < center + 2; i++) { int index = i; @@ -168,14 +154,9 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) while(index >= (int)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) - if(mEntries.at(index).data.background) - mEntries.at(index).data.background->render(titleTrans); - - // title (always exists) - mEntries.at(index).data.title->render(titleTrans); + mEntries.at(index).data.backgroundExtras->render(extrasTrans); } // draw logos diff --git a/src/views/SystemView.h b/src/views/SystemView.h index a28f51553..ede6d7460 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -11,9 +11,8 @@ class SystemData; struct SystemViewData { - std::shared_ptr title; std::shared_ptr logo; - std::shared_ptr background; + std::shared_ptr backgroundExtras; }; class SystemView : public IList