correct menu flicker at the end of scrolling

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2019-11-18 14:08:07 +08:00
parent b8324b2bb7
commit b95b326352

View File

@ -3,6 +3,9 @@
#include "../SDL.h"
/// -------------- DEFINES --------------
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
//#define MENU_DEBUG
#define MENU_ERROR
@ -847,19 +850,19 @@ void MenuMode::launch( )
}
/// --------- Handle Scroll effect ---------
if (scroll>0){
scroll+=SCROLL_SPEED_PX;
screen_refresh = 1;
}
if (scroll<0){
scroll-=SCROLL_SPEED_PX;
screen_refresh = 1;
}
if (scroll>MENU_ZONE_HEIGHT || scroll<-MENU_ZONE_HEIGHT) {
if (scroll>=MENU_ZONE_HEIGHT || scroll<=-MENU_ZONE_HEIGHT) {
prevItem=menuItem;
scroll=0;
screen_refresh = 1;
}
else if (scroll>0){
scroll+=MIN(SCROLL_SPEED_PX, MENU_ZONE_HEIGHT-scroll);
screen_refresh = 1;
}
else if (scroll<0){
scroll-=MIN(SCROLL_SPEED_PX, MENU_ZONE_HEIGHT+scroll);
screen_refresh = 1;
}
/// --------- Handle FPS ---------
cur_ms = SDL_GetTicks();