Skip to content

Commit

Permalink
Fixed Auto-Crop assigned to custom control
Browse files Browse the repository at this point in the history
- The event is now a toggle ON/OFF
- Ensure the aspect ratio is fixed if we turn auto-crop off through the input event
  • Loading branch information
midwan committed Mar 27, 2022
1 parent e1ad09b commit 7eb4d3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/inputdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4774,7 +4774,8 @@ static bool inputdevice_handle_inputcode2(int monid, int code, int state, const
break;
#endif
case AKS_AUTO_CROP_IMAGE:
auto_crop_image();
currprefs.gfx_auto_crop = !currprefs.gfx_auto_crop;
check_prefs_changed_gfx();
break;
}
end:
Expand Down
2 changes: 1 addition & 1 deletion src/inputevents.def
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ DEFEVENT(SPC_SHUTDOWN, _T("Shutdown System"),AM_K,0,0,AKS_SHUTDOWN)
DEFEVENT(SPC_TOGGLE_JIT, _T("Toggle JIT"),AM_K,0,0,AKS_TOGGLE_JIT)
DEFEVENT(SPC_TOGGLE_JIT_FPU, _T("Toggle JIT FPU"),AM_K,0,0,AKS_TOGGLE_JIT_FPU)

DEFEVENT(SPC_AUTO_CROP_IMAGE, _T("Auto crop image"),AM_K,0,0,AKS_AUTO_CROP_IMAGE)
DEFEVENT(SPC_AUTO_CROP_IMAGE, _T("Toggle Auto Crop"),AM_K,0,0,AKS_AUTO_CROP_IMAGE)

#endif

Expand Down
28 changes: 27 additions & 1 deletion src/osdep/amiberry_gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ extern int get_visible_left_border();
void auto_crop_image()
{
static bool last_autocrop;
static int width, height;
if (currprefs.gfx_auto_crop)
{
static int last_vstrt, last_vstop, last_hstrt, last_hstop;
Expand Down Expand Up @@ -971,7 +972,6 @@ void auto_crop_image()
#else
crop_rect = { x, y, new_width, new_height };

int width, height;
if (changed_prefs.gfx_correct_aspect == 0)
{
width = sdl_mode.w;
Expand Down Expand Up @@ -1000,6 +1000,32 @@ void auto_crop_image()
#ifdef USE_DISPMANX
#else
crop_rect = { 0, 0, sdl_surface->w, sdl_surface->h };

if (last_autocrop != currprefs.gfx_auto_crop)
{
// Restore Aspect ratio corrections if auto-crop was turned off
if (changed_prefs.gfx_correct_aspect == 0)
{
width = sdl_mode.w;
height = sdl_mode.h;
}
else
{
width = display_width * 2 >> currprefs.gfx_resolution;
height = display_height * 2 >> currprefs.gfx_vresolution;
}
if (amiberry_options.rotation_angle == 0 || amiberry_options.rotation_angle == 180)
{
SDL_RenderSetLogicalSize(sdl_renderer, width, height);
renderQuad = { dx, dy, width, height };
}
else
{
SDL_RenderSetLogicalSize(sdl_renderer, height, width);
renderQuad = { -(width - height) / 2, (width - height) / 2, width, height };
}
}

#endif
}

Expand Down

0 comments on commit 7eb4d3d

Please sign in to comment.