From 8969613a5a0810b761371613cd7563161a407a86 Mon Sep 17 00:00:00 2001
From: tamasmeszaros <meszaros.q@gmail.com>
Date: Thu, 7 May 2020 12:46:37 +0200
Subject: [PATCH 1/2] Fix cmake error on unixes

---
 deps/CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt
index 06ab0fa65..74bf6eb53 100644
--- a/deps/CMakeLists.txt
+++ b/deps/CMakeLists.txt
@@ -152,8 +152,10 @@ include(MPFR/MPFR.cmake)
 include(CGAL/CGAL.cmake)
 include(wxWidgets/wxWidgets.cmake)
 
-add_dependencies(dep_blosc ${ZLIB_PKG})
-add_dependencies(dep_openexr ${ZLIB_PKG})
+if (ZLIB_PKG)
+    add_dependencies(dep_blosc ${ZLIB_PKG})
+    add_dependencies(dep_openexr ${ZLIB_PKG})
+endif ()
 
 if (MSVC)
 

From 3c996111aa56952d5b58cb0d010d0bc2c5c65abd Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Thu, 7 May 2020 15:36:50 +0200
Subject: [PATCH 2/2] Layouts: 1. Fixed crash on OSX after change of the
 settings layout (PreferencesDialog should be destroyed before call of
 recreate_GUI) 2. Fixed dialog message during GUI recreation 3. In
 PreferencesDialog changed radio buttons view (under OSX they were bold) 4.
 slDlg mode - fixed switching between main frame and settings dialog
 (dialog->SetFocus() doesn't work under OSX, so we just hide it and show
 again)

---
 src/slic3r/GUI/GUI_App.cpp      | 18 +++++++++++++-----
 src/slic3r/GUI/GUI_App.hpp      |  2 +-
 src/slic3r/GUI/MainFrame.cpp    |  5 ++---
 src/slic3r/GUI/OptionsGroup.hpp |  2 +-
 src/slic3r/GUI/Preferences.cpp  | 27 +++++++++++++--------------
 src/slic3r/GUI/Preferences.hpp  |  3 +++
 6 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index dcef48de9..bea73b51e 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -591,11 +591,10 @@ float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
     return 0.01f * int_val * icon_sc;
 }
 
-void GUI_App::recreate_GUI()
+void GUI_App::recreate_GUI(const wxString& msg_name)
 {
     mainframe->shutdown();
 
-    const auto msg_name = _(L("Changing of an application language")) + dots;
     wxProgressDialog dlg(msg_name, msg_name);
     dlg.Pulse();
     dlg.Update(10, _(L("Recreating")) + dots);
@@ -726,7 +725,7 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
 bool GUI_App::switch_language()
 {
     if (select_language()) {
-        recreate_GUI();
+        recreate_GUI(_L("Changing of an application language") + dots);
         return true;
     } else {
         return false;
@@ -1030,8 +1029,17 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
             break;
         case ConfigMenuPreferences:
         {
-            PreferencesDialog dlg(mainframe);
-            dlg.ShowModal();
+            bool recreate_app = false;
+            {
+                // the dialog needs to be destroyed before the call to recreate_GUI()
+                // or sometimes the application crashes into wxDialogBase() destructor
+                // so we put it into an inner scope
+                PreferencesDialog dlg(mainframe);
+                dlg.ShowModal();
+                recreate_app = dlg.settings_layout_changed();
+            }
+            if (recreate_app)
+                recreate_GUI(_L("Changing of the settings layout") + dots);
             break;
         }
         case ConfigMenuLanguage:
diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp
index f0caeed0a..50c771879 100644
--- a/src/slic3r/GUI/GUI_App.hpp
+++ b/src/slic3r/GUI/GUI_App.hpp
@@ -136,7 +136,7 @@ public:
     int             em_unit() const         { return m_em_unit; }
     float           toolbar_icon_scale(const bool is_limited = false) const;
 
-    void            recreate_GUI();
+    void            recreate_GUI(const wxString& message);
     void            system_info();
     void            keyboard_shortcuts();
     void            load_project(wxWindow *parent, wxString& input_file) const;
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 62fffc423..2b16e92d6 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -1267,9 +1267,8 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
         }
         // Show/Activate Settings Dialog
         if (m_settings_dialog->IsShown())
-            m_settings_dialog->SetFocus();
-        else
-            m_settings_dialog->Show();
+            m_settings_dialog->Hide();
+        m_settings_dialog->Show();
     }
     else if (m_layout == slNew) {
         m_plater->Show(tab == 0);
diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp
index 6128eb7ab..09df9ea65 100644
--- a/src/slic3r/GUI/OptionsGroup.hpp
+++ b/src/slic3r/GUI/OptionsGroup.hpp
@@ -178,7 +178,7 @@ public:
         if (staticbox) {
             stb = new wxStaticBox(_parent, wxID_ANY, _(title));
             if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
-            stb->SetFont(wxGetApp().bold_font());
+            stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
         } else
         	stb = nullptr;
         sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp
index 88c643add..ff42da61d 100644
--- a/src/slic3r/GUI/Preferences.cpp
+++ b/src/slic3r/GUI/Preferences.cpp
@@ -117,13 +117,6 @@ void PreferencesDialog::build()
 	m_optgroup_general->append_single_option_line(option);
 #endif
 
-	def.label = L("Show the button for the collapse sidebar");
-	def.type = coBool;
-	def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
-	def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
-	option = Option(def, "show_collapse_button");
-	m_optgroup_general->append_single_option_line(option);
-
 	m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _(L("Camera")));
 	m_optgroup_camera->label_width = 40;
 	m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
@@ -154,6 +147,13 @@ void PreferencesDialog::build()
 		}
 	};
 
