Hide menubar + minor UI refactor.

Add ui/hideMenuBar boolean option, defaulting to on, which hides the
main menubar when the mouse is idle or outside the frame.

This is disabled on mac, because on macs the main menubar is not part of
the application window.

Fix pointer hiding/unhiding by connecting panel events to the gamearea
mouse event handler.

Clean up the pausing when menus are opened code, make it actually work
on Windows.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2020-04-27 21:02:02 +00:00
parent 2868c1b753
commit 504ca08b6b
11 changed files with 290 additions and 186 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-12 00:19+0000\n"
"POT-Creation-Date: 2020-04-27 20:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -155,7 +155,7 @@ msgstr ""
msgid "VBA cheat lists (*.clt)|*.clt|CHT cheat lists (*.cht)|*.cht"
msgstr ""
#: guiinit.cpp:256 panel.cpp:417
#: guiinit.cpp:256 panel.cpp:424
msgid "Loaded cheats"
msgstr ""
@ -308,40 +308,40 @@ msgstr ""
msgid "Menu accelerator %s for %s overrides default for %s ; keeping menu"
msgstr ""
#: guiinit.cpp:2998
#: guiinit.cpp:3006
#, c-format
msgid "Invalid menu item %s; removing"
msgstr ""
#: guiinit.cpp:3206
#: guiinit.cpp:3214
msgid "Code"
msgstr ""
#: guiinit.cpp:3215
#: guiinit.cpp:3223
msgid "Description"
msgstr ""
#: guiinit.cpp:3289 xrc/CheatAdd.xrc:31
#: guiinit.cpp:3297 xrc/CheatAdd.xrc:31
msgid "Address"
msgstr ""
#: guiinit.cpp:3290
#: guiinit.cpp:3298
msgid "Old Value"
msgstr ""
#: guiinit.cpp:3291
#: guiinit.cpp:3299
msgid "New Value"
msgstr ""
#: guiinit.cpp:3799
#: guiinit.cpp:3811
msgid "Menu commands"
msgstr ""
#: guiinit.cpp:3822
#: guiinit.cpp:3834
msgid "Other commands"
msgstr ""
#: guiinit.cpp:3933
#: guiinit.cpp:3945
msgid "JoyBus host invalid; disabling"
msgstr ""
@ -611,7 +611,7 @@ msgstr ""
msgid "Confirm import"
msgstr ""
#: cmdevents.cpp:907 panel.cpp:360
#: cmdevents.cpp:907 panel.cpp:367
#, c-format
msgid "Loaded battery %s"
msgstr ""
@ -694,7 +694,7 @@ msgstr ""
msgid "Wrote battery %s"
msgstr ""
#: cmdevents.cpp:1100 panel.cpp:666
#: cmdevents.cpp:1100 panel.cpp:673
#, c-format
msgid "Error writing battery %s"
msgstr ""
@ -790,32 +790,32 @@ msgstr ""
msgid "Waiting for GDB..."
msgstr ""
#: cmdevents.cpp:2618
#: cmdevents.cpp:2626
#, c-format
msgid "Using pixel filter #%d"
msgstr ""
#: cmdevents.cpp:2633
#: cmdevents.cpp:2641
#, c-format
msgid "Using interframe blending #%d"
msgstr ""
#: cmdevents.cpp:2672 panel.cpp:176 panel.cpp:277
#: cmdevents.cpp:2680 panel.cpp:181 panel.cpp:284
msgid "Could not initialize the sound driver!"
msgstr ""
#: cmdevents.cpp:2764
#: cmdevents.cpp:2772
msgid "Nintendo GameBoy (+Color+Advance) emulator."
msgstr ""
#: cmdevents.cpp:2765
#: cmdevents.cpp:2773
msgid ""
"Copyright (C) 1999-2003 Forgotten\n"
"Copyright (C) 2004-2006 VBA development team\n"
"Copyright (C) 2007-2017 VBA-M development team"
msgstr ""
#: cmdevents.cpp:2766
#: cmdevents.cpp:2774
msgid ""
"This program is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
@ -831,35 +831,35 @@ msgid ""
"along with this program. If not, see http://www.gnu.org/licenses ."
msgstr ""
#: cmdevents.cpp:3061
#: cmdevents.cpp:3069
msgid "LAN link is already active. Disable link mode to disconnect."
msgstr ""
#: cmdevents.cpp:3067
#: cmdevents.cpp:3075
msgid "Network is not supported in local mode."
msgstr ""
#: opts.cpp:555 opts.cpp:860
#: opts.cpp:560 opts.cpp:865
#, c-format
msgid "Invalid value %s for option %s; valid values are %s%s%s"
msgstr ""
#: opts.cpp:572 opts.cpp:872
#: opts.cpp:577 opts.cpp:877
#, c-format
msgid "Invalid value %d for option %s; valid values are %d - %d"
msgstr ""
#: opts.cpp:579 opts.cpp:588 opts.cpp:880 opts.cpp:888
#: opts.cpp:584 opts.cpp:593 opts.cpp:885 opts.cpp:893
#, c-format
msgid "Invalid value %f for option %s; valid values are %f - %f"
msgstr ""
#: opts.cpp:648 opts.cpp:669 opts.cpp:957 opts.cpp:983
#: opts.cpp:653 opts.cpp:674 opts.cpp:962 opts.cpp:988
#, c-format
msgid "Invalid key binding %s for %s"
msgstr ""
#: opts.cpp:843
#: opts.cpp:848
#, c-format
msgid "Invalid flag option %s - %s ignored"
msgstr ""
@ -939,155 +939,155 @@ msgstr ""
msgid "Error setting up server socket (%d)"
msgstr ""
#: panel.cpp:90
#: panel.cpp:95
#, c-format
msgid "%s is not a valid ROM file"
msgstr ""
#: panel.cpp:91 panel.cpp:152 panel.cpp:215
#: panel.cpp:96 panel.cpp:157 panel.cpp:222
msgid "Problem loading file"
msgstr ""
#: panel.cpp:151
#: panel.cpp:156
#, c-format
msgid "Unable to load Game Boy ROM %s"
msgstr ""
#: panel.cpp:191 panel.cpp:291
#: panel.cpp:198 panel.cpp:298
#, c-format
msgid "Could not load BIOS %s"
msgstr ""
#: panel.cpp:214
#: panel.cpp:221
#, c-format
msgid "Unable to load Game Boy Advance ROM %s"
msgstr ""
#: panel.cpp:449
#: panel.cpp:456
msgid " player "
msgstr ""
#: panel.cpp:614
#: panel.cpp:621
#, c-format
msgid "Loaded state %s"
msgstr ""
#: panel.cpp:614
#: panel.cpp:621
#, c-format
msgid "Error loading state %s"
msgstr ""
#: panel.cpp:638
#: panel.cpp:645
#, c-format
msgid "Saved state %s"
msgstr ""
#: panel.cpp:638
#: panel.cpp:645
#, c-format
msgid "Error saving state %s"
msgstr ""
#: panel.cpp:842
#: panel.cpp:849
#, c-format
msgid "Fullscreen mode %dx%d-%d@%d not supported; looking for another"
msgstr ""
#: panel.cpp:880
#: panel.cpp:887
#, c-format
msgid "Fullscreen mode %dx%d-%d@%d not supported"
msgstr ""
#: panel.cpp:885
#: panel.cpp:892
#, c-format
msgid "Valid mode: %dx%d-%d@%d"
msgstr ""
#: panel.cpp:893
#: panel.cpp:900
#, c-format
msgid "Chose mode %dx%d-%d@%d"
msgstr ""
#: panel.cpp:897
#: panel.cpp:904
#, c-format
msgid "Failed to change mode to %dx%d-%d@%d"
msgstr ""
#: panel.cpp:981
#: panel.cpp:988
msgid "Not a valid GBA cartridge"
msgstr ""
#: panel.cpp:1129
#: panel.cpp:1146
msgid "No memory for rewinding"
msgstr ""
#: panel.cpp:1139
#: panel.cpp:1156
msgid "Error writing rewind state"
msgstr ""
#: panel.cpp:2236
#: panel.cpp:2253
msgid "Failed to set glXSwapIntervalEXT"
msgstr ""
#: panel.cpp:2245
#: panel.cpp:2262
msgid "Failed to set glXSwapIntervalSGI"
msgstr ""
#: panel.cpp:2254
#: panel.cpp:2271
msgid "Failed to set glXSwapIntervalMESA"
msgstr ""
#: panel.cpp:2261
#: panel.cpp:2278
msgid "No support for wglGetExtensionsString"
msgstr ""
#: panel.cpp:2263
#: panel.cpp:2280
msgid "No support for WGL_EXT_swap_control"
msgstr ""
#: panel.cpp:2272
#: panel.cpp:2289
msgid "Failed to set wglSwapIntervalEXT"
msgstr ""
#: panel.cpp:2278
#: panel.cpp:2295
msgid "No VSYNC available on this platform"
msgstr ""
#: panel.cpp:2374
#: panel.cpp:2391
msgid "memory allocation error"
msgstr ""
#: panel.cpp:2377
#: panel.cpp:2394
msgid "error initializing codec"
msgstr ""
#: panel.cpp:2380
#: panel.cpp:2397
msgid "error writing to output file"
msgstr ""
#: panel.cpp:2383
#: panel.cpp:2400
msgid "can't guess output format from file name"
msgstr ""
#: panel.cpp:2388
#: panel.cpp:2405
msgid "programming error; aborting!"
msgstr ""
#: panel.cpp:2400 panel.cpp:2429
#: panel.cpp:2417 panel.cpp:2446
#, c-format
msgid "Unable to begin recording to %s (%s)"
msgstr ""
#: panel.cpp:2457
#: panel.cpp:2474
#, c-format
msgid "Error in audio/video recording (%s); aborting"
msgstr ""
#: panel.cpp:2463
#: panel.cpp:2480
#, c-format
msgid "Error in audio recording (%s); aborting"
msgstr ""
#: panel.cpp:2473
#: panel.cpp:2490
#, c-format
msgid "Error in video recording (%s); aborting"
msgstr ""
@ -3250,175 +3250,179 @@ msgstr ""
msgid "&Key Shortcuts ..."
msgstr ""
#: xrc/MainMenu.xrc:566
#: xrc/MainMenu.xrc:565
msgid "&UI Settings ..."
msgstr ""
#: xrc/MainMenu.xrc:569
msgid "&Tools"
msgstr ""
#: xrc/MainMenu.xrc:568
#: xrc/MainMenu.xrc:571
msgid "&Cheats"
msgstr ""
#: xrc/MainMenu.xrc:570
#: xrc/MainMenu.xrc:573
msgid "List &cheats ..."
msgstr ""
#: xrc/MainMenu.xrc:573
#: xrc/MainMenu.xrc:576
msgid "Find c&heat ..."
msgstr ""
#: xrc/MainMenu.xrc:577
#: xrc/MainMenu.xrc:580
msgid "A&utomatically save/load cheats"
msgstr ""
#: xrc/MainMenu.xrc:581
#: xrc/MainMenu.xrc:584
msgid "&Enable cheats"
msgstr ""
#: xrc/MainMenu.xrc:588
#: xrc/MainMenu.xrc:591
msgid "&Break into GDB"
msgstr ""
#: xrc/MainMenu.xrc:592
#: xrc/MainMenu.xrc:595
msgid "&Configure port..."
msgstr ""
#: xrc/MainMenu.xrc:595
#: xrc/MainMenu.xrc:598
msgid "&Break on load"
msgstr ""
#: xrc/MainMenu.xrc:600
#: xrc/MainMenu.xrc:603
msgid "&Disconnect"
msgstr ""
#: xrc/MainMenu.xrc:602
#: xrc/MainMenu.xrc:605
msgid "&GDB"
msgstr ""
#: xrc/MainMenu.xrc:605
#: xrc/MainMenu.xrc:608
msgid "&Disassemble..."
msgstr ""
#: xrc/MainMenu.xrc:608
#: xrc/MainMenu.xrc:611
msgid "&Logging..."
msgstr ""
#: xrc/MainMenu.xrc:611
#: xrc/MainMenu.xrc:614
msgid "&IO Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:614
#: xrc/MainMenu.xrc:617
msgid "&Map Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:617
#: xrc/MainMenu.xrc:620
msgid "M&emory Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:620
#: xrc/MainMenu.xrc:623
msgid "&OAM Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:623
#: xrc/MainMenu.xrc:626
msgid "&Palette Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:626
#: xrc/MainMenu.xrc:629
msgid "&Tile Viewer..."
msgstr ""
#: xrc/MainMenu.xrc:631
#: xrc/MainMenu.xrc:634
msgid "Show all video layers"
msgstr ""
#: xrc/MainMenu.xrc:635
#: xrc/MainMenu.xrc:638
msgid "BG &0"
msgstr ""
#: xrc/MainMenu.xrc:640
#: xrc/MainMenu.xrc:643
msgid "BG &1"
msgstr ""
#: xrc/MainMenu.xrc:645
#: xrc/MainMenu.xrc:648
msgid "BG &2"
msgstr ""
#: xrc/MainMenu.xrc:650
#: xrc/MainMenu.xrc:653
msgid "BG &3"
msgstr ""
#: xrc/MainMenu.xrc:655
#: xrc/MainMenu.xrc:658
msgid "&OBJ"
msgstr ""
#: xrc/MainMenu.xrc:660
#: xrc/MainMenu.xrc:663
msgid "&WIN 0"
msgstr ""
#: xrc/MainMenu.xrc:665
#: xrc/MainMenu.xrc:668
msgid "W&IN 1"
msgstr ""
#: xrc/MainMenu.xrc:670
#: xrc/MainMenu.xrc:673
msgid "O&BJ WIN"
msgstr ""
#: xrc/MainMenu.xrc:674
#: xrc/MainMenu.xrc:677
msgid "&View Layers"
msgstr ""
#: xrc/MainMenu.xrc:678
#: xrc/MainMenu.xrc:681
msgid "Channel &1"
msgstr ""
#: xrc/MainMenu.xrc:683
#: xrc/MainMenu.xrc:686
msgid "Channel &2"
msgstr ""
#: xrc/MainMenu.xrc:688
#: xrc/MainMenu.xrc:691
msgid "Channel &3"
msgstr ""
#: xrc/MainMenu.xrc:693
#: xrc/MainMenu.xrc:696
msgid "Channel &4"
msgstr ""
#: xrc/MainMenu.xrc:698
#: xrc/MainMenu.xrc:701
msgid "Direct Sound &A"
msgstr ""
#: xrc/MainMenu.xrc:703
#: xrc/MainMenu.xrc:706
msgid "Direct Sound &B"
msgstr ""
#: xrc/MainMenu.xrc:707
#: xrc/MainMenu.xrc:710
msgid "&Sound Channels"
msgstr ""
#: xrc/MainMenu.xrc:711
#: xrc/MainMenu.xrc:714
msgid "&Help"
msgstr ""
#: xrc/MainMenu.xrc:713
#: xrc/MainMenu.xrc:716
msgid "Report &Bugs"
msgstr ""
#: xrc/MainMenu.xrc:716
#: xrc/MainMenu.xrc:719
msgid "VBA-M Support &Forum"
msgstr ""
#: xrc/MainMenu.xrc:719
#: xrc/MainMenu.xrc:722
msgid "Translations"
msgstr ""
#: xrc/MainMenu.xrc:727
#: xrc/MainMenu.xrc:730
msgid "Check for updates"
msgstr ""
#: xrc/MainMenu.xrc:730
#: xrc/MainMenu.xrc:733
msgid "&Factory Reset..."
msgstr ""
#: xrc/MainMenu.xrc:734
#: xrc/MainMenu.xrc:737
msgid "&About..."
msgstr ""
@ -3701,3 +3705,11 @@ msgstr ""
#: xrc/SpeedupConfig.xrc:84
msgid "Frame skip"
msgstr ""
#: xrc/UIConfig.xrc:4
msgid "User Interface Settings"
msgstr ""
#: xrc/UIConfig.xrc:9
msgid "Hide Menu Bar"
msgstr ""

