From 0c2b2e56f2c5d1b8d6900dbd4cd726f06511c77c Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Fri, 10 Jun 2016 18:30:14 +0200 Subject: [PATCH] Added support for onEnter/onExit to the scrolling lists. --- .../Graphics/Component/ScrollingList.cpp | 26 ++++++++++++++++++- .../Source/Graphics/Component/ScrollingList.h | 2 ++ RetroFE/Source/Graphics/Page.cpp | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 34d2785..fd5f7e3 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -51,7 +51,7 @@ ScrollingList::ScrollingList(Configuration &c, , spriteList_(NULL) , scrollPoints_(NULL) , tweenPoints_(NULL) - , focus_(true) + , focus_(false) , itemIndex_(0) , componentIndex_(0) , selectedOffsetIndex_(0) @@ -381,6 +381,30 @@ void ScrollingList::freeGraphicsMemory() deallocateSpritePoints(); } +void ScrollingList::triggerEnterEvent() +{ + focus_ = true; + notifyAllRequested_ = true; + + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "enter" ); + } +} + +void ScrollingList::triggerExitEvent() +{ + focus_ = false; + notifyAllRequested_ = true; + + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "exit" ); + } +} + void ScrollingList::triggerMenuEnterEvent( int menuIndex ) { focus_ = true; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 6c97004..4c92204 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -53,6 +53,8 @@ public: ScrollingList(const ScrollingList ©); virtual ~ScrollingList(); + void triggerEnterEvent(); + void triggerExitEvent(); void triggerMenuEnterEvent(int menuIndex = -1); void triggerMenuExitEvent(int menuIndex = -1); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index e9b6aef..e5cbd26 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -235,6 +235,7 @@ void Page::start() { ScrollingList *menu = *it; menu->triggerEvent( "enter" ); + menu->triggerEnterEvent(); } if(loadSoundChunk_) @@ -263,6 +264,7 @@ void Page::stop() { ScrollingList *menu = *it; menu->triggerEvent( "exit" ); + menu->triggerExitEvent(); } if(unloadSoundChunk_)