+	def.label = L("Show the button for the collapse sidebar");
+	def.type = coBool;
+	def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
+	def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
+	option = Option(def, "show_collapse_button");
+	m_optgroup_gui->append_single_option_line(option);
+
 	def.label = L("Use custom size for toolbar icons");
 	def.type = coBool;
 	def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
@@ -190,11 +190,11 @@ void PreferencesDialog::accept()
 
     auto app_config = get_app_config();
 
-	bool settings_layout_changed =	m_values.find("old_settings_layout_mode") != m_values.end() ||
-		                            m_values.find("new_settings_layout_mode") != m_values.end() ||
-		                            m_values.find("dlg_settings_layout_mode") != m_values.end();
+	m_settings_layout_changed =	m_values.find("old_settings_layout_mode") != m_values.end() ||
+		                        m_values.find("new_settings_layout_mode") != m_values.end() ||
+		                        m_values.find("dlg_settings_layout_mode") != m_values.end();
 
-	if (settings_layout_changed) {
+	if (m_settings_layout_changed) {
 		// the dialog needs to be destroyed before the call to recreate_gui()
 		// or sometimes the application crashes into wxDialogBase() destructor
 		// so we put it into an inner scope
@@ -222,9 +222,8 @@ void PreferencesDialog::accept()
 	app_config->save();
 	EndModal(wxID_OK);
 
-	if (settings_layout_changed)
-		// recreate application, if settings layout was changed
-		wxGetApp().recreate_GUI();
+	if (m_settings_layout_changed)
+		;// application will be recreated after Preference dialog will be destroyed
 	else
 	    // Nothify the UI to update itself from the ini file.
         wxGetApp().update_ui_from_settings();
diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp
index 738e805b2..d90f01e2b 100644
--- a/src/slic3r/GUI/Preferences.hpp
+++ b/src/slic3r/GUI/Preferences.hpp
@@ -23,10 +23,13 @@ class PreferencesDialog : public DPIDialog
 	wxSizer*                            m_icon_size_sizer;
 	wxRadioBox*							m_layout_mode_box;
     bool                                isOSX {false};
+	bool								m_settings_layout_changed {false};
 public:
 	PreferencesDialog(wxWindow* parent);
 	~PreferencesDialog() {}
 
+	bool settings_layout_changed() { return m_settings_layout_changed; }
+
 	void	build();
 	void	accept();