View File

@ -623,6 +623,7 @@ set(
xrc/SoundConfig.xrc
xrc/TileViewer.xrc
xrc/SpeedupConfig.xrc
xrc/UIConfig.xrc
)
# wxrc does not support xrs files in -c output (> 10x compression)

View File

@ -2326,6 +2326,14 @@ EVT_HANDLER(SpeedupConfigure, "Speedup / Turbo options...")
update_opts();
}
EVT_HANDLER(UIConfigure, "UI Settings...")
{
wxDialog* dlg = GetXRCDialog("UIConfig");
if (ShowModal(dlg) == wxID_OK)
update_opts();
}
EVT_HANDLER(GameBoyConfigure, "Game Boy options...")
{
wxDialog* dlg = GetXRCDialog("GameBoyConfig");

View File

@ -2907,15 +2907,23 @@ bool MainFrame::BindControls()
// remove this item from the menu completely
wxMenuItem* gdbmi = XRCITEM("GDBMenu");
gdbmi->GetMenu()->Remove(gdbmi);
gdbmi = NULL;
gdbmi = nullptr;
#endif
#ifdef NO_LINK
// remove this item from the menu completely
wxMenuItem* linkmi = XRCITEM("LinkMenu");
linkmi->GetMenu()->Remove(linkmi);
linkmi = NULL;
linkmi = nullptr;
#endif
#ifdef __WXMAC__
// Remove UI Config menu item, because it only has an option that does nothing on mac.
wxMenuItem* ui_config_mi = XRCITEM("UIConfigure");
ui_config_mi->GetMenu()->Remove(ui_config_mi);
ui_config_mi = nullptr;
#endif
// if a recent menu is present, save its location
wxMenuItem* recentmi = XRCITEM("RecentMenu");
@ -3425,6 +3433,10 @@ bool MainFrame::BindControls()
NULL, &speedup_throttle_ctrl);
d->Fit();
}
d = LoadXRCDialog("UIConfig");
{
getcbb("HideMenuBar", gopts.hide_menu_bar);
}
#define getcbbe(n, o) getbe(n, o, cb, wxCheckBox, CB)
wxBoolIntEnValidator* bienval;
(void)bienval; // not used yet

