Fix font pref setting, share config objects

This commit is contained in:
Timothy Warren 2019-06-24 09:18:08 -04:00
parent f07dc8148d
commit 80245660d6
8 changed files with 23 additions and 21 deletions

View File

@ -1,7 +1,5 @@
# Building on Windows
In order to keep a consistent build system, Tyro is built with MinGW and Msys. This allows for a *nix-style build environment on Windows.
## Build Environment Setup:
1. Install [Visual Studio 2015](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) (Community or Express should work)
@ -14,4 +12,4 @@ In order to keep a consistent build system, Tyro is built with MinGW and Msys. T
## Build Tyro
TODO

View File

@ -60,7 +60,7 @@ int main(int argc, char** argv) {
fprintf(fo, "\n};\n\n");
fprintf(fo, "#endif\n");
printf("converted %s\n", argv[1]);
printf("converted %s to .h file\n", argv[1]);
return 0;
}

View File

@ -11,13 +11,14 @@
#include "src/widgets/MainFrame.h"
// Some global stuff
// All the ugly globals
wxConfigBase *Glob_config = nullptr;
LangConfig *Glob_lang_config = nullptr;
ThemeConfig *Glob_theme_config = nullptr;
MainFrame *Glob_main_frame = nullptr;
TyroMenu *Glob_menu_bar = nullptr;
wxStatusBar *Glob_status_bar = nullptr;
MainFrame *Glob_main_frame = nullptr;
ThemeConfig *Glob_theme_config = nullptr;
LangConfig *Glob_lang_config = nullptr;
StringConstMap Glob_lexer_map;
/**
@ -33,8 +34,6 @@ public:
*/
bool OnInit() final
{
// if ( ! wxApp::OnInit()) return false;
TyroApp::SetSystemOptions();
this->SetAppName(APP_NAME);
this->SetVendorName(APP_VENDOR);

View File

@ -723,7 +723,7 @@ void MainFrame::OnLangSelect(wxCommandEvent &event)
*
* @return void
*/
void MainFrame::OnPrefsChanged(wxCommandEvent &WXUNUSED(event))
void MainFrame::OnPrefsChanged()
{
this->notebook->Freeze();
for(size_t i = 0; i < this->notebook->GetPageCount(); i++)

View File

@ -16,7 +16,7 @@ class MainFrame: public wxFrame
~MainFrame() override;
void EnableEditControls(bool enable=true);
void OpenFiles(wxArrayString filelist);
void OnPrefsChanged(wxCommandEvent &event);
void OnPrefsChanged();
private:
PrefFrame *prefFrame = nullptr;
FileTreePane *fileTreePane = nullptr;

View File

@ -63,21 +63,28 @@ public:
{
this->showLineNumbers->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) {
Glob_config->Write("show_line_numbers", event.IsChecked());
Glob_main_frame->OnPrefsChanged(event);
Glob_main_frame->OnPrefsChanged();
Glob_config->Flush();
}, myID_PREFS_LINE_NUMBERS);
this->showIndentGuides->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) {
Glob_config->Write("show_indent_guides", event.IsChecked());
Glob_main_frame->OnPrefsChanged(event);
Glob_main_frame->OnPrefsChanged();
Glob_config->Flush();
}, myID_PREFS_IDENT_GUIDES);
this->showCodeFolding->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) {
Glob_config->Write("show_code_folding", event.IsChecked());
Glob_main_frame->OnPrefsChanged(event);
Glob_main_frame->OnPrefsChanged();
Glob_config->Flush();
}, myID_PREFS_CODE_FOLDING);
this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) {
auto font = event.GetFont();
Glob_config->Write("global_font", font);
Glob_main_frame->OnPrefsChanged();
Glob_config->Flush();
}, myID_PREFS_FONT);
}
}
@ -123,7 +130,7 @@ public:
Glob_config->Write("global_font", this->fontPicker->GetSelectedFont());
auto evt = wxCommandEvent();
Glob_main_frame->OnPrefsChanged(evt);
Glob_main_frame->OnPrefsChanged();
Glob_config->Flush();

View File

@ -1,5 +1,7 @@
#include "src/widgets/TyroMenu.h"
extern LangConfig *Glob_lang_config;
/**
* Constructor
*/
@ -11,8 +13,6 @@ TyroMenu::TyroMenu()
this->langMenu = new wxMenu();
this->helpMenu = new wxMenu();
this->lang_config = new LangConfig();
this->SetupMainMenus();
this->SetupLangMenu();
@ -30,7 +30,6 @@ TyroMenu::TyroMenu()
TyroMenu::~TyroMenu()
{
wxLogDebug("TyroMenu Destructor Called.");
delete this->lang_config;
}
/**
@ -82,7 +81,7 @@ void TyroMenu::SetupMainMenus()
*/
void TyroMenu::SetupLangMenu()
{
StringMap languages = lang_config->GetLangList();
StringMap languages = Glob_lang_config->GetLangList();
for (const auto lang: languages)
{

View File

@ -14,7 +14,6 @@ public:
void SetIdChecked(int id, bool checked);
void SetCurrentLanguage(string lang);
private:
LangConfig *lang_config = nullptr;
wxMenu *fileMenu = nullptr;
wxMenu *editMenu = nullptr;
wxMenu *viewMenu = nullptr;