Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-center window under TTF, add "Video/Center window" menu item #5098

Merged
merged 4 commits into from
Jul 4, 2024
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
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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).
- Fixed update-version-number script to patch all *.iss files, not
just the specific one it did before, to ensure future releases have
correct version numbers. (joncampbell123).
Expand Down
3 changes: 3 additions & 0 deletions src/gui/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ static const char *def_menu_video[] =
#endif
"VideoRatioMenu",
"mapper_aspratio",
#if defined(C_SDL2)
"center_window",
#endif
#if !defined(C_SDL2) && defined(MACOSX)
"highdpienable",
#endif
Expand Down
14 changes: 14 additions & 0 deletions src/gui/menu_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,15 @@ 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
#if defined(C_SDL2)
SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
#endif
return true;
}

bool set_titletext_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) {
(void)menu;//UNUSED
(void)menuitem;//UNUSED
Expand Down Expand Up @@ -3198,6 +3207,11 @@ void AllocCallback1() {
set_callback_function(scaler_set_menu_callback);
}

#if defined(C_SDL2)
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"center_window").set_text("Center window").
set_callback_function(center_window_menu_callback);
#endif

mainMenu.alloc_item(DOSBoxMenu::item_type_id,"set_titletext").set_text("Set title bar text...").
set_callback_function(set_titletext_menu_callback);

Expand Down
1 change: 1 addition & 0 deletions src/output/output_ttf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,7 @@ void ttf_switch_on(bool ss=true) {
#ifdef C_SDL2
transparency = 0;
SetWindowTransparency(static_cast<Section_prop *>(control->GetSection("sdl"))->Get_int("transparency"));
SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
#endif
if (!IS_PC98_ARCH && vga.draw.address_add != ttf.cols * 2) checkcol = ss?2:1;
}
Expand Down
Loading