diff --git a/src/GuiComponent.cpp b/src/GuiComponent.cpp index 8cea223d5..816a09234 100644 --- a/src/GuiComponent.cpp +++ b/src/GuiComponent.cpp @@ -227,6 +227,23 @@ void GuiComponent::stopAnimation(unsigned char slot) } } +bool GuiComponent::isAnimationPlaying(unsigned char slot) const +{ + return mAnimationMap[slot] != NULL; +} + +bool GuiComponent::isAnimationReversed(unsigned char slot) const +{ + assert(mAnimationMap[slot] != NULL); + return mAnimationMap[slot]->isReversed(); +} + +int GuiComponent::getAnimationTime(unsigned char slot) const +{ + assert(mAnimationMap[slot] != NULL); + return mAnimationMap[slot]->getTime(); +} + void GuiComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) { Eigen::Vector2f scale = getParent() ? getParent()->getSize() : Eigen::Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); diff --git a/src/GuiComponent.h b/src/GuiComponent.h index 63aedd43c..0a0276638 100644 --- a/src/GuiComponent.h +++ b/src/GuiComponent.h @@ -53,6 +53,9 @@ public: GuiComponent* getChild(unsigned int i) const; // animation will be automatically deleted when it completes or is stopped. + bool isAnimationPlaying(unsigned char slot) const; + bool isAnimationReversed(unsigned char slot) const; + int getAnimationTime(unsigned char slot) const; void setAnimation(Animation* animation, std::function finishedCallback = nullptr, bool reverse = false, unsigned char slot = 0); void stopAnimation(unsigned char slot); diff --git a/src/animations/AnimationController.h b/src/animations/AnimationController.h index de28f62a5..91a086b9b 100644 --- a/src/animations/AnimationController.h +++ b/src/animations/AnimationController.h @@ -15,6 +15,9 @@ public: // Returns true if the animation is complete. bool update(int deltaTime); + inline bool isReversed() const { return mReverse; } + inline int getTime() const { return mTime; } + private: Animation* mAnimation; std::function mFinishedCallback; diff --git a/src/components/DateTimeComponent.cpp b/src/components/DateTimeComponent.cpp index 3bfc884e8..a705612ac 100644 --- a/src/components/DateTimeComponent.cpp +++ b/src/components/DateTimeComponent.cpp @@ -142,6 +142,8 @@ void DateTimeComponent::render(const Eigen::Affine3f& parentTrans) if(mTextCache) { std::shared_ptr font = getFont(); + + mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity()); font->renderTextCache(mTextCache.get()); if(mEditing) diff --git a/src/components/RatingComponent.cpp b/src/components/RatingComponent.cpp index a3f061fbb..f52baaf61 100644 --- a/src/components/RatingComponent.cpp +++ b/src/components/RatingComponent.cpp @@ -82,6 +82,8 @@ void RatingComponent::render(const Eigen::Affine3f& parentTrans) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(255, 255, 255, getOpacity()); + glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -100,6 +102,8 @@ void RatingComponent::render(const Eigen::Affine3f& parentTrans) glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); + glColor4ub(255, 255, 255, 255); + renderChildren(trans); } diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index fd12f1f40..b3f23f1b9 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -46,7 +46,7 @@ public: void setCursor(typename std::vector::const_iterator& it); void stopScrolling(); - inline bool isScrolling() const { return mScrollDir != 0; } + inline bool isScrolling() const { return mScrollDir != 0 && mScrollAccumulator >= 0; } enum CursorState { diff --git a/src/views/gamelist/DetailedGameListView.cpp b/src/views/gamelist/DetailedGameListView.cpp index 0717a4281..7eefa51c9 100644 --- a/src/views/gamelist/DetailedGameListView.cpp +++ b/src/views/gamelist/DetailedGameListView.cpp @@ -1,6 +1,7 @@ #include "DetailedGameListView.h" #include "../../Window.h" #include "../ViewController.h" +#include "../../animations/LambdaAnimation.h" DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : BasicGameListView(window, root), @@ -180,10 +181,12 @@ void DetailedGameListView::updateInfoPanel() { FileData* file = (mList.getList().size() == 0 || mList.isScrolling()) ? NULL : mList.getSelected(); + bool fadingOut; if(file == NULL) { - mImage.setImage(""); - mDescription.setText(""); + //mImage.setImage(""); + //mDescription.setText(""); + fadingOut = true; }else{ mImage.setImage(file->metadata.get("image")); mRating.setValue(file->metadata.get("rating")); @@ -198,6 +201,31 @@ void DetailedGameListView::updateInfoPanel() mDescription.setText(file->metadata.get("desc")); mDescContainer.resetAutoScrollTimer(); mDescContainer.setScrollPos(Eigen::Vector2d(0, 0)); + fadingOut = false; + } + + std::vector comps = getMDValues(); + comps.push_back(&mImage); + comps.push_back(&mDescription); + std::vector labels = getMDLabels(); + comps.insert(comps.end(), labels.begin(), labels.end()); + + for(auto it = comps.begin(); it != comps.end(); it++) + { + GuiComponent* comp = *it; + // an animation is playing + // then animate if reverse != fadingOut + // an animation is not playing + // then animate if opacity != our target opacity + if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || + (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) + { + auto func = [comp](float t) + { + comp->setOpacity((unsigned char)(lerp(0.0f, 1.0f, t)*255)); + }; + comp->setAnimation(new LambdaAnimation(func, 150), nullptr, fadingOut); + } } }