From a55fd84d5884c407bc2cc5e19f9f6737178abc26 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Fri, 10 Jun 2016 12:10:36 +0200 Subject: [PATCH] Added animation types maxWidth, maxHeight, and nop (no-operation; do nothing). Fixed onHighlightEnter and onHighlightExit animations, which were not started at all. --- RetroFE/Source/Graphics/Animate/Tween.cpp | 25 +++++++++-------- RetroFE/Source/Graphics/Animate/TweenTypes.h | 3 ++ .../Source/Graphics/Component/Component.cpp | 17 +++++++++++ .../Graphics/Component/ScrollingList.cpp | 2 ++ RetroFE/Source/Graphics/Page.cpp | 14 +++++++--- RetroFE/Source/Graphics/Page.h | 5 ++-- RetroFE/Source/Graphics/PageBuilder.cpp | 28 ++++++++++++++++--- RetroFE/Source/RetroFE.cpp | 22 +++++++++++++++ RetroFE/Source/RetroFE.h | 3 ++ 9 files changed, 98 insertions(+), 21 deletions(-) diff --git a/RetroFE/Source/Graphics/Animate/Tween.cpp b/RetroFE/Source/Graphics/Animate/Tween.cpp index edf3340..9568dde 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.cpp +++ b/RetroFE/Source/Graphics/Animate/Tween.cpp @@ -39,18 +39,21 @@ bool Tween::getTweenProperty(std::string name, TweenProperty &property) if(tweenPropertyMap_.size() == 0) { - tweenPropertyMap_["x"] = TWEEN_PROPERTY_X; - tweenPropertyMap_["y"] = TWEEN_PROPERTY_Y; - tweenPropertyMap_["angle"] = TWEEN_PROPERTY_ANGLE; - tweenPropertyMap_["alpha"] = TWEEN_PROPERTY_ALPHA; - tweenPropertyMap_["width"] = TWEEN_PROPERTY_WIDTH; - tweenPropertyMap_["height"] = TWEEN_PROPERTY_HEIGHT; - tweenPropertyMap_["xorigin"] = TWEEN_PROPERTY_X_ORIGIN; - tweenPropertyMap_["yorigin"] = TWEEN_PROPERTY_Y_ORIGIN; - tweenPropertyMap_["xoffset"] = TWEEN_PROPERTY_X_OFFSET; - tweenPropertyMap_["yoffset"] = TWEEN_PROPERTY_Y_OFFSET; - tweenPropertyMap_["fontSize"] = TWEEN_PROPERTY_FONT_SIZE; + tweenPropertyMap_["x"] = TWEEN_PROPERTY_X; + tweenPropertyMap_["y"] = TWEEN_PROPERTY_Y; + tweenPropertyMap_["angle"] = TWEEN_PROPERTY_ANGLE; + tweenPropertyMap_["alpha"] = TWEEN_PROPERTY_ALPHA; + tweenPropertyMap_["width"] = TWEEN_PROPERTY_WIDTH; + tweenPropertyMap_["height"] = TWEEN_PROPERTY_HEIGHT; + tweenPropertyMap_["xorigin"] = TWEEN_PROPERTY_X_ORIGIN; + tweenPropertyMap_["yorigin"] = TWEEN_PROPERTY_Y_ORIGIN; + tweenPropertyMap_["xoffset"] = TWEEN_PROPERTY_X_OFFSET; + tweenPropertyMap_["yoffset"] = TWEEN_PROPERTY_Y_OFFSET; + tweenPropertyMap_["fontSize"] = TWEEN_PROPERTY_FONT_SIZE; tweenPropertyMap_["backgroundalpha"] = TWEEN_PROPERTY_BACKGROUND_ALPHA; + tweenPropertyMap_["maxwidth"] = TWEEN_PROPERTY_MAX_WIDTH; + tweenPropertyMap_["maxheight"] = TWEEN_PROPERTY_MAX_HEIGHT; + tweenPropertyMap_["nop"] = TWEEN_PROPERTY_NOP; } std::transform(name.begin(), name.end(), name.begin(), ::tolower); diff --git a/RetroFE/Source/Graphics/Animate/TweenTypes.h b/RetroFE/Source/Graphics/Animate/TweenTypes.h index c9d61d6..8d27931 100644 --- a/RetroFE/Source/Graphics/Animate/TweenTypes.h +++ b/RetroFE/Source/Graphics/Animate/TweenTypes.h @@ -55,4 +55,7 @@ enum TweenProperty TWEEN_PROPERTY_Y_OFFSET, TWEEN_PROPERTY_FONT_SIZE, TWEEN_PROPERTY_BACKGROUND_ALPHA, + TWEEN_PROPERTY_MAX_WIDTH, + TWEEN_PROPERTY_MAX_HEIGHT, + TWEEN_PROPERTY_NOP, }; diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index edbb1d7..3d243b2 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -287,6 +287,23 @@ bool Component::animate() else baseViewInfo.BackgroundAlpha = tween->animate(elapsedTime, storeViewInfo_.BackgroundAlpha); break; + + case TWEEN_PROPERTY_MAX_WIDTH: + if (tween->startDefined) + baseViewInfo.MaxWidth = tween->animate(elapsedTime); + else + baseViewInfo.MaxWidth = tween->animate(elapsedTime, storeViewInfo_.MaxWidth); + break; + + case TWEEN_PROPERTY_MAX_HEIGHT: + if (tween->startDefined) + baseViewInfo.MaxHeight = tween->animate(elapsedTime); + else + baseViewInfo.MaxHeight = tween->animate(elapsedTime, storeViewInfo_.MaxHeight); + break; + + case TWEEN_PROPERTY_NOP: + break; } } diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 83acea2..acb3f8d 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -580,6 +580,8 @@ void ScrollingList::resetTweens(Component *c, AnimationEvents *sets, ViewInfo *c set->push(new Tween(TWEEN_PROPERTY_Y_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo->YOffset, nextViewInfo->YOffset, scrollTime)); set->push(new Tween(TWEEN_PROPERTY_FONT_SIZE, EASE_INOUT_QUADRATIC, currentViewInfo->FontSize, nextViewInfo->FontSize, scrollTime)); set->push(new Tween(TWEEN_PROPERTY_BACKGROUND_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo->BackgroundAlpha, nextViewInfo->BackgroundAlpha, scrollTime)); + set->push(new Tween(TWEEN_PROPERTY_MAX_WIDTH, EASE_INOUT_QUADRATIC, currentViewInfo->MaxWidth, nextViewInfo->MaxWidth, scrollTime)); + set->push(new Tween(TWEEN_PROPERTY_MAX_HEIGHT, EASE_INOUT_QUADRATIC, currentViewInfo->MaxHeight, nextViewInfo->MaxHeight, scrollTime)); scrollTween->Push(set); } diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index fe074d5..078e899 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -372,14 +372,14 @@ void Page::highlightEnter() if(!item) return; if(activeMenu_) { - activeMenu_->triggerEvent( "highlightEnter" ); + activeMenu_->triggerEvent( "highlightEnter", menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) { for(std::vector::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) { - (*it)->triggerEvent( "highlightEnter" ); + (*it)->triggerEvent( "highlightEnter", menuDepth_ - 1 ); } } } @@ -392,14 +392,14 @@ void Page::highlightExit() if(!item) return; if(activeMenu_) { - activeMenu_->triggerEvent( "highlightExit" ); + activeMenu_->triggerEvent( "highlightExit", menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) { for(std::vector::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) { - (*it)->triggerEvent( "highlightExit" ); + (*it)->triggerEvent( "highlightExit", menuDepth_ - 1 ); } } } @@ -862,3 +862,9 @@ void Page::resetMenuItems() activeMenu_->deallocateSpritePoints(); activeMenu_->allocateSpritePoints(); } + + +bool Page::isMenuScrolling() +{ + return scrollActive_; +} diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index a68fc67..f31e322 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -87,13 +87,14 @@ public: std::string getCollectionName(); void setMinShowTime(float value); float getMinShowTime(); + void highlightEnter(); + void highlightExit(); void addPlaylist(); void removePlaylist(); void resetMenuItems(); + bool isMenuScrolling(); private: - void highlightEnter(); - void highlightExit(); void playlistChange(); std::string collectionName_; Configuration &config_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index d4d0167..617af2a 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -643,9 +643,9 @@ ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml, Page &page) if(scrollOrientationXml) { std::string scrollOrientation = scrollOrientationXml->value(); - if(scrollOrientation == "horizontal") + if(scrollOrientation == "horizontal") { - menu->horizontalScroll = true; + menu->horizontalScroll = true; } } @@ -966,11 +966,18 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) xml_attribute<> *to = animate->first_attribute("to"); xml_attribute<> *algorithmXml = animate->first_attribute("algorithm"); + std::string animateType; + if (type) + { + animateType = type->value(); + } + + if(!type) { Logger::write(Logger::ZONE_ERROR, "Layout", "Animate tag missing \"type\" attribute"); } - else if(!to) + else if(!to && animateType != "nop") { Logger::write(Logger::ZONE_ERROR, "Layout", "Animate tag missing \"to\" attribute"); } @@ -979,10 +986,18 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) float fromValue = 0.0f; bool fromDefined = true; if (from) + { fromValue = Utils::convertFloat(from->value()); + } else + { fromDefined = false; - float toValue = Utils::convertFloat(to->value()); + } + float toValue = 0.0f; + if (to) + { + toValue = Utils::convertFloat(to->value()); + } float durationValue = Utils::convertFloat(durationXml->value()); TweenAlgorithm algorithm = LINEAR; @@ -1025,6 +1040,11 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) toValue = getVerticalAlignment(to, 0) / screenHeight_; break; + case TWEEN_PROPERTY_MAX_WIDTH: + case TWEEN_PROPERTY_MAX_HEIGHT: + fromValue = getVerticalAlignment(from, FLT_MAX); + toValue = getVerticalAlignment(to, FLT_MAX); + default: break; } diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index f8577c8..6e96806 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -334,6 +334,26 @@ void RetroFE::run() } break; + case RETROFE_HIGHLIGHT_REQUEST: + currentPage_->highlightExit(); + state = RETROFE_HIGHLIGHT_EXIT; + break; + + case RETROFE_HIGHLIGHT_EXIT: + if (currentPage_->isIdle()) + { + currentPage_->highlightEnter(); + state = RETROFE_HIGHLIGHT_ENTER; + } + break; + + case RETROFE_HIGHLIGHT_ENTER: + if (currentPage_->isIdle()) + { + state = RETROFE_IDLE; + } + break; + case RETROFE_NEXT_PAGE_REQUEST: currentPage_->exitMenu(); state = RETROFE_NEXT_PAGE_MENU_EXIT; @@ -636,6 +656,8 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) !input_.keystate(UserInput::KeyCodePageUp) && !input_.keystate(UserInput::KeyCodePageDown)) { + if (page->isMenuScrolling()) + state = RETROFE_HIGHLIGHT_REQUEST; page->setScrolling(Page::ScrollDirectionIdle); } diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index 48883d2..296751f 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -54,6 +54,9 @@ private: RETROFE_IDLE, RETROFE_ENTER, RETROFE_EXIT, + RETROFE_HIGHLIGHT_REQUEST, + RETROFE_HIGHLIGHT_EXIT, + RETROFE_HIGHLIGHT_ENTER, RETROFE_NEXT_PAGE_REQUEST, RETROFE_NEXT_PAGE_MENU_EXIT, RETROFE_NEXT_PAGE_MENU_ENTER,