View File

@ -306,6 +306,9 @@ opt_desc opts[] = {
INTOPT("geometry/windowX", "X", wxTRANSLATE("Window axis X position at startup"), windowPositionX, -1, 99999),
INTOPT("geometry/windowY", "Y", wxTRANSLATE("Window axis Y position at startup"), windowPositionY, -1, 99999),
/// UI
BOOLOPT("ui/hideMenuBar", "", wxTRANSLATE("Hide menu bar when mouse is inactive"), gopts.hide_menu_bar),
/// Sound
ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|openal|directsound|xaudio2|faudio")),
STROPT("Sound/AudioDevice", "", wxTRANSLATE("Device ID of chosen audio device for chosen driver"), gopts.audio_dev),
@ -366,6 +369,8 @@ opts_t::opts_t()
link_host = "127.0.0.1";
server_ip = "*";
link_port = 5738;
hide_menu_bar = true;
}
// for binary_search() and friends

View File

@ -84,6 +84,9 @@ extern struct opts_t {
/// Recent
wxFileHistory* recent;
/// UI Config
bool hide_menu_bar;
/// wxWindows
// wxWidgets-generated options (opaque)
} gopts;

View File

@ -3,6 +3,7 @@
#include <cstring>
#include <vector>
#include <wx/dcbuffer.h>
#include <wx/menu.h>
#include <SDL_joystick.h>
#include "../common/version_cpp.h"
@ -16,6 +17,10 @@
#include "filters.h"
#include "wxvbam.h"
#ifdef __WXMSW__
#include <windows.h>
#endif
// release all buttons currently pressed
static void clear_input_press();
@ -925,7 +930,7 @@ GameArea::~GameArea()
void GameArea::OnKillFocus(wxFocusEvent& ev)
{
clear_input_press();
ev.Skip(true);
ev.Skip();
}
void GameArea::Pause()
@ -1038,9 +1043,16 @@ void GameArea::OnIdle(wxIdleEvent& event)
// the userdata is freed on disconnect/destruction
this->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this);
// we need to check if the buttons stayed pressed when focus the panel
// We need to check if the buttons stayed pressed when focus the panel.
w->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(GameArea::OnKillFocus), NULL, this);
// Update mouse last-used timers on mouse events etc..
w->Connect(wxEVT_MOTION, wxMouseEventHandler(GameArea::MouseEvent), NULL, this);
w->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(GameArea::MouseEvent), NULL, this);
w->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(GameArea::MouseEvent), NULL, this);
w->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(GameArea::MouseEvent), NULL, this);
w->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(GameArea::MouseEvent), NULL, this);
w->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
w->SetSize(wxSize(basic_width, basic_height));
@ -1095,6 +1107,7 @@ void GameArea::OnIdle(wxIdleEvent& event)
if (!paused) {
HidePointer();
HideMenuBar();
event.RequestMore();
#ifndef NO_DEBUGGER
@ -1123,6 +1136,8 @@ void GameArea::OnIdle(wxIdleEvent& event)
if (paused)
SetExtraStyle(GetExtraStyle() & ~wxWS_EX_PROCESS_IDLE);
ShowMenuBar();
}
if (do_rewind && emusys->emuWriteMemState) {
@ -1306,7 +1321,7 @@ void GameArea::OnKeyDown(wxKeyEvent& ev)
wxWakeUpIdle();
}
else {
ev.Skip(true);
ev.Skip();
}
}
@ -1318,7 +1333,7 @@ void GameArea::OnKeyUp(wxKeyEvent& ev)
wxWakeUpIdle();
}
else {
ev.Skip(true);
ev.Skip();
}
}
@ -1342,7 +1357,7 @@ void GameArea::OnSize(wxSizeEvent& ev)
if (panel)
panel->OnSize(ev);
ev.Skip(true);
ev.Skip();
}
#if defined(__WXGTK__) && defined(HAVE_XSS)
@ -2005,7 +2020,7 @@ void DrawingPanelBase::DrawOSD(wxWindowDC& dc)
void DrawingPanelBase::OnSize(wxSizeEvent& ev)
{
ev.Skip(true);
ev.Skip();
}
DrawingPanelBase::~DrawingPanelBase()
@ -2289,7 +2304,7 @@ void GLDrawingPanel::OnSize(wxSizeEvent& ev)
{
AdjustViewport();
ev.Skip(true);
ev.Skip();
}
void GLDrawingPanel::AdjustViewport()
@ -2482,17 +2497,22 @@ void GameArea::AddFrame(const uint8_t* data)
}
#endif
void GameArea::ShowPointer()
void GameArea::MouseEvent(wxMouseEvent& ev)
{
if (fullscreen)
return;
mouse_active_time = systemGetClock();
if (!pointer_blanked)
return;
ShowPointer();
ShowMenuBar();
ev.Skip();
}
void GameArea::ShowPointer()
{
if (!pointer_blanked || fullscreen) return;
pointer_blanked = false;
SetCursor(wxNullCursor);
if (panel)
@ -2501,12 +2521,11 @@ void GameArea::ShowPointer()
void GameArea::HidePointer()
{
if (pointer_blanked)
return;
if (pointer_blanked || !main_frame) return;
// FIXME: make time configurable
if ((fullscreen || (systemGetClock() - mouse_active_time) > 3000) &&
!(main_frame && (main_frame->MenusOpened() || main_frame->DialogOpened()))) {
!(main_frame->MenusOpened() || main_frame->DialogOpened())) {
pointer_blanked = true;
SetCursor(wxCursor(wxCURSOR_BLANK));
@ -2516,6 +2535,44 @@ void GameArea::HidePointer()
}
}
// We do not hide the menubar on mac, on mac it is not part of the main frame
// and the user can adjust hiding behavior herself.
void GameArea::HideMenuBar()
{
#ifndef __WXMAC__
if (!main_frame || menu_bar_hidden || !gopts.hide_menu_bar) return;
if (((systemGetClock() - mouse_active_time) > 3000) && !main_frame->MenusOpened()) {
#ifdef __WXMSW__
current_hmenu = static_cast<HMENU>(main_frame->GetMenuBar()->GetHMenu());
::SetMenu(main_frame->GetHandle(), nullptr);
#else
main_frame->GetMenuBar()->Hide();
#endif
SendSizeEvent();
menu_bar_hidden = true;
}
#endif
}
void GameArea::ShowMenuBar()
{
#ifndef __WXMAC__
if (!main_frame || !menu_bar_hidden) return;
#ifdef __WXMSW__
if (current_hmenu != nullptr) {
::SetMenu(main_frame->GetHandle(), current_hmenu);
current_hmenu = nullptr;
}
#else
main_frame->GetMenuBar()->Show();
#endif
SendSizeEvent();
menu_bar_hidden = false;
#endif
}
// stub HiDPI methods, see macsupport.mm for the Mac support
#ifndef __WXMAC__
double HiDPIAware::HiDPIScaleFactor()

View File

@ -755,20 +755,11 @@ EVT_DROP_FILES(MainFrame::OnDropFile)
// for window geometry
EVT_MOVE(MainFrame::OnMove)
EVT_SIZE(MainFrame::OnSize)
// pause game if menu pops up
//
// This is a feature most people don't like, and it causes problems with
// keyboard game keys on mac, so we will disable it for now.
//
// On Windows, there will still be a pause because of how the windows event
// model works, in addition the audio will loop with SDL, so we still pause on
// Windows, TODO: this needs to be fixed properly
//
#ifdef __WXMSW__
// For tracking menubar state.
EVT_MENU_OPEN(MainFrame::MenuPopped)
EVT_MENU_CLOSE(MainFrame::MenuPopped)
EVT_MENU_HIGHLIGHT_ALL(MainFrame::MenuPopped)
#endif
END_EVENT_TABLE()
@ -1069,65 +1060,43 @@ int MainFrame::newest_state_slot()
return ns + 1;
}
// disable emulator loop while menus are popped up
// not sure how to match up w/ down other than counting...
// only msw is guaranteed to only give one up & one down event for entire
// menu browsing
// if there is ever a mismatch, the game will freeze and there is no way
// to detect if it's doing that
// FIXME: this does not work.
// Not all open events are followed by close events.
// Removing the nesting counter may help, but on wxGTK I still get lockups.
void MainFrame::MenuPopped(wxMenuEvent& evt)
{
bool popped = evt.GetEventType() != wxEVT_MENU_CLOSE;
#if 0
if (popped)
++menus_opened;
else
--menus_opened;
if (menus_opened < 0) // how could this ever be???
menus_opened = 0;
#else
if (popped)
menus_opened = 1;
// We consider the menu closed when the main menubar or system menu is closed, not any submenus.
// On Windows nullptr is the system menu.
if (evt.GetEventType() == wxEVT_MENU_CLOSE && (evt.GetMenu() == nullptr || evt.GetMenu()->GetMenuBar() == GetMenuBar()))
SetMenusOpened(false);
else
menus_opened = 0;
SetMenusOpened(true);
#endif
// workaround for lack of wxGTK mouse motion events: unblank
// pointer when menu popped up
// of course this does not help in finding the menus in the first place
// the user is better off clicking in the window or entering/
// exiting the window (which does generate a mouse event)
// it will auto-hide again once game resumes
if (popped)
panel->ShowPointer();
//if (menus_opened)
// panel->Pause();
//else if (!IsPaused())
// panel->Resume();
evt.Skip();
}
// Pause game if menu pops up.
//
// This is a feature most people don't like, and it causes problems with
// keyboard game keys on mac, so we will disable it for now.
//
// On Windows, there will still be a pause because of how the windows event
// model works, in addition the audio will loop with SDL, so we still pause on
// Windows.
//
// TODO: This needs to be fixed properly.
//
void MainFrame::SetMenusOpened(bool state)
{
if (state) {
menus_opened = 1;
if ((menus_opened = state)) {
#ifdef __WXMSW__
paused = true;
panel->Pause();
#endif
}
else {
menus_opened = 0;
#ifdef __WXMSW__
paused = false;
pause_next = false;
panel->Resume();
#endif
}
}

View File

@ -305,7 +305,7 @@ public:
// call this to update the viewers once a frame:
void UpdateViewers();
virtual bool MenusOpened() { return menus_opened != 0; }
virtual bool MenusOpened() { return menus_opened; }
virtual void SetMenusOpened(bool state);
@ -315,7 +315,7 @@ public:
bool IsPaused(bool incendental = false)
{
return (paused && !pause_next && !incendental) || menus_opened || dialog_opened;
return (paused && !pause_next && !incendental) || dialog_opened;
}
void PollJoysticks() { joy.Poll(); }
@ -331,9 +331,8 @@ protected:
private:
GameArea* panel;
// the various reasons the game might be paused
bool paused;
int menus_opened, dialog_opened;
bool paused, menus_opened;
int dialog_opened;
bool autoLoadMostRecent;
// copy of top-level menu bar as a context menu
@ -474,6 +473,11 @@ enum audioapi { AUD_SDL,
class DrawingPanelBase;
#ifdef __WXMSW__
// For saving menu handle.
#include <windows.h>
#endif
class GameArea : public wxPanel, public HiDPIAware {
public:
GameArea();
@ -628,14 +632,16 @@ protected:
public:
void ShowPointer();
void HidePointer();
void HideMenuBar();
void ShowMenuBar();
protected:
void MouseEvent(wxMouseEvent&)
{
ShowPointer();
}
bool pointer_blanked;
void MouseEvent(wxMouseEvent&);
bool pointer_blanked, menu_bar_hidden = false;
uint32_t mouse_active_time;
#ifdef __WXMSW__
HMENU current_hmenu = nullptr;
#endif
DECLARE_DYNAMIC_CLASS(GameArea)
DECLARE_EVENT_TABLE()

View File

@ -561,6 +561,9 @@
<object class="wxMenuItem" name="Customize">
<label>_Key Shortcuts ...</label>
</object>
<object class="wxMenuItem" name="UIConfigure">
<label>_UI Settings ...</label>
</object>
</object>
<object class="wxMenu">
<label>_Tools</label>

28
src/wx/xrc/UIConfig.xrc Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
<object class="wxDialog" name="UIConfig">
<title>User Interface Settings</title>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxCheckBox" name="HideMenuBar">
<label>Hide Menu Bar</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxStdDialogButtonSizer">
<object class="button">
<object class="wxButton" name="wxID_OK"/>
</object>
<object class="button">
<object class="wxButton" name="wxID_CANCEL"/>
</object>
</object>
</object>
</object>
</object>
</resource>