mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
Added animation types maxWidth, maxHeight, and nop (no-operation; do
nothing). Fixed onHighlightEnter and onHighlightExit animations, which were not started at all.
This commit is contained in:
parent
537322f9c0
commit
a55fd84d58
@ -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);
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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<Component *>::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<Component *>::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_;
|
||||
}
|
||||
|
||||
@ -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_;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user