Improved the main window size specifying, now has an option to lock the window to the specified size, making it unresizable.

This commit is contained in:
OBattler
2021-04-12 05:58:59 +02:00
parent 2c12f47bd7
commit 58a1939dbf
7 changed files with 132 additions and 49 deletions

View File

@@ -450,7 +450,9 @@ load_general(void)
char temp[512]; char temp[512];
char *p; char *p;
vid_resize = !!config_get_int(cat, "vid_resize", 0); vid_resize = config_get_int(cat, "vid_resize", 0);
if (vid_resize & ~3)
vid_resize &= 3;
memset(temp, '\0', sizeof(temp)); memset(temp, '\0', sizeof(temp));
p = config_get_string(cat, "vid_renderer", "default"); p = config_get_string(cat, "vid_renderer", "default");
@@ -488,6 +490,25 @@ load_general(void)
window_w = window_h = window_x = window_y = 0; window_w = window_h = window_x = window_y = 0;
} }
if (vid_resize & 2) {
p = config_get_string(cat, "window_fixed_res", NULL);
if (p == NULL)
p = "120x120";
sscanf(p, "%ix%i", &fixed_size_x, &fixed_size_y);
if (fixed_size_x < 120)
fixed_size_x = 120;
if (fixed_size_x > 2048)
fixed_size_x = 2048;
if (fixed_size_y < 120)
fixed_size_y = 120;
if (fixed_size_y > 2048)
fixed_size_y = 2048;
} else {
config_delete_var(cat, "window_fixed_res");
fixed_size_x = fixed_size_y = 120;
}
sound_gain = config_get_int(cat, "sound_gain", 0); sound_gain = config_get_int(cat, "sound_gain", 0);
confirm_reset = config_get_int(cat, "confirm_reset", 1); confirm_reset = config_get_int(cat, "confirm_reset", 1);
@@ -1720,6 +1741,7 @@ config_load(void)
fpu_type = fpu_get_type(cpu_f, cpu, "none"); fpu_type = fpu_get_type(cpu_f, cpu, "none");
gfxcard = video_get_video_from_internal_name("cga"); gfxcard = video_get_video_from_internal_name("cga");
vid_api = plat_vidapi("default"); vid_api = plat_vidapi("default");
vid_resize = 0;
time_sync = TIME_SYNC_ENABLED; time_sync = TIME_SYNC_ENABLED;
hdc_current = hdc_get_from_internal_name("none"); hdc_current = hdc_get_from_internal_name("none");
serial_enabled[0] = 1; serial_enabled[0] = 1;
@@ -1857,6 +1879,12 @@ save_general(void)
config_delete_var(cat, "window_coordinates"); config_delete_var(cat, "window_coordinates");
} }
if (vid_resize & 2) {
sprintf(temp, "%ix%i", fixed_size_x, fixed_size_y);
config_set_string(cat, "window_fixed_res", temp);
} else
config_delete_var(cat, "window_fixed_res");
if (sound_gain != 0) if (sound_gain != 0)
config_set_int(cat, "sound_gain", sound_gain); config_set_int(cat, "sound_gain", sound_gain);
else else

View File

@@ -120,6 +120,7 @@ extern int enable_crashdump; /* (C) enable crash dump */
extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out, extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out,
how to remove that hack from the ET4000/W32p. */ how to remove that hack from the ET4000/W32p. */
extern int fixed_size_x, fixed_size_y;
#ifdef ENABLE_LOG_TOGGLES #ifdef ENABLE_LOG_TOGGLES

View File

@@ -281,6 +281,7 @@
#define IDC_WIDTHSPIN 1401 #define IDC_WIDTHSPIN 1401
#define IDC_EDIT_HEIGHT 1402 #define IDC_EDIT_HEIGHT 1402
#define IDC_HEIGHTSPIN 1403 #define IDC_HEIGHTSPIN 1403
#define IDC_CHECK_LOCK_SIZE 1404
#define IDM_ABOUT 40001 #define IDM_ABOUT 40001
#define IDC_ABOUT_ICON 65535 #define IDC_ABOUT_ICON 65535

View File

