Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions workspace/all/common/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,18 @@ void PLAT_animateSurface(
int target_opacity,
int layer
);
#define ANIM_LINEAR 0
#define ANIM_EASE_OUT 1 // fast start, slows to stop
#define ANIM_EASE_IN 2 // slow start, fast exit
#define ANIM_EASE_IN_OUT 3 // slow start, fast middle, slow end

void PLAT_animateAndFadeSurface(
SDL_Surface *inputSurface,
int x, int y, int target_x, int target_y, int w, int h, int duration_ms,
SDL_Surface *fadeSurface,
int fade_x, int fade_y, int fade_w, int fade_h,
int start_opacity, int target_opacity, int layer
int fade_x, int fade_y, int fade_target_x, int fade_target_y, int fade_w, int fade_h,
int start_opacity, int target_opacity, int layer,
int input_easing, int fade_easing, int intensity
);

void PLAT_animateSurfaceOpacity(SDL_Surface *inputSurface, int x, int y, int w, int h,
Expand Down
10 changes: 6 additions & 4 deletions workspace/all/common/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void CFG_defaults(NextUISettings *cfg)
.raNotificationDuration = CFG_DEFAULT_RA_NOTIFICATION_DURATION,
.raProgressNotificationDuration = CFG_DEFAULT_RA_PROGRESS_NOTIFICATION_DURATION,
.raAchievementSortOrder = CFG_DEFAULT_RA_ACHIEVEMENT_SORT_ORDER,

};

*cfg = defaults;
Expand Down Expand Up @@ -187,7 +188,8 @@ void CFG_init(FontLoad_callback_t cb, ColorSet_callback_t ccb)
}
if (sscanf(line, "menutransitions=%i", &temp_value) == 1)
{
CFG_setMenuTransitions((bool)temp_value);
// Old bool values (0/1) map directly: 0=off, 1=snappy.
CFG_setMenuTransitions(temp_value);
continue;
}
if (sscanf(line, "recents=%i", &temp_value) == 1)
Expand Down Expand Up @@ -583,14 +585,14 @@ void CFG_setMenuAnimations(bool show)
CFG_sync();
}

bool CFG_getMenuTransitions(void)
int CFG_getMenuTransitions(void)
{
return settings.showMenuTransitions;
}

void CFG_setMenuTransitions(bool show)
void CFG_setMenuTransitions(int mode)
{
settings.showMenuTransitions = show;
settings.showMenuTransitions = mode;
CFG_sync();
}

Expand Down
23 changes: 17 additions & 6 deletions workspace/all/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef struct
bool clock24h;
bool showBatteryPercent;
bool showMenuAnimations;
bool showMenuTransitions;
int showMenuTransitions; // 0=off, 1=snappy, 2=comfy
bool showRecents;
bool showTools;
bool showCollections;
Expand All @@ -133,7 +133,7 @@ typedef struct

// Haptic
bool haptics;

// Networking
bool ntp;
int currentTimezone; // index of timezone in tz database
Expand Down Expand Up @@ -164,6 +164,11 @@ typedef struct

} NextUISettings;

// Transition mode constants
#define TRANSITION_OFF 0
#define TRANSITION_SNAPPY 1
#define TRANSITION_COMFY 2

#define CFG_DEFAULT_FONT_ID 1 // Next
#define CFG_DEFAULT_COLOR1 0xffffffU
#define CFG_DEFAULT_COLOR2 0x9b2257U
Expand All @@ -184,7 +189,7 @@ typedef struct
#define CFG_DEFAULT_CLOCK24H true
#define CFG_DEFAULT_SHOWBATTERYPERCENT false
#define CFG_DEFAULT_SHOWMENUANIMATIONS true
#define CFG_DEFAULT_SHOWMENUTRANSITIONS true
#define CFG_DEFAULT_SHOWMENUTRANSITIONS TRANSITION_SNAPPY
#define CFG_DEFAULT_SHOWRECENTS true
#define CFG_DEFAULT_SHOWCOLLECTIONS true
#define CFG_DEFAULT_SHOWGAMEART true
Expand Down Expand Up @@ -230,6 +235,12 @@ typedef struct
#define CFG_DEFAULT_RA_PROGRESS_NOTIFICATION_DURATION 1
#define CFG_DEFAULT_RA_ACHIEVEMENT_SORT_ORDER RA_SORT_UNLOCKED_FIRST

