[option] Convert all uses of geometry options to use config::Option
Moving and resizing the window no longer updates the entire option set, reducing jank on move and resize.
This commit is contained in:
parent
d2d070b52f
commit
0ca5184dda
|
@ -247,8 +247,8 @@ int vsync;
|
||||||
int wasPaused = 0;
|
int wasPaused = 0;
|
||||||
uint32_t windowHeight;
|
uint32_t windowHeight;
|
||||||
int windowMaximized;
|
int windowMaximized;
|
||||||
int windowPositionX, bkpPosX = 0;
|
int windowPositionX = 0;
|
||||||
int windowPositionY, bkpPosY = 0;
|
int windowPositionY = 0;
|
||||||
uint32_t windowWidth;
|
uint32_t windowWidth;
|
||||||
int winGbBorderOn;
|
int winGbBorderOn;
|
||||||
int winGbPrinterEnabled;
|
int winGbPrinterEnabled;
|
||||||
|
|
|
@ -137,8 +137,8 @@ extern int vsync;
|
||||||
extern int wasPaused;
|
extern int wasPaused;
|
||||||
extern uint32_t windowHeight;
|
extern uint32_t windowHeight;
|
||||||
extern int windowMaximized;
|
extern int windowMaximized;
|
||||||
extern int windowPositionX, bkpPosX;
|
extern int windowPositionX;
|
||||||
extern int windowPositionY, bkpPosY;
|
extern int windowPositionY;
|
||||||
extern uint32_t windowWidth;
|
extern uint32_t windowWidth;
|
||||||
extern int winGbBorderOn;
|
extern int winGbBorderOn;
|
||||||
extern int winGbPrinterEnabled;
|
extern int winGbPrinterEnabled;
|
||||||
|
|
|
@ -46,6 +46,32 @@ void MainFrame::GetMenuOptionBool(const wxString& menuName, bool* field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainFrame::GetMenuOptionConfig(const wxString& menu_name,
|
||||||
|
const config::OptionID& option_id) {
|
||||||
|
config::Option* option = config::Option::ByID(option_id);
|
||||||
|
assert(option);
|
||||||
|
|
||||||
|
int id = wxXmlResource::GetXRCID(menu_name);
|
||||||
|
for (size_t i = 0; i < checkable_mi.size(); i++) {
|
||||||
|
if (checkable_mi[i].cmd != id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const bool is_checked = checkable_mi[i].mi->IsChecked();
|
||||||
|
switch (option->type()) {
|
||||||
|
case config::Option::Type::kBool:
|
||||||
|
option->SetBool(is_checked);
|
||||||
|
break;
|
||||||
|
case config::Option::Type::kInt:
|
||||||
|
option->SetInt(is_checked);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
|
void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
|
||||||
{
|
{
|
||||||
assert(field);
|
assert(field);
|
||||||
|
@ -2714,36 +2740,22 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
|
||||||
|
|
||||||
EVT_HANDLER_MASK(DisplayConfigure, "Display options...", CMDEN_NREC_ANY)
|
EVT_HANDLER_MASK(DisplayConfigure, "Display options...", CMDEN_NREC_ANY)
|
||||||
{
|
{
|
||||||
bool fs = fullScreen;
|
|
||||||
wxVideoMode dm = gopts.fs_mode;
|
|
||||||
|
|
||||||
if (gopts.max_threads != 1) {
|
if (gopts.max_threads != 1) {
|
||||||
gopts.max_threads = wxThread::GetCPUCount();
|
gopts.max_threads = wxThread::GetCPUCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Just in case GetCPUCount() returns 0
|
// Just in case GetCPUCount() returns 0 or -1
|
||||||
if (!gopts.max_threads)
|
if (gopts.max_threads < 0) {
|
||||||
gopts.max_threads = 1;
|
gopts.max_threads = 1;
|
||||||
|
|
||||||
wxDialog* dlg = GetXRCDialog("DisplayConfig");
|
|
||||||
|
|
||||||
if (ShowModal(dlg) != wxID_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (frameSkip >= 0)
|
|
||||||
systemFrameSkip = frameSkip;
|
|
||||||
|
|
||||||
if (fs != fullScreen) {
|
|
||||||
panel->ShowFullScreen(fullScreen);
|
|
||||||
} else if (panel->IsFullScreen() && dm != gopts.fs_mode) {
|
|
||||||
// maybe not the best way to do this..
|
|
||||||
panel->ShowFullScreen(false);
|
|
||||||
panel->ShowFullScreen(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel->panel) {
|
wxDialog* dlg = GetXRCDialog("DisplayConfig");
|
||||||
panel->panel->Destroy();
|
if (ShowModal(dlg) != wxID_OK) {
|
||||||
panel->panel = nullptr;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameSkip >= 0) {
|
||||||
|
systemFrameSkip = frameSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_opts();
|
update_opts();
|
||||||
|
@ -3125,8 +3137,7 @@ EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.")
|
||||||
|
|
||||||
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
|
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("Fullscreen", &fullScreen, 1);
|
GetMenuOptionConfig("Fullscreen", config::OptionID::kgeometryfullScreen);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
|
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
|
||||||
|
|
|
@ -359,7 +359,7 @@ bool Option::SetInt(int32_t value) {
|
||||||
|
|
||||||
bool Option::SetUnsigned(uint32_t value) {
|
bool Option::SetUnsigned(uint32_t value) {
|
||||||
assert(is_unsigned());
|
assert(is_unsigned());
|
||||||
uint32_t old_value = value;
|
uint32_t old_value = GetUnsigned();
|
||||||
if (value < nonstd::get<uint32_t>(min_) ||
|
if (value < nonstd::get<uint32_t>(min_) ||
|
||||||
value > nonstd::get<uint32_t>(max_)) {
|
value > nonstd::get<uint32_t>(max_)) {
|
||||||
wxLogWarning(
|
wxLogWarning(
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/xrc/xmlres.h>
|
#include <wx/xrc/xmlres.h>
|
||||||
|
|
||||||
#include "../../System.h"
|
|
||||||
#include "../../common/ConfigManager.h"
|
|
||||||
#include "config/option.h"
|
#include "config/option.h"
|
||||||
#include "rpi.h"
|
#include "rpi.h"
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
|
|
@ -391,8 +391,9 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
emusys = &GBASystem;
|
emusys = &GBASystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullScreen)
|
if (config::Option::ByID(config::OptionID::kgeometryfullScreen)->GetInt()) {
|
||||||
GameArea::ShowFullScreen(true);
|
GameArea::ShowFullScreen(true);
|
||||||
|
}
|
||||||
|
|
||||||
loaded = t;
|
loaded = t;
|
||||||
SetFrameTitle();
|
SetFrameTitle();
|
||||||
|
|
|
@ -471,13 +471,17 @@ bool wxvbamApp::OnInit() {
|
||||||
config::GameControlState::Instance().OnGameBindingsChanged();
|
config::GameControlState::Instance().OnGameBindingsChanged();
|
||||||
|
|
||||||
// create the main window
|
// create the main window
|
||||||
int x = windowPositionX;
|
int x = config::Option::ByID(config::OptionID::kgeometrywindowX)->GetInt();
|
||||||
int y = windowPositionY;
|
int y = config::Option::ByID(config::OptionID::kgeometrywindowY)->GetInt();
|
||||||
int width = windowWidth;
|
int width = config::Option::ByID(config::OptionID::kgeometrywindowWidth)
|
||||||
int height = windowHeight;
|
->GetUnsigned();
|
||||||
int isFullscreen = fullScreen;
|
int height = config::Option::ByID(config::OptionID::kgeometrywindowHeight)
|
||||||
int isMaximized = windowMaximized;
|
->GetUnsigned();
|
||||||
frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame);
|
bool isFullscreen =
|
||||||
|
config::Option::ByID(config::OptionID::kgeometryfullScreen)->GetInt();
|
||||||
|
bool isMaximized =
|
||||||
|
config::Option::ByID(config::OptionID::kgeometryisMaximized)->GetInt();
|
||||||
|
frame = wxDynamicCast(xr->LoadFrame(nullptr, "MainFrame"), MainFrame);
|
||||||
|
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
wxLogError(_("Could not create main window"));
|
wxLogError(_("Could not create main window"));
|
||||||
|
@ -835,59 +839,46 @@ void MainFrame::OnMenu(wxContextMenuEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnMove(wxMoveEvent& event)
|
void MainFrame::OnMove(wxMoveEvent&) {
|
||||||
{
|
wxPoint window_pos = GetScreenPosition();
|
||||||
(void)event; // unused params
|
|
||||||
wxPoint pos = GetScreenPosition();
|
if (!IsFullScreen() && !IsMaximized()) {
|
||||||
int x = pos.x, y = pos.y;
|
if (window_pos.x >= 0 && window_pos.y >= 0) {
|
||||||
if (!IsFullScreen() && !IsMaximized())
|
config::Option::ByID(config::OptionID::kgeometrywindowX)
|
||||||
{
|
->SetInt(window_pos.x);
|
||||||
if (x >= 0 && y >= 0)
|
config::Option::ByID(config::OptionID::kgeometrywindowY)
|
||||||
{
|
->SetInt(window_pos.y);
|
||||||
bkpPosX = windowPositionX;
|
|
||||||
bkpPosY = windowPositionY;
|
|
||||||
windowPositionX = x;
|
|
||||||
windowPositionY = y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
windowPositionX = bkpPosX;
|
|
||||||
windowPositionY = bkpPosY;
|
|
||||||
}
|
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnSize(wxSizeEvent& event)
|
void MainFrame::OnSize(wxSizeEvent& event)
|
||||||
{
|
{
|
||||||
wxFrame::OnSize(event);
|
wxFrame::OnSize(event);
|
||||||
wxRect pos = GetRect();
|
wxRect window_rect = GetRect();
|
||||||
wxPoint windowPos = GetScreenPosition();
|
wxPoint window_pos = GetScreenPosition();
|
||||||
int height = pos.GetHeight(), width = pos.GetWidth();
|
config::Option* window_x =
|
||||||
int x = windowPos.x, y = windowPos.y;
|
config::Option::ByID(config::OptionID::kgeometrywindowX);
|
||||||
bool isFullscreen = IsFullScreen();
|
config::Option* window_y =
|
||||||
bool isMaximized = IsMaximized();
|
config::Option::ByID(config::OptionID::kgeometrywindowY);
|
||||||
if (!isFullscreen && !isMaximized)
|
|
||||||
{
|
if (!IsFullScreen() && !IsMaximized()) {
|
||||||
if (height > 0 && width > 0)
|
if (window_rect.GetHeight() > 0 && window_rect.GetWidth() > 0) {
|
||||||
{
|
config::Option::ByID(config::OptionID::kgeometrywindowHeight)
|
||||||
windowHeight = height;
|
->SetUnsigned(window_rect.GetHeight());
|
||||||
windowWidth = width;
|
config::Option::ByID(config::OptionID::kgeometrywindowWidth)
|
||||||
|
->SetUnsigned(window_rect.GetWidth());
|
||||||
}
|
}
|
||||||
if (x >= 0 && y >= 0)
|
if (window_pos.x >= 0 && window_pos.y >= 0) {
|
||||||
{
|
window_x->SetInt(window_pos.x);
|
||||||
windowPositionX = x;
|
window_y->SetInt(window_pos.y);
|
||||||
windowPositionY = y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
config::Option::ByID(config::OptionID::kgeometryisMaximized)
|
||||||
windowPositionX = bkpPosX;
|
->SetInt(IsMaximized());
|
||||||
windowPositionY = bkpPosY;
|
config::Option::ByID(config::OptionID::kgeometryfullScreen)
|
||||||
}
|
->SetInt(IsFullScreen());
|
||||||
windowMaximized = isMaximized;
|
|
||||||
fullScreen = isFullscreen;
|
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainFrame::FilterEvent(wxEvent& event)
|
int MainFrame::FilterEvent(wxEvent& event)
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
#include "wx/wxmisc.h"
|
#include "wx/wxmisc.h"
|
||||||
#include "wxhead.h"
|
#include "wxhead.h"
|
||||||
|
|
||||||
/* yeah, they aren't needed globally, but I'm too lazy to limit where needed */
|
|
||||||
#include "../common/ConfigManager.h"
|
|
||||||
|
|
||||||
#include "../System.h"
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../gb/gb.h"
|
#include "../gb/gb.h"
|
||||||
#include "../gb/gbCheats.h"
|
#include "../gb/gbCheats.h"
|
||||||
#include "../gb/gbGlobals.h"
|
#include "../gb/gbGlobals.h"
|
||||||
|
@ -223,6 +218,8 @@ public:
|
||||||
void MenuOptionIntMask(const wxString& menuName, int field, int mask);
|
void MenuOptionIntMask(const wxString& menuName, int field, int mask);
|
||||||
void MenuOptionIntRadioValue(const wxString& menuName, int field, int mask);
|
void MenuOptionIntRadioValue(const wxString& menuName, int field, int mask);
|
||||||
void MenuOptionBool(const wxString& menuName, bool field);
|
void MenuOptionBool(const wxString& menuName, bool field);
|
||||||
|
void GetMenuOptionConfig(const wxString& menu_name,
|
||||||
|
const config::OptionID& option_id);
|
||||||
void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
|
void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
|
||||||
void GetMenuOptionBool(const wxString& menuName, bool* field);
|
void GetMenuOptionBool(const wxString& menuName, bool* field);
|
||||||
void SetMenuOption(const wxString& menuName, int value);
|
void SetMenuOption(const wxString& menuName, int value);
|
||||||
|
|
Loading…
Reference in New Issue