@@ -343,7 +343,7 @@ BEGIN
#endif #endif
END END
DLG_SPECIFY_DIM DIALOG DISCARDABLE 0, 0, 175, 47 DLG_SPECIFY_DIM DIALOG DISCARDABLE 0, 0, 175, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Specify Main Window Dimensions" CAPTION "Specify Main Window Dimensions"
FONT 9, "Segoe UI" FONT 9, "Segoe UI"
@@ -358,8 +358,10 @@ BEGIN
CONTROL "",IDC_HEIGHTSPIN,"msctls_updown32",UDS_SETBUDDYINT | CONTROL "",IDC_HEIGHTSPIN,"msctls_updown32",UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,166,6, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,166,6,
12,12 12,12
DEFPUSHBUTTON "OK",IDOK,30,26,50,14 CONTROL "Lock to this size",IDC_CHECK_LOCK_SIZE,"Button",
PUSHBUTTON "Cancel",IDCANCEL,99,26,50,14 BS_AUTOCHECKBOX | WS_TABSTOP,7,26,94,10
DEFPUSHBUTTON "OK",IDOK,30,45,50,14
PUSHBUTTON "Cancel",IDCANCEL,99,45,50,14
END END
DLG_CFG_MACHINE DIALOG DISCARDABLE 107, 0, 305, 200 DLG_CFG_MACHINE DIALOG DISCARDABLE 107, 0, 305, 200
@@ -1038,7 +1040,7 @@ BEGIN
IDS_2123 "Save" IDS_2123 "Save"
IDS_2124 "About 86Box" IDS_2124 "About 86Box"
IDS_2125 "86Box v" EMU_VERSION IDS_2125 "86Box v" EMU_VERSION
IDS_2126 "An emulator of old computers\n\nAuthors: Miran Grca (OBattler), Sarah Walker, Fred N. van Kempen (waltje), SA1988, MoochMcGee, reenigne, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2. See LICENSE for more information." IDS_2126 "An emulator of old computers\n\nAuthors: Sarah Walker, Miran Grca, Fred N. van Kempen (waltje), SA1988, MoochMcGee, reenigne, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2. See LICENSE for more information."
IDS_2127 "OK" IDS_2127 "OK"
IDS_2128 "Hardware not available" IDS_2128 "Hardware not available"
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -1032,7 +1032,7 @@ plat_setfullscreen(int on)
plat_resize(scrnsz_x, scrnsz_y); plat_resize(scrnsz_x, scrnsz_y);
if (vid_resize) { if (vid_resize) {
/* scale the screen base on DPI */ /* scale the screen base on DPI */
if (window_remember) { if (!(vid_resize & 2) && window_remember) {
MoveWindow(hwndMain, window_x, window_y, window_w, window_h, TRUE); MoveWindow(hwndMain, window_x, window_y, window_w, window_h, TRUE);
GetClientRect(hwndMain, &rect); GetClientRect(hwndMain, &rect);
@@ -1040,11 +1040,11 @@ plat_setfullscreen(int on)
temp_y = rect.bottom - rect.top + 1 - sbar_height; temp_y = rect.bottom - rect.top + 1 - sbar_height;
} else { } else {
if (dpi_scale) { if (dpi_scale) {
temp_x = MulDiv(unscaled_size_x, dpi, 96); temp_x = MulDiv((vid_resize & 2) ? fixed_size_x : unscaled_size_x, dpi, 96);
temp_y = MulDiv(unscaled_size_y, dpi, 96); temp_y = MulDiv((vid_resize & 2) ? fixed_size_y : unscaled_size_y, dpi, 96);
} else { } else {
temp_x = unscaled_size_x; temp_x = (vid_resize & 2) ? fixed_size_x : unscaled_size_x;
temp_y = unscaled_size_y; temp_y = (vid_resize & 2) ? fixed_size_y : unscaled_size_y;
} }
/* Main Window. */ /* Main Window. */
@@ -1061,8 +1061,8 @@ plat_setfullscreen(int on)
if (mouse_capture) if (mouse_capture)
ClipCursor(&rect); ClipCursor(&rect);
scrnsz_x = unscaled_size_x; scrnsz_x = (vid_resize & 2) ? fixed_size_x : unscaled_size_x;
scrnsz_y = unscaled_size_y; scrnsz_y = (vid_resize & 2) ? fixed_size_y : unscaled_size_y;
} }
} }
video_fullscreen &= 1; video_fullscreen &= 1;

View File

