From 2c0c85e4427d98d64913c5e5ff499984e66c8f09 Mon Sep 17 00:00:00 2001 From: apoorv569 Date: Tue, 18 May 2021 18:49:02 +0530 Subject: [PATCH] Fixing the frame opening with extremely small window size. --- src/MainFrame.cpp | 24 +++++++++++------------- src/MainFrame.hpp | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/MainFrame.cpp b/src/MainFrame.cpp index c2d00cc..42daa79 100644 --- a/src/MainFrame.cpp +++ b/src/MainFrame.cpp @@ -36,14 +36,8 @@ MainFrame::MainFrame() : wxFrame(NULL, wxID_ANY, "Sample Hive", wxDefaultPosition), m_ConfigFilepath("config.yaml"), m_DatabaseFilepath("sample.hive") { - int height = 600, width = 800; - // Load default yaml config file. - LoadConfigFile(height, width); - - this->SetSize(width, height); - this->CenterOnScreen(wxBOTH); - this->SetIcon(wxIcon("../assets/icons/icon-hive_24x24.png", wxICON_DEFAULT_TYPE, -1, -1)); + LoadConfigFile(); // Initializing BoxSizers m_MainSizer = new wxBoxSizer(wxVERTICAL); @@ -282,9 +276,8 @@ MainFrame::MainFrame() // Sizer for the frame this->SetSizer(m_MainSizer); - m_MainSizer->Fit(this); - m_MainSizer->SetSizeHints(this); - m_MainSizer->Layout(); + this->Layout(); + this->Center(wxBOTH); // Sizer for the main panel m_MainPanel->SetSizer(m_TopSizer); @@ -1186,8 +1179,10 @@ void MainFrame::OnCancelSearch(wxCommandEvent& event) m_SearchBox->Clear(); } -void MainFrame::LoadConfigFile(int& height, int& width) +void MainFrame::LoadConfigFile() { + int height = 600, width = 800; + Settings settings(m_ConfigFilepath, m_DatabaseFilepath); Serializer serialize(m_ConfigFilepath); @@ -1198,13 +1193,16 @@ void MainFrame::LoadConfigFile(int& height, int& width) serialize.DeserializeBrowserControls("loop", bLoop); serialize.DeserializeBrowserControls("muted", bMuted); - serialize.DeserializeWinSize("Height", height); - serialize.DeserializeWinSize("Width", width); + height = serialize.DeserializeWinSize("Height", height); + width = serialize.DeserializeWinSize("Width", width); settings.GetFontType().SetFaceName(font_face); settings.GetFontType().SetPointSize(font_size); this->SetFont(settings.GetFontType()); + this->SetSize(width, height); + this->CenterOnScreen(wxBOTH); + this->SetIcon(wxIcon("../assets/icons/icon-hive_24x24.png", wxICON_DEFAULT_TYPE, -1, -1)); } void MainFrame::RefreshDatabase() diff --git a/src/MainFrame.hpp b/src/MainFrame.hpp index a7d96a7..29fd6bd 100644 --- a/src/MainFrame.hpp +++ b/src/MainFrame.hpp @@ -189,7 +189,7 @@ class MainFrame : public wxFrame // ------------------------------------------------------------------- void LoadDatabase(); void RefreshDatabase(); - void LoadConfigFile(int& height, int& width); + void LoadConfigFile(); // ------------------------------------------------------------------- // Getters