// Transition animation parameters (fixed per mode)
#define TRANSITION_SNAPPY_DURATION 150
#define TRANSITION_COMFY_DURATION 250
#define TRANSITION_CURVE 1 // ANIM_EASE_OUT
#define TRANSITION_INTENSITY 3

void CFG_init(FontLoad_callback_t fontCallback, ColorSet_callback_t ccb);
void CFG_print(void);
void CFG_get(const char *key, char * value);
Expand Down Expand Up @@ -267,9 +278,9 @@ void CFG_setShowBatteryPercent(bool show);
// Show/hide menu animations in main menu.
bool CFG_getMenuAnimations(void);
void CFG_setMenuAnimations(bool show);
// Show/hide menu transitions between screens in main menu.
bool CFG_getMenuTransitions(void);
void CFG_setMenuTransitions(bool show);
// Menu transition mode: TRANSITION_OFF, TRANSITION_SNAPPY, TRANSITION_COMFY.
int CFG_getMenuTransitions(void);
void CFG_setMenuTransitions(int mode);
// Set thumbnail rounding radius.
int CFG_getThumbnailRadius(void);
void CFG_setThumbnailRadius(int radius);
Expand Down
31 changes: 26 additions & 5 deletions workspace/all/common/generic_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdlib.h>
#include <pthread.h>
#include <stdint.h>
#include <math.h>

#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
Expand Down Expand Up @@ -1397,12 +1398,28 @@ SDL_Surface* PLAT_captureRendererToSurface() {
return surface;
}

static float anim_ease(float t, int easing, float intensity) {
switch (easing) {
case ANIM_EASE_OUT:
return 1.0f - powf(1.0f - t, intensity);
case ANIM_EASE_IN:
return powf(t, intensity);
case ANIM_EASE_IN_OUT:
return t < 0.5f
? 0.5f * powf(2.0f * t, intensity)
: 1.0f - 0.5f * powf(2.0f * (1.0f - t), intensity);
default:
return t;
}
}

