From 71ca0fb270518aacbd95f785949d9c2efd2534b6 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Mon, 23 Oct 2023 23:14:24 -0700 Subject: [PATCH] Properly hide the status bar at startup Previously, the status bar was always shown at startup, even if the status bar had been previously disabled. This fixes the issue by hiding the status bar when it is first set up, if needed. --- src/wx/wxvbam.cpp | 14 ++++++++------ src/wx/wxvbam.h | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 63421882..59a3b801 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -846,7 +846,7 @@ MainFrame::MainFrame() #endif keep_on_top_styler_(this), status_bar_observer_(config::OptionID::kGenStatusBar, - std::bind(&MainFrame::OnStatusBarChanged, this, std::placeholders::_1)) { + std::bind(&MainFrame::OnStatusBarChanged, this)) { jpoll = new JoystickPoller(); this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll); } @@ -857,12 +857,14 @@ MainFrame::~MainFrame() { #endif } -void MainFrame::OnStatusBarChanged(config::Option* option) { - if (option->GetBool()) - GetStatusBar()->Show(); - else - GetStatusBar()->Hide(); +void MainFrame::SetStatusBar(wxStatusBar* menu_bar) { + wxFrame::SetStatusBar(menu_bar); + // This will take care of hiding the menu bar at startup, if needed. + menu_bar->Show(OPTION(kGenStatusBar)); +} +void MainFrame::OnStatusBarChanged() { + GetStatusBar()->Show(OPTION(kGenStatusBar)); SendSizeEvent(); panel->AdjustSize(false); SendSizeEvent(); diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 04e18c87..85ec2a05 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -362,11 +362,14 @@ private: const widgets::KeepOnTopStyler keep_on_top_styler_; const config::OptionsObserver status_bar_observer_; + // wxFrame override. + void SetStatusBar(wxStatusBar* menuBar) override; + // helper function for adding menu to accel editor void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu); // For enabling / disabling the status bar. - void OnStatusBarChanged(config::Option* option); + void OnStatusBarChanged(); // for detecting window focus void OnActivate(wxActivateEvent&); // may work, may not... if so, load dropped file