Skip to content

Commit

Permalink
Merge pull request #5098 from aybe/video-fixes
Browse files Browse the repository at this point in the history
Fix off-center window under TTF, add "Video/Center window" menu item
  • Loading branch information
joncampbell123 committed Jul 4, 2024
2 parents f87cebb + 89643df commit b0a5616
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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

0 comments on commit b0a5616

Please sign in to comment.