mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
full "any component following menu" scroll working
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
ee3c2dd67f
commit
8e777aba46
@ -84,12 +84,15 @@ void ReloadableMedia::update(float dt)
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Reload media
|
// Reload media
|
||||||
if (newItemSelected ||
|
if (newItemSelected)
|
||||||
(newScrollItemSelected && getMenuScrollReload()))
|
|
||||||
{
|
{
|
||||||
reloadTexture();
|
reloadTexture();
|
||||||
newItemSelected = false;
|
newItemSelected = false;
|
||||||
newScrollItemSelected = false;
|
}
|
||||||
|
else if(newScrollItemSelected && getMenuScrollReload())
|
||||||
|
{
|
||||||
|
reloadTexture(true);
|
||||||
|
newScrollItemSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loadedComponent_)
|
if(loadedComponent_)
|
||||||
@ -134,6 +137,11 @@ void ReloadableMedia::freeGraphicsMemory()
|
|||||||
|
|
||||||
|
|
||||||
void ReloadableMedia::reloadTexture()
|
void ReloadableMedia::reloadTexture()
|
||||||
|
{
|
||||||
|
reloadTexture(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReloadableMedia::reloadTexture( bool previousItem )
|
||||||
{
|
{
|
||||||
if(loadedComponent_)
|
if(loadedComponent_)
|
||||||
{
|
{
|
||||||
@ -141,7 +149,14 @@ void ReloadableMedia::reloadTexture()
|
|||||||
loadedComponent_ = NULL;
|
loadedComponent_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item *selectedItem = page.getSelectedItem(displayOffset_);
|
/* Select item to reload */
|
||||||
|
Item *selectedItem = NULL;
|
||||||
|
if(previousItem){
|
||||||
|
selectedItem = page.getPreviousSelectedItem(displayOffset_);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
selectedItem = page.getSelectedItem(displayOffset_);
|
||||||
|
}
|
||||||
if(!selectedItem) return;
|
if(!selectedItem) return;
|
||||||
|
|
||||||
config_.getProperty("currentCollection", currentCollection_);
|
config_.getProperty("currentCollection", currentCollection_);
|
||||||
@ -490,9 +505,9 @@ void ReloadableMedia::draw()
|
|||||||
|
|
||||||
if(loadedComponent_)
|
if(loadedComponent_)
|
||||||
{
|
{
|
||||||
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
||||||
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
||||||
loadedComponent_->baseViewInfo = baseViewInfo;
|
loadedComponent_->baseViewInfo = baseViewInfo;
|
||||||
loadedComponent_->draw();
|
loadedComponent_->draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,8 @@ public:
|
|||||||
void enableImageFallback_(bool value);
|
void enableImageFallback_(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reloadTexture();
|
void reloadTexture( );
|
||||||
|
void reloadTexture( bool previousItem );
|
||||||
Configuration &config_;
|
Configuration &config_;
|
||||||
bool systemMode_;
|
bool systemMode_;
|
||||||
bool layoutMode_;
|
bool layoutMode_;
|
||||||
|
|||||||
@ -112,7 +112,8 @@ void ScrollingList::setItems( std::vector<Item *> *items )
|
|||||||
items_ = items;
|
items_ = items;
|
||||||
if ( items_ )
|
if ( items_ )
|
||||||
{
|
{
|
||||||
itemIndex_ = loopDecrement( 0, selectedOffsetIndex_, items_->size( ) );
|
prevItemIndex_ = itemIndex_;
|
||||||
|
itemIndex_ = loopDecrement( 0, selectedOffsetIndex_, items_->size( ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +213,8 @@ void ScrollingList::setPoints( std::vector<ViewInfo *> *scrollPoints, std::vecto
|
|||||||
|
|
||||||
if ( items_ )
|
if ( items_ )
|
||||||
{
|
{
|
||||||
itemIndex_ = loopDecrement( 0, selectedOffsetIndex_, items_->size( ) );
|
prevItemIndex_ = itemIndex_;
|
||||||
|
itemIndex_ = loopDecrement( 0, selectedOffsetIndex_, items_->size( ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,6 +227,7 @@ unsigned int ScrollingList::getScrollOffsetIndex( )
|
|||||||
|
|
||||||
void ScrollingList::setScrollOffsetIndex( unsigned int index )
|
void ScrollingList::setScrollOffsetIndex( unsigned int index )
|
||||||
{
|
{
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopDecrement( index, selectedOffsetIndex_, items_->size( ) );
|
itemIndex_ = loopDecrement( index, selectedOffsetIndex_, items_->size( ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,6 +258,27 @@ Item *ScrollingList::getItemByOffset( int offset )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item *ScrollingList::getPreviousItemByOffset( int offset )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( !items_ || items_->size( ) == 0 ) return NULL;
|
||||||
|
|
||||||
|
unsigned int index = getPreviousSelectedIndex( );
|
||||||
|
|
||||||
|
if ( offset >= 0 )
|
||||||
|
{
|
||||||
|
index = loopIncrement( index, offset, items_->size( ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = loopDecrement( index, offset*-1, items_->size( ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return items_->at( index );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item *ScrollingList::getSelectedItem( )
|
Item *ScrollingList::getSelectedItem( )
|
||||||
{
|
{
|
||||||
if ( !items_ || items_->size( ) == 0 ) return NULL;
|
if ( !items_ || items_->size( ) == 0 ) return NULL;
|
||||||
@ -265,6 +289,7 @@ Item *ScrollingList::getSelectedItem( )
|
|||||||
void ScrollingList::pageUp( )
|
void ScrollingList::pageUp( )
|
||||||
{
|
{
|
||||||
if ( components_.size( ) == 0 ) return;
|
if ( components_.size( ) == 0 ) return;
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopDecrement( itemIndex_, components_.size( ), items_->size( ) );
|
itemIndex_ = loopDecrement( itemIndex_, components_.size( ), items_->size( ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +297,7 @@ void ScrollingList::pageUp( )
|
|||||||
void ScrollingList::pageDown( )
|
void ScrollingList::pageDown( )
|
||||||
{
|
{
|
||||||
if ( components_.size( ) == 0 ) return;
|
if ( components_.size( ) == 0 ) return;
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopIncrement( itemIndex_, components_.size( ), items_->size( ) );
|
itemIndex_ = loopIncrement( itemIndex_, components_.size( ), items_->size( ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +305,7 @@ void ScrollingList::pageDown( )
|
|||||||
void ScrollingList::random( )
|
void ScrollingList::random( )
|
||||||
{
|
{
|
||||||
if ( !items_ || items_->size( ) == 0 ) return;
|
if ( !items_ || items_->size( ) == 0 ) return;
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = rand( ) % items_->size( );
|
itemIndex_ = rand( ) % items_->size( );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +347,7 @@ void ScrollingList::letterChange( bool increment )
|
|||||||
if ((isalpha(startname[0] ) ^ isalpha(endname[0] ) ) ||
|
if ((isalpha(startname[0] ) ^ isalpha(endname[0] ) ) ||
|
||||||
(isalpha(startname[0] ) && isalpha(endname[0] ) && startname[0] != endname[0] ) )
|
(isalpha(startname[0] ) && isalpha(endname[0] ) && startname[0] != endname[0] ) )
|
||||||
{
|
{
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = index;
|
itemIndex_ = index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -339,8 +367,9 @@ void ScrollingList::letterChange( bool increment )
|
|||||||
if ((isalpha(startname[0] ) ^ isalpha(endname[0] ) ) ||
|
if ((isalpha(startname[0] ) ^ isalpha(endname[0] ) ) ||
|
||||||
(isalpha(startname[0] ) && isalpha(endname[0] ) && startname[0] != endname[0] ) )
|
(isalpha(startname[0] ) && isalpha(endname[0] ) && startname[0] != endname[0] ) )
|
||||||
{
|
{
|
||||||
itemIndex_ = loopIncrement( index,1,items_->size( ) );
|
prevItemIndex_ = itemIndex_;
|
||||||
break;
|
itemIndex_ = loopIncrement( index,1,items_->size( ) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -503,9 +532,17 @@ unsigned int ScrollingList::getSelectedIndex( )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int ScrollingList::getPreviousSelectedIndex( )
|
||||||
|
{
|
||||||
|
if ( !items_ ) return 0;
|
||||||
|
return loopIncrement( prevItemIndex_, selectedOffsetIndex_, items_->size( ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScrollingList::setSelectedIndex( unsigned int index )
|
void ScrollingList::setSelectedIndex( unsigned int index )
|
||||||
{
|
{
|
||||||
if ( !items_ ) return;
|
if ( !items_ ) return;
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopDecrement( index, selectedOffsetIndex_, items_->size( ) );
|
itemIndex_ = loopDecrement( index, selectedOffsetIndex_, items_->size( ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,6 +859,7 @@ void ScrollingList::scroll( bool forward )
|
|||||||
{
|
{
|
||||||
scrollDirectionForward_ = true;
|
scrollDirectionForward_ = true;
|
||||||
Item *i = items_->at( loopIncrement( itemIndex_, scrollPoints_->size( ), items_->size( ) ) );
|
Item *i = items_->at( loopIncrement( itemIndex_, scrollPoints_->size( ), items_->size( ) ) );
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopIncrement( itemIndex_, 1, items_->size( ) );
|
itemIndex_ = loopIncrement( itemIndex_, 1, items_->size( ) );
|
||||||
deallocateTexture( 0 );
|
deallocateTexture( 0 );
|
||||||
allocateTexture( 0, i );
|
allocateTexture( 0, i );
|
||||||
@ -830,6 +868,7 @@ void ScrollingList::scroll( bool forward )
|
|||||||
{
|
{
|
||||||
scrollDirectionForward_ = false;
|
scrollDirectionForward_ = false;
|
||||||
Item *i = items_->at( loopDecrement( itemIndex_, 1, items_->size( ) ) );
|
Item *i = items_->at( loopDecrement( itemIndex_, 1, items_->size( ) ) );
|
||||||
|
prevItemIndex_ = itemIndex_;
|
||||||
itemIndex_ = loopDecrement( itemIndex_, 1, items_->size( ) );
|
itemIndex_ = loopDecrement( itemIndex_, 1, items_->size( ) );
|
||||||
deallocateTexture( loopDecrement( 0, 1, components_.size( ) ) );
|
deallocateTexture( loopDecrement( 0, 1, components_.size( ) ) );
|
||||||
allocateTexture( loopDecrement( 0, 1, components_.size( ) ), i );
|
allocateTexture( loopDecrement( 0, 1, components_.size( ) ), i );
|
||||||
|
|||||||
@ -64,6 +64,7 @@ public:
|
|||||||
void destroyItems( );
|
void destroyItems( );
|
||||||
void setPoints( std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints );
|
void setPoints( std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints );
|
||||||
unsigned int getSelectedIndex( );
|
unsigned int getSelectedIndex( );
|
||||||
|
unsigned int getPreviousSelectedIndex( );
|
||||||
void setSelectedIndex( unsigned int index );
|
void setSelectedIndex( unsigned int index );
|
||||||
unsigned int getSize( );
|
unsigned int getSize( );
|
||||||
void pageUp( );
|
void pageUp( );
|
||||||
@ -79,6 +80,7 @@ public:
|
|||||||
void setScrollOffsetIndex( unsigned int index );
|
void setScrollOffsetIndex( unsigned int index );
|
||||||
void setSelectedIndex( int selectedIndex );
|
void setSelectedIndex( int selectedIndex );
|
||||||
Item *getItemByOffset( int offset );
|
Item *getItemByOffset( int offset );
|
||||||
|
Item *getPreviousItemByOffset( int offset );
|
||||||
Item *getSelectedItem( );
|
Item *getSelectedItem( );
|
||||||
void allocateGraphicsMemory( );
|
void allocateGraphicsMemory( );
|
||||||
void freeGraphicsMemory( );
|
void freeGraphicsMemory( );
|
||||||
@ -107,12 +109,14 @@ private:
|
|||||||
std::vector<AnimationEvents *> *tweenPoints_;
|
std::vector<AnimationEvents *> *tweenPoints_;
|
||||||
|
|
||||||
unsigned int itemIndex_;
|
unsigned int itemIndex_;
|
||||||
|
unsigned int prevItemIndex_;
|
||||||
unsigned int selectedOffsetIndex_;
|
unsigned int selectedOffsetIndex_;
|
||||||
|
|
||||||
float scrollAcceleration_;
|
float scrollAcceleration_;
|
||||||
float startScrollTime_;
|
float startScrollTime_;
|
||||||
float scrollPeriod_;
|
float scrollPeriod_;
|
||||||
int scrollAccelerationIdx_;
|
int scrollAccelerationIdx_;
|
||||||
|
bool scrollDirectionForward_;
|
||||||
|
|
||||||
Configuration &config_;
|
Configuration &config_;
|
||||||
float scaleX_;
|
float scaleX_;
|
||||||
@ -124,5 +128,4 @@ private:
|
|||||||
std::vector<Item *> *items_;
|
std::vector<Item *> *items_;
|
||||||
std::vector<Component *> components_;
|
std::vector<Component *> components_;
|
||||||
|
|
||||||
bool scrollDirectionForward_;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,7 +34,6 @@ Page::Page(Configuration &config)
|
|||||||
, scrollActive_(false)
|
, scrollActive_(false)
|
||||||
, scrollDirectionForward_(false)
|
, scrollDirectionForward_(false)
|
||||||
, selectedItem_(NULL)
|
, selectedItem_(NULL)
|
||||||
, selectNextItemAfterScroll_(false)
|
|
||||||
, textStatusComponent_(NULL)
|
, textStatusComponent_(NULL)
|
||||||
, loadSoundChunk_(NULL)
|
, loadSoundChunk_(NULL)
|
||||||
, unloadSoundChunk_(NULL)
|
, unloadSoundChunk_(NULL)
|
||||||
@ -168,17 +167,15 @@ void Page::onNewItemSelected()
|
|||||||
|
|
||||||
void Page::onNewScrollItemSelected()
|
void Page::onNewScrollItemSelected()
|
||||||
{
|
{
|
||||||
if(selectNextItemAfterScroll_){
|
|
||||||
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return;
|
|
||||||
selectedItem_ = activeMenu_[0]->getSelectedItem();
|
|
||||||
|
|
||||||
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return;
|
||||||
{
|
selectedItem_ = activeMenu_[0]->getSelectedItem();
|
||||||
(*it)->setNewScrollItemSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
selectNextItemAfterScroll_ = false;
|
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->setNewScrollItemSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -360,6 +357,12 @@ Item *Page::getSelectedItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item *Page::getPrevSelectedItem_()
|
||||||
|
{
|
||||||
|
return prevSelectedItem_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item *Page::getSelectedItem(int offset)
|
Item *Page::getSelectedItem(int offset)
|
||||||
{
|
{
|
||||||
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return NULL;
|
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return NULL;
|
||||||
@ -367,6 +370,13 @@ Item *Page::getSelectedItem(int offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item *Page::getPreviousSelectedItem(int offset)
|
||||||
|
{
|
||||||
|
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return NULL;
|
||||||
|
return activeMenu_[0]->getPreviousItemByOffset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Page::removeSelectedItem()
|
void Page::removeSelectedItem()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1376,12 +1386,6 @@ void Page::updateScrollPeriod()
|
|||||||
void Page::scroll(bool forward)
|
void Page::scroll(bool forward)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Select next item
|
|
||||||
onNewScrollItemSelected();
|
|
||||||
|
|
||||||
// Set flag for notifying a new selected item after next update()
|
|
||||||
selectNextItemAfterScroll_ = true;
|
|
||||||
|
|
||||||
// Change scroll index
|
// Change scroll index
|
||||||
for(std::vector<ScrollingList *>::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++)
|
for(std::vector<ScrollingList *>::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++)
|
||||||
{
|
{
|
||||||
@ -1392,6 +1396,10 @@ void Page::scroll(bool forward)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify scroll item selected next item
|
||||||
|
onNewScrollItemSelected();
|
||||||
|
|
||||||
|
// Play sound
|
||||||
if(highlightSoundChunk_)
|
if(highlightSoundChunk_)
|
||||||
{
|
{
|
||||||
highlightSoundChunk_->play();
|
highlightSoundChunk_->play();
|
||||||
|
|||||||
@ -75,7 +75,9 @@ public:
|
|||||||
bool isHorizontalScroll();
|
bool isHorizontalScroll();
|
||||||
unsigned int getMenuDepth();
|
unsigned int getMenuDepth();
|
||||||
Item *getSelectedItem();
|
Item *getSelectedItem();
|
||||||
|
Item *getPrevSelectedItem_();
|
||||||
Item *getSelectedItem(int offset);
|
Item *getSelectedItem(int offset);
|
||||||
|
Item *getPreviousSelectedItem(int offset);
|
||||||
void removeSelectedItem();
|
void removeSelectedItem();
|
||||||
void setScrollOffsetIndex(unsigned int i);
|
void setScrollOffsetIndex(unsigned int i);
|
||||||
unsigned int getScrollOffsetIndex();
|
unsigned int getScrollOffsetIndex();
|
||||||
@ -145,9 +147,9 @@ private:
|
|||||||
|
|
||||||
bool scrollActive_;
|
bool scrollActive_;
|
||||||
bool scrollDirectionForward_;
|
bool scrollDirectionForward_;
|
||||||
bool selectNextItemAfterScroll_;
|
|
||||||
|
|
||||||
Item *selectedItem_;
|
Item *selectedItem_;
|
||||||
|
Item *prevSelectedItem_;
|
||||||
Text *textStatusComponent_;
|
Text *textStatusComponent_;
|
||||||
Sound *loadSoundChunk_;
|
Sound *loadSoundChunk_;
|
||||||
Sound *unloadSoundChunk_;
|
Sound *unloadSoundChunk_;
|
||||||
|
|||||||
@ -625,7 +625,7 @@ void RetroFE::run( )
|
|||||||
// Start onHighlightEnter animation
|
// Start onHighlightEnter animation
|
||||||
case RETROFE_HIGHLIGHT_LOAD_ART:
|
case RETROFE_HIGHLIGHT_LOAD_ART:
|
||||||
currentPage_->highlightEnter( );
|
currentPage_->highlightEnter( );
|
||||||
currentPage_->onNewScrollItemSelected( );
|
currentPage_->onNewItemSelected( );
|
||||||
state = RETROFE_HIGHLIGHT_ENTER;
|
state = RETROFE_HIGHLIGHT_ENTER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user