(Windows Frontend) Allow screen resizing in horizontal display layout.

The right hand screen is allowed to be resized in horizontal screen layout to enable the window or full screen display to better utilize the screen area.

Changes:
1- Modify scaling, resizing and update functions to allow for new screen resizing ratio
2- Modify touch input scaling (incl. HUD editing) to adapt to different screen sizes
3- Add GUI menu for user to select the screen resizing ratio
4- Implement saving/loading settings from file similar to other settings
This commit is contained in:
retr0s4ge 2018-07-09 01:03:35 +02:00
parent 66062bca80
commit 5ad5e16a40
3 changed files with 100 additions and 15 deletions

View File

@ -519,6 +519,8 @@ bool continuousframeAdvancing = false;
unsigned short windowSize = 0; unsigned short windowSize = 0;
float screenSizeRatio = 1.0f;
/*const u32 gapColors[16] = { /*const u32 gapColors[16] = {
Color::Gray, Color::Gray,
Color::Brown, Color::Brown,
@ -714,7 +716,10 @@ void ScaleScreen(float factor, bool user)
MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor)); MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor));
else else
if (video.layout == 1) if (video.layout == 1)
MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2), (int)(video.rotatedheightgap() * factor / 2)); {
factor /= screenSizeRatio;
MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2), (int)(video.rotatedheightgap() * factor * screenSizeRatio / 2));
}
else else
if (video.layout == 2) if (video.layout == 2)
MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor / 2)); MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor / 2));
@ -869,21 +874,49 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen)
bool topOnTop = (video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst); bool topOnTop = (video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst);
bool bottom = (whichScreen > 0); bool bottom = (whichScreen > 0);
if (topOnTop) if (topOnTop)
x += bottom ? -GPU_FRAMEBUFFER_NATIVE_WIDTH : 0; {
else if (bottom)
x += (x < GPU_FRAMEBUFFER_NATIVE_WIDTH) ? (bottom ? 0 : GPU_FRAMEBUFFER_NATIVE_WIDTH) : (bottom ? 0 : -GPU_FRAMEBUFFER_NATIVE_WIDTH); {
x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio;
x /= (2 - screenSizeRatio);
y /= (2 - screenSizeRatio);
}
} }
else else
{ {
if (x < GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio)
{
if (bottom == 0)
x += GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio;
}
else
{
if (bottom == 0)
x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio;
}
x /= screenSizeRatio;
}
}
else
{
x /= screenSizeRatio;
if(x >= GPU_FRAMEBUFFER_NATIVE_WIDTH) if(x >= GPU_FRAMEBUFFER_NATIVE_WIDTH)
{ {
x -= GPU_FRAMEBUFFER_NATIVE_WIDTH; x -= GPU_FRAMEBUFFER_NATIVE_WIDTH;
y += GPU_FRAMEBUFFER_NATIVE_HEIGHT; x *= screenSizeRatio / (2 - screenSizeRatio);
y += GPU_FRAMEBUFFER_NATIVE_HEIGHT * (2 - screenSizeRatio);
y /= (2 - screenSizeRatio);
if (y < GPU_FRAMEBUFFER_NATIVE_HEIGHT)
y = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
} }
else if(x < 0) else if(x < 0)
{ {
x += GPU_FRAMEBUFFER_NATIVE_WIDTH; x = 0;
y -= GPU_FRAMEBUFFER_NATIVE_HEIGHT; }
else
{
if (y > GPU_FRAMEBUFFER_NATIVE_HEIGHT)
y = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
} }
} }
} }
@ -1161,7 +1194,7 @@ void UpdateWndRects(HWND hwnd)
if (video.layout == 1) //horizontal if (video.layout == 1) //horizontal
{ {
rc = CalculateDisplayLayoutWrapper(rc, GPU_FRAMEBUFFER_NATIVE_WIDTH * 2, GPU_FRAMEBUFFER_NATIVE_HEIGHT, tbheight, maximized); rc = CalculateDisplayLayoutWrapper(rc, GPU_FRAMEBUFFER_NATIVE_WIDTH * 2, (int)((float)(GPU_FRAMEBUFFER_NATIVE_HEIGHT * screenSizeRatio)), tbheight, maximized);
wndWidth = (rc.bottom - rc.top) - tbheight; wndWidth = (rc.bottom - rc.top) - tbheight;
wndHeight = (rc.right - rc.left); wndHeight = (rc.right - rc.left);
@ -1176,20 +1209,20 @@ void UpdateWndRects(HWND hwnd)
ClientToScreen(hwnd, &ptClient); ClientToScreen(hwnd, &ptClient);
MainScreenRect.left = ptClient.x; MainScreenRect.left = ptClient.x;
MainScreenRect.top = ptClient.y; MainScreenRect.top = ptClient.y;
ptClient.x = (rc.left + oneScreenHeight); ptClient.x = (rc.left + oneScreenHeight * screenSizeRatio);
ptClient.y = (rc.top + wndWidth); ptClient.y = (rc.top + wndWidth);
ClientToScreen(hwnd, &ptClient); ClientToScreen(hwnd, &ptClient);
MainScreenRect.right = ptClient.x; MainScreenRect.right = ptClient.x;
MainScreenRect.bottom = ptClient.y; MainScreenRect.bottom = ptClient.y;
// Sub screen // Sub screen
ptClient.x = (rc.left + oneScreenHeight); ptClient.x = (rc.left + oneScreenHeight * screenSizeRatio);
ptClient.y = rc.top; ptClient.y = rc.top;
ClientToScreen(hwnd, &ptClient); ClientToScreen(hwnd, &ptClient);
SubScreenRect.left = ptClient.x; SubScreenRect.left = ptClient.x;
SubScreenRect.top = ptClient.y; SubScreenRect.top = ptClient.y;
ptClient.x = (rc.left + oneScreenHeight + oneScreenHeight); ptClient.x = (rc.left + oneScreenHeight * 2);
ptClient.y = (rc.top + wndWidth); ptClient.y = (rc.top + wndWidth * (2 - screenSizeRatio));
ClientToScreen(hwnd, &ptClient); ClientToScreen(hwnd, &ptClient);
SubScreenRect.right = ptClient.x; SubScreenRect.right = ptClient.x;
SubScreenRect.bottom = ptClient.y; SubScreenRect.bottom = ptClient.y;
@ -3008,6 +3041,7 @@ int _main()
msgbox = &msgBoxWnd; msgbox = &msgBoxWnd;
char text[80] = {0}; char text[80] = {0};
char scrRatStr[4] = "1.0";
path.ReadPathSettings(); path.ReadPathSettings();
@ -3071,6 +3105,8 @@ int _main()
GetPrivateProfileString("MicSettings", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName); GetPrivateProfileString("MicSettings", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName);
RefreshMicSettings(); RefreshMicSettings();
GetPrivateProfileString("Display", "Screen Size Ratio", "1.0", scrRatStr, 4, IniName);
screenSizeRatio = atof(scrRatStr);
video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName);
SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName); SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName);
ScreenGapColor = GetPrivateProfileInt("Display", "ScreenGapColor", 0xFFFFFF, IniName); ScreenGapColor = GetPrivateProfileInt("Display", "ScreenGapColor", 0xFFFFFF, IniName);
@ -4629,6 +4665,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
MainWindow->checkMenu(IDM_ALWAYS_ON_TOP, (GetStyle()&DWS_ALWAYSONTOP)!=0); MainWindow->checkMenu(IDM_ALWAYS_ON_TOP, (GetStyle()&DWS_ALWAYSONTOP)!=0);
MainWindow->checkMenu(IDM_LOCKDOWN, (GetStyle()&DWS_LOCKDOWN)!=0); MainWindow->checkMenu(IDM_LOCKDOWN, (GetStyle()&DWS_LOCKDOWN)!=0);
//Screen Size Ratio
MainWindow->checkMenu(IDC_SCR_RATIO_1p0, ((int)(screenSizeRatio*10)==10));
MainWindow->checkMenu(IDC_SCR_RATIO_1p1, ((int)(screenSizeRatio*10)==11));
MainWindow->checkMenu(IDC_SCR_RATIO_1p2, ((int)(screenSizeRatio*10)==12));
MainWindow->checkMenu(IDC_SCR_RATIO_1p3, ((int)(screenSizeRatio*10)==13));
MainWindow->checkMenu(IDC_SCR_RATIO_1p4, ((int)(screenSizeRatio*10)==14));
MainWindow->checkMenu(IDC_SCR_RATIO_1p5, ((int)(screenSizeRatio*10)==15));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p0, (video.layout == 1));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p1, (video.layout == 1));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p2, (video.layout == 1));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p3, (video.layout == 1));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p4, (video.layout == 1));
DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p5, (video.layout == 1));
//Screen Separation //Screen Separation
MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone))); MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone)));
MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==kGapBorder))); MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==kGapBorder)));
@ -4920,7 +4970,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
else if (video.layout == 1) else if (video.layout == 1)
{ {
minX = video.rotatedwidthgap() * 2; minX = video.rotatedwidthgap() * 2;
minY = video.rotatedheightgap() / 2; minY = video.rotatedheightgap() * screenSizeRatio / 2;
} }
else if (video.layout == 2) else if (video.layout == 2)
{ {
@ -6278,6 +6328,26 @@ DOKEYDOWN:
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
break; break;
case IDC_SCR_RATIO_1p0:
case IDC_SCR_RATIO_1p1:
case IDC_SCR_RATIO_1p2:
case IDC_SCR_RATIO_1p3:
case IDC_SCR_RATIO_1p4:
case IDC_SCR_RATIO_1p5:
{
screenSizeRatio = LOWORD(wParam) - IDC_SCR_RATIO_1p0;
screenSizeRatio = screenSizeRatio * 0.1 + 1;
RECT rc;
GetClientRect(hwnd, &rc);
MainWindow->setClientSize((int)((rc.right - rc.left + 8) / screenSizeRatio), rc.bottom - rc.top);
char scrRatStr[4] = "1.0";
sprintf(scrRatStr, "%.1f", screenSizeRatio);
WritePrivateProfileString("Display", "Screen Size Ratio", scrRatStr, IniName);
}
return 0;
case IDC_VIEW_PADTOINTEGER: case IDC_VIEW_PADTOINTEGER:
PadToInteger = (!PadToInteger)?TRUE:FALSE; PadToInteger = (!PadToInteger)?TRUE:FALSE;
WritePrivateProfileInt("Video","Window Pad To Integer",PadToInteger,IniName); WritePrivateProfileInt("Video","Window Pad To Integer",PadToInteger,IniName);

View File

@ -958,6 +958,12 @@
#define IDM_RENDER_3XBRZ 40123 #define IDM_RENDER_3XBRZ 40123
#define IDM_RENDER_4XBRZ 40124 #define IDM_RENDER_4XBRZ 40124
#define IDM_RENDER_5XBRZ 40125 #define IDM_RENDER_5XBRZ 40125
#define IDC_SCR_RATIO_1p0 40143
#define IDC_SCR_RATIO_1p1 40144
#define IDC_SCR_RATIO_1p2 40145
#define IDC_SCR_RATIO_1p3 40146
#define IDC_SCR_RATIO_1p4 40147
#define IDC_SCR_RATIO_1p5 40148
#define ID_LABEL_HK3b 44670 #define ID_LABEL_HK3b 44670
#define ID_LABEL_HK3c 44671 #define ID_LABEL_HK3c 44671
#define ID_LABEL_HK3d 44672 #define ID_LABEL_HK3d 44672
@ -1072,7 +1078,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1 #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 128 #define _APS_NEXT_RESOURCE_VALUE 128
#define _APS_NEXT_COMMAND_VALUE 40126 #define _APS_NEXT_COMMAND_VALUE 40149
#define _APS_NEXT_CONTROL_VALUE 1065 #define _APS_NEXT_CONTROL_VALUE 1065
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif

View File

@ -1609,6 +1609,15 @@ BEGIN
MENUITEM "&Always On Top", IDM_ALWAYS_ON_TOP MENUITEM "&Always On Top", IDM_ALWAYS_ON_TOP
MENUITEM "&Lockdown", IDM_LOCKDOWN MENUITEM "&Lockdown", IDM_LOCKDOWN
END END
POPUP "Screen Size Ratio (L:R)"
BEGIN
MENUITEM "1.0 : 1.0", IDC_SCR_RATIO_1p0
MENUITEM "1.1 : 0.9", IDC_SCR_RATIO_1p1
MENUITEM "1.2 : 0.8", IDC_SCR_RATIO_1p2
MENUITEM "1.3 : 0.7", IDC_SCR_RATIO_1p3
MENUITEM "1.4 : 0.6", IDC_SCR_RATIO_1p4
MENUITEM "1.5 : 0.5", IDC_SCR_RATIO_1p5
END
POPUP "Screen &Gap" POPUP "Screen &Gap"
BEGIN BEGIN
MENUITEM "&None\t(0 px)", IDM_SCREENSEP_NONE MENUITEM "&None\t(0 px)", IDM_SCREENSEP_NONE