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.
This commit is contained in:
Fabrice de Gans 2023-10-23 23:14:24 -07:00 committed by Rafael Kitover
parent e19e13fa0a
commit 71ca0fb270
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 12 additions and 7 deletions

View File

@ -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();

View File

@ -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