void PLAT_animateAndFadeSurface(
SDL_Surface *inputSurface,
int x, int y, int target_x, int target_y, int w, int h, int duration_ms,
SDL_Surface *fadeSurface,
int fade_x, int fade_y, int fade_w, int fade_h,
int start_opacity, int target_opacity,int layer
int fade_x, int fade_y, int fade_target_x, int fade_target_y, int fade_w, int fade_h,
int start_opacity, int target_opacity, int layer,
int input_easing, int fade_easing, int intensity
) {
if (!inputSurface || !vid.renderer) return;

Expand Down Expand Up @@ -1438,9 +1455,11 @@ void PLAT_animateAndFadeSurface(
for (int frame = 0; frame <= total_frames; ++frame) {

float t = (float)frame / total_frames;
float t_input = anim_ease(t, input_easing, (float)intensity);
float t_fade = anim_ease(t, fade_easing, (float)intensity);

int current_x = x + (int)((target_x - x) * t);
int current_y = y + (int)((target_y - y) * t);
int current_x = x + (int)((target_x - x) * t_input);
int current_y = y + (int)((target_y - y) * t_input);

int current_opacity = start_opacity + (int)((target_opacity - start_opacity) * t);
if (current_opacity < 0) current_opacity = 0;
Expand Down Expand Up @@ -1476,7 +1495,9 @@ void PLAT_animateAndFadeSurface(

if (fadeTexture) {
SDL_SetTextureAlphaMod(fadeTexture, current_opacity);
SDL_Rect fadeDstRect = { fade_x, fade_y, fade_w, fade_h };
int fade_current_x = fade_x + (int)((fade_target_x - fade_x) * t_fade);
int fade_current_y = fade_y + (int)((fade_target_y - fade_y) * t_fade);
SDL_Rect fadeDstRect = { fade_current_x, fade_current_y, fade_w, fade_h };
SDL_RenderCopy(vid.renderer, fadeTexture, NULL, &fadeDstRect);
}

Expand Down
21 changes: 19 additions & 2 deletions workspace/all/nextui/nextui.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,12 +3137,29 @@ int main (int argc, char *argv[]) {
SDL_UnlockMutex(bgMutex);
folderbgchanged = 1;
GFX_clearLayers(LAYER_TRANSITION);
// Draw the selection pill at its target position before capturing the new
// screen, so the cursor is present in the incoming slide surface rather than
// blinking in after the transition animation ends.
if (currentScreen == SCREEN_GAMELIST && total > 0 && globalpill && list_show_entry_names) {
SDL_LockMutex(animMutex);
GFX_drawOnLayer(globalpill, SCALE1(BUTTON_MARGIN), (int)SCALE1(targetY + PADDING), globallpillW, globalpill->h, 1.0f, 0, LAYER_TRANSITION);
if (globalText) {
GFX_drawOnLayer(globalText, SCALE1(BUTTON_MARGIN + BUTTON_PADDING), pilltargetTextY, globalText->w, globalText->h, 1.0f, 0, LAYER_SCROLLTEXT);
}
SDL_UnlockMutex(animMutex);
}
GFX_flipHidden();
SDL_Surface *tmpNewScreen = GFX_captureRendererToSurface();
SDL_SetSurfaceBlendMode(tmpNewScreen,SDL_BLENDMODE_BLEND);
GFX_clearLayers(LAYER_SCROLLTEXT); // baked into tmpNewScreen; must clear or it floats above the animation
GFX_clearLayers(LAYER_THUMBNAIL);
if(animationdirection == SLIDE_LEFT) GFX_animateAndFadeSurface(tmpOldScreen,0,0,0-FIXED_WIDTH,0,FIXED_WIDTH,FIXED_HEIGHT,200,tmpNewScreen,1,0,FIXED_WIDTH,FIXED_HEIGHT,0,255,LAYER_THUMBNAIL);
if(animationdirection == SLIDE_RIGHT) GFX_animateAndFadeSurface(tmpOldScreen,0,0,0+FIXED_WIDTH,0,FIXED_WIDTH,FIXED_HEIGHT,200,tmpNewScreen,1,0,FIXED_WIDTH,FIXED_HEIGHT,0,255,LAYER_THUMBNAIL);
{
int _duration = (CFG_getMenuTransitions() == TRANSITION_COMFY)
? TRANSITION_COMFY_DURATION
: TRANSITION_SNAPPY_DURATION;
if(animationdirection == SLIDE_LEFT) GFX_animateAndFadeSurface(tmpOldScreen,0,0,-250,0,FIXED_WIDTH,FIXED_HEIGHT,_duration,tmpNewScreen,FIXED_WIDTH,0,0,0,FIXED_WIDTH,FIXED_HEIGHT,255,255,LAYER_THUMBNAIL,TRANSITION_CURVE,TRANSITION_CURVE,TRANSITION_INTENSITY);
if(animationdirection == SLIDE_RIGHT) GFX_animateAndFadeSurface(tmpNewScreen,-250,0,0,0,FIXED_WIDTH,FIXED_HEIGHT,_duration,tmpOldScreen,0,0,FIXED_WIDTH,0,FIXED_WIDTH,FIXED_HEIGHT,255,255,LAYER_THUMBNAIL,TRANSITION_CURVE,TRANSITION_CURVE,TRANSITION_INTENSITY);
}
GFX_clearLayers(LAYER_THUMBNAIL);
SDL_FreeSurface(tmpNewScreen);
}
Expand Down
Loading
Loading