From 8bb92abe8dd3ca26eacb6df989651649dcd9a2f8 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 4 Jul 2024 21:43:26 +0200 Subject: [PATCH] Add menu item "Video/Center window" Makes one's life much simpler now. --- CHANGELOG | 1 + src/gui/menu.cpp | 1 + src/gui/menu_callback.cpp | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 0ccad8f3ca..1a587ac607 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ NEXT - fix off-center and off-screen window after entering the configuration tool while using TTF output mode (aybe). + - add menu item for centering window "Video/Center window" (aybe). 2024.07.01 - Correct Hercules InColor memory emulation. Read and write planar behavior was incorrect due to a misunderstanding of available diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 1c4c6bf381..bb624729ba 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -525,6 +525,7 @@ static const char *def_menu_video[] = #endif "VideoRatioMenu", "mapper_aspratio", + "center_window", #if !defined(C_SDL2) && defined(MACOSX) "highdpienable", #endif diff --git a/src/gui/menu_callback.cpp b/src/gui/menu_callback.cpp index fb77cee1c3..baf9bfd6cd 100644 --- a/src/gui/menu_callback.cpp +++ b/src/gui/menu_callback.cpp @@ -2071,6 +2071,13 @@ bool vsync_set_syncrate_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * return true; } +bool center_window_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) { + (void)menu;//UNUSED + (void)menuitem;//UNUSED + SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + return true; +} + bool set_titletext_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) { (void)menu;//UNUSED (void)menuitem;//UNUSED @@ -3198,6 +3205,9 @@ void AllocCallback1() { set_callback_function(scaler_set_menu_callback); } + mainMenu.alloc_item(DOSBoxMenu::item_type_id,"center_window").set_text("Center window"). + set_callback_function(center_window_menu_callback); + mainMenu.alloc_item(DOSBoxMenu::item_type_id,"set_titletext").set_text("Set title bar text..."). set_callback_function(set_titletext_menu_callback);