@@ -44,7 +44,7 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
UDACCEL accel, accel2; UDACCEL accel, accel2;
RECT r; RECT r;
uint32_t temp_x = 0, temp_y = 0; uint32_t temp_x = 0, temp_y = 0;
int dpi = 96; int dpi = 96, lock;
LPTSTR lptsTemp; LPTSTR lptsTemp;
char *stransi; char *stransi;
@@ -69,6 +69,9 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
accel2.nInc = 8; accel2.nInc = 8;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel2); SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel2);
SendMessage(h, UDM_SETPOS, 0, r.bottom - r.top); SendMessage(h, UDM_SETPOS, 0, r.bottom - r.top);
h = GetDlgItem(hdlg, IDC_CHECK_LOCK_SIZE);
SendMessage(h, BM_SETCHECK, !!(vid_resize & 2), 0);
break; break;
case WM_COMMAND: case WM_COMMAND:
@@ -81,18 +84,33 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp); SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, 512); wcstombs(stransi, lptsTemp, 512);
sscanf(stransi, "%u", &temp_x); sscanf(stransi, "%u", &temp_x);
fixed_size_x = temp_x;
h = GetDlgItem(hdlg, IDC_EDIT_HEIGHT); h = GetDlgItem(hdlg, IDC_EDIT_HEIGHT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp); SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, 512); wcstombs(stransi, lptsTemp, 512);
sscanf(stransi, "%u", &temp_y); sscanf(stransi, "%u", &temp_y);
fixed_size_y = temp_y;
window_remember = 1; h = GetDlgItem(hdlg, IDC_CHECK_LOCK_SIZE);
lock = SendMessage(h, BM_GETCHECK, 0, 0);
if (lock) {
vid_resize = 2;
window_remember = 0;
} else {
vid_resize = 1; vid_resize = 1;
window_remember = 1;
}
hmenu = GetMenu(hwndMain); hmenu = GetMenu(hwndMain);
CheckMenuItem(hmenu, IDM_VID_RESIZE, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_REMEMBER, (window_remember == 1) ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize == 1) ? MF_CHECKED : MF_UNCHECKED);
EnableMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize & 2) ? MF_GRAYED : MF_ENABLED);
if (vid_resize == 1)
SetWindowLongPtr(hwndMain, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE); SetWindowLongPtr(hwndMain, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE);
else
SetWindowLongPtr(hwndMain, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX) | WS_VISIBLE);
/* scale the screen base on DPI */ /* scale the screen base on DPI */
if (dpi_scale) { if (dpi_scale) {
@@ -106,27 +124,31 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height);
if (mouse_capture) if (vid_resize) {
ClipCursor(&r);
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED);
scale = 1; scale = 1;
EnableMenuItem(hmenu, IDM_VID_SCALE_1X, MF_GRAYED); }
EnableMenuItem(hmenu, IDM_VID_SCALE_2X, MF_GRAYED); EnableMenuItem(hmenu, IDM_VID_SCALE_1X, vid_resize ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(hmenu, IDM_VID_SCALE_3X, MF_GRAYED); EnableMenuItem(hmenu, IDM_VID_SCALE_2X, vid_resize ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(hmenu, IDM_VID_SCALE_4X, MF_GRAYED); EnableMenuItem(hmenu, IDM_VID_SCALE_3X, vid_resize ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(hmenu, IDM_VID_SCALE_4X, vid_resize ? MF_GRAYED : MF_ENABLED);
scrnsz_x = temp_x; scrnsz_x = fixed_size_x;
scrnsz_y = temp_y; scrnsz_y = fixed_size_y;
doresize = 1; doresize = 1;
CheckMenuItem(hmenu, IDM_VID_REMEMBER, MF_CHECKED);
GetWindowRect(hwndMain, &r); GetWindowRect(hwndMain, &r);
if (mouse_capture)
ClipCursor(&r);
if (!(vid_resize & 2) && window_remember) {
window_x = r.left; window_x = r.left;
window_y = r.top; window_y = r.top;
window_w = r.right - r.left; window_w = r.right - r.left;
window_h = r.bottom - r.top; window_h = r.bottom - r.top;
}
config_save(); config_save();

View File

@@ -66,6 +66,7 @@ int minimized = 0;
int infocus = 1, button_down = 0; int infocus = 1, button_down = 0;
int rctrl_is_lalt = 0; int rctrl_is_lalt = 0;
int user_resize = 0; int user_resize = 0;
int fixed_size_x = 0, fixed_size_y = 0;
extern char openfilestring[512]; extern char openfilestring[512];
extern WCHAR wopenfilestring[512]; extern WCHAR wopenfilestring[512];
@@ -125,7 +126,7 @@ int win_get_system_metrics(int index, int dpi) {
void void
ResizeWindowByClientArea(HWND hwnd, int width, int height) ResizeWindowByClientArea(HWND hwnd, int width, int height)
{ {
if (vid_resize || padded_frame) { if ((vid_resize == 1) || padded_frame) {
int padding = win_get_system_metrics(SM_CXPADDEDBORDER, dpi); int padding = win_get_system_metrics(SM_CXPADDEDBORDER, dpi);
width += (win_get_system_metrics(SM_CXFRAME, dpi) + padding) * 2; width += (win_get_system_metrics(SM_CXFRAME, dpi) + padding) * 2;
height += (win_get_system_metrics(SM_CYFRAME, dpi) + padding) * 2; height += (win_get_system_metrics(SM_CYFRAME, dpi) + padding) * 2;
@@ -279,7 +280,7 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED);
if (vid_resize) if (vid_resize == 1)
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_SW+vid_api, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_SW+vid_api, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
@@ -300,6 +301,20 @@ ResetAllMenus(void)
#ifdef MTR_ENABLED #ifdef MTR_ENABLED
EnableMenuItem(menuMain, IDM_ACTION_END_TRACE, MF_DISABLED); EnableMenuItem(menuMain, IDM_ACTION_END_TRACE, MF_DISABLED);
#endif #endif
if (vid_resize) {
if (vid_resize >= 2) {
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED);
EnableMenuItem(menuMain, IDM_VID_RESIZE, MF_GRAYED);
}
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + scale, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_2X, MF_CHECKED);
EnableMenuItem(menuMain, IDM_VID_SCALE_1X, MF_GRAYED);
EnableMenuItem(menuMain, IDM_VID_SCALE_2X, MF_GRAYED);
EnableMenuItem(menuMain, IDM_VID_SCALE_3X, MF_GRAYED);
EnableMenuItem(menuMain, IDM_VID_SCALE_4X, MF_GRAYED);
}
} }
@@ -599,10 +614,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case IDM_VID_RESIZE: case IDM_VID_RESIZE:
vid_resize = !vid_resize; vid_resize ^= 1;
CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize & 1) ? MF_CHECKED : MF_UNCHECKED);
if (vid_resize) if (vid_resize == 1)
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE); SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE);
else else
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX) | WS_VISIBLE); SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX) | WS_VISIBLE);
@@ -642,7 +657,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
window_remember = !window_remember; window_remember = !window_remember;
CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
GetWindowRect(hwnd, &rect); GetWindowRect(hwnd, &rect);
if (window_remember) { if (!(vid_resize & 2) && window_remember) {
window_x = rect.left; window_x = rect.left;
window_y = rect.top; window_y = rect.top;
window_w = rect.right - rect.left; window_w = rect.right - rect.left;
@@ -837,9 +852,19 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
GetWindowRect(hwndSBAR, &rect); GetWindowRect(hwndSBAR, &rect);
sbar_height = rect.bottom - rect.top; sbar_height = rect.bottom - rect.top;
rect_p = (RECT*)lParam; rect_p = (RECT*)lParam;
if (vid_resize) if (vid_resize == 1)
MoveWindow(hwnd, rect_p->left, rect_p->top, rect_p->right - rect_p->left, rect_p->bottom - rect_p->top, TRUE); MoveWindow(hwnd, rect_p->left, rect_p->top, rect_p->right - rect_p->left, rect_p->bottom - rect_p->top, TRUE);
else if (!user_resize) else if (vid_resize >= 2) {
temp_x = fixed_size_x;
temp_y = fixed_size_y;
if (dpi_scale) {
temp_x = MulDiv(temp_x, dpi, 96);
temp_y = MulDiv(temp_y, dpi, 96);
}
/* Main Window. */
ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height);
} else if (!user_resize)
doresize = 1; doresize = 1;
break; break;
@@ -1243,7 +1268,7 @@ ui_init(int nCmdShow)
sbar_height = sbar_rect.bottom - sbar_rect.top; sbar_height = sbar_rect.bottom - sbar_rect.top;
/* Set up main window for resizing if configured. */ /* Set up main window for resizing if configured. */
if (vid_resize) if (vid_resize == 1)
SetWindowLongPtr(hwnd, GWL_STYLE, SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_OVERLAPPEDWINDOW)); (WS_OVERLAPPEDWINDOW));
else else
@@ -1256,10 +1281,15 @@ ui_init(int nCmdShow)
/* Initiate a resize in order to properly arrange all controls. /* Initiate a resize in order to properly arrange all controls.
Move to the last-saved position if needed. */ Move to the last-saved position if needed. */
if (window_remember) if ((vid_resize < 2) && window_remember)
MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE); MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE);
else else {
if (vid_resize >= 2) {
scrnsz_x = fixed_size_x;
scrnsz_y = fixed_size_y;
}
ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height); ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height);
}
/* Reset all menus to their defaults. */ /* Reset all menus to their defaults. */
ResetAllMenus(); ResetAllMenus();
@@ -1479,7 +1509,6 @@ plat_resize(int x, int y)
{ {
/* First, see if we should resize the UI window. */ /* First, see if we should resize the UI window. */
if (!vid_resize) { if (!vid_resize) {
/* scale the screen base on DPI */ /* scale the screen base on DPI */
if (dpi_scale) { if (dpi_scale) {
x = MulDiv(x, dpi, 96); x = MulDiv(x, dpi, 96);