Merge remote-tracking branch 'remotes/origin/ys_comboboxes'

This commit is contained in:
bubnikv 2019-03-21 10:11:27 +01:00
commit d9d0eff0f1
12 changed files with 134 additions and 65 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

View File

@ -2,6 +2,7 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "I18N.hpp" #include "I18N.hpp"
#include "Field.hpp" #include "Field.hpp"
#include "wxExtensions.hpp"
#include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfig.hpp"
@ -259,6 +260,11 @@ void TextCtrl::BUILD() {
const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/; const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style); auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
if (! m_opt.multiline)
// Only disable background refresh for single line input fields, as they are completely painted over by the edit control.
// This does not apply to the multi-line edit field, where the last line and a narrow frame around the text is not cleared.
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
#ifdef __WXOSX__ #ifdef __WXOSX__
temp->OSXDisableAllSmartSubstitutions(); temp->OSXDisableAllSmartSubstitutions();
@ -375,6 +381,7 @@ void CheckBox::BUILD() {
false; false;
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
temp->SetValue(check_value); temp->SetValue(check_value);
if (m_opt.readonly) temp->Disable(); if (m_opt.readonly) temp->Disable();
@ -433,6 +440,7 @@ void SpinCtrl::BUILD() {
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
0|wxTE_PROCESS_ENTER, min_val, max_val, default_value); 0|wxTE_PROCESS_ENTER, min_val, max_val, default_value);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
#ifndef __WXOSX__ #ifndef __WXOSX__
@ -498,15 +506,30 @@ void SpinCtrl::propagate_value()
} }
void Choice::BUILD() { void Choice::BUILD() {
auto size = wxSize(wxDefaultSize); wxSize size(15 * wxGetApp().em_unit(), -1);
if (m_opt.height >= 0) size.SetHeight(m_opt.height); if (m_opt.height >= 0) size.SetHeight(m_opt.height);
if (m_opt.width >= 0) size.SetWidth(m_opt.width); if (m_opt.width >= 0) size.SetWidth(m_opt.width);
wxComboBox* temp; wxBitmapComboBox* temp;
if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) {
temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); m_is_editable = true;
else temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, NULL, wxCB_READONLY); }
else {
#ifdef __WXOSX__
/* wxBitmapComboBox with wxCB_READONLY style return NULL for GetTextCtrl(),
* so ToolTip doesn't shown.
* Next workaround helps to solve this problem
*/
temp = new wxBitmapComboBox();
temp->SetTextCtrlStyle(wxTE_READONLY);
temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr);
#else
temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
#endif //__WXOSX__
}
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
// recast as a wxWindow to fit the calling convention // recast as a wxWindow to fit the calling convention
@ -517,19 +540,19 @@ void Choice::BUILD() {
else{ else{
for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) { for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) {
const wxString& str = _(el);//m_opt_id == "support" ? _(el) : el; const wxString& str = _(el);//m_opt_id == "support" ? _(el) : el;
temp->Append(str); temp->Append(str, create_scaled_bitmap("empty_icon.png"));
} }
set_selection(); set_selection();
} }
// temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); // temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
if (temp->GetWindowStyle() != wxCB_READONLY) { if (m_is_editable) {
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
e.Skip(); e.Skip();
if (m_opt.type == coStrings) return; if (m_opt.type == coStrings) return;
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999; double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
if (is_defined_input_value<wxComboBox>(window, m_opt.type)) { if (is_defined_input_value<wxBitmapComboBox>(window, m_opt.type)) {
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001) if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
return; return;
else else
@ -546,6 +569,8 @@ void Choice::BUILD() {
void Choice::set_selection() void Choice::set_selection()
{ {
wxString text_value = wxString(""); wxString text_value = wxString("");
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
switch (m_opt.type) { switch (m_opt.type) {
case coFloat: case coFloat:
case coPercent: { case coPercent: {
@ -560,13 +585,13 @@ void Choice::set_selection()
} }
// if (m_opt.type == coPercent) text_value += "%"; // if (m_opt.type == coPercent) text_value += "%";
idx == m_opt.enum_values.size() ? idx == m_opt.enum_values.size() ?
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) : field->SetValue(text_value) :
dynamic_cast<wxComboBox*>(window)->SetSelection(idx); field->SetSelection(idx);
break; break;
} }
case coEnum:{ case coEnum:{
int id_value = static_cast<const ConfigOptionEnum<SeamPosition>*>(m_opt.default_value)->value; //!! int id_value = static_cast<const ConfigOptionEnum<SeamPosition>*>(m_opt.default_value)->value; //!!
dynamic_cast<wxComboBox*>(window)->SetSelection(id_value); field->SetSelection(id_value);
break; break;
} }
case coInt:{ case coInt:{
@ -580,8 +605,8 @@ void Choice::set_selection()
++idx; ++idx;
} }
idx == m_opt.enum_values.size() ? idx == m_opt.enum_values.size() ?
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) : field->SetValue(text_value) :
dynamic_cast<wxComboBox*>(window)->SetSelection(idx); field->SetSelection(idx);
break; break;
} }
case coStrings:{ case coStrings:{
@ -595,8 +620,8 @@ void Choice::set_selection()
++idx; ++idx;
} }
idx == m_opt.enum_values.size() ? idx == m_opt.enum_values.size() ?
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) : field->SetValue(text_value) :
dynamic_cast<wxComboBox*>(window)->SetSelection(idx); field->SetSelection(idx);
break; break;
} }
} }
@ -614,9 +639,10 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
++idx; ++idx;
} }
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
idx == m_opt.enum_values.size() ? idx == m_opt.enum_values.size() ?
dynamic_cast<wxComboBox*>(window)->SetValue(value) : field->SetValue(value) :
dynamic_cast<wxComboBox*>(window)->SetSelection(idx); field->SetSelection(idx);
m_disable_change_event = false; m_disable_change_event = false;
} }
@ -625,6 +651,8 @@ void Choice::set_value(const boost::any& value, bool change_event)
{ {
m_disable_change_event = !change_event; m_disable_change_event = !change_event;
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
switch (m_opt.type) { switch (m_opt.type) {
case coInt: case coInt:
case coFloat: case coFloat:
@ -646,11 +674,11 @@ void Choice::set_value(const boost::any& value, bool change_event)
if (idx == m_opt.enum_values.size()) { if (idx == m_opt.enum_values.size()) {
// For editable Combobox under OSX is needed to set selection to -1 explicitly, // For editable Combobox under OSX is needed to set selection to -1 explicitly,
// otherwise selection doesn't be changed // otherwise selection doesn't be changed
dynamic_cast<wxComboBox*>(window)->SetSelection(-1); field->SetSelection(-1);
dynamic_cast<wxComboBox*>(window)->SetValue(text_value); field->SetValue(text_value);
} }
else else
dynamic_cast<wxComboBox*>(window)->SetSelection(idx); field->SetSelection(idx);
break; break;
} }
case coEnum: { case coEnum: {
@ -680,7 +708,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
else else
val = 0; val = 0;
} }
dynamic_cast<wxComboBox*>(window)->SetSelection(val); field->SetSelection(val);
break; break;
} }
default: default:
@ -699,7 +727,7 @@ void Choice::set_values(const std::vector<std::string>& values)
// # it looks that Clear() also clears the text field in recent wxWidgets versions, // # it looks that Clear() also clears the text field in recent wxWidgets versions,
// # but we want to preserve it // # but we want to preserve it
auto ww = dynamic_cast<wxComboBox*>(window); auto ww = dynamic_cast<wxBitmapComboBox*>(window);
auto value = ww->GetValue(); auto value = ww->GetValue();
ww->Clear(); ww->Clear();
ww->Append(""); ww->Append("");
@ -712,8 +740,9 @@ void Choice::set_values(const std::vector<std::string>& values)
boost::any& Choice::get_value() boost::any& Choice::get_value()
{ {
// boost::any m_value; wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();
wxString ret_str = field->GetValue();
// options from right panel // options from right panel
std::vector <std::string> right_panel_options{ "support", "scale_unit" }; std::vector <std::string> right_panel_options{ "support", "scale_unit" };
@ -723,7 +752,7 @@ boost::any& Choice::get_value()
if (m_opt.type == coEnum) if (m_opt.type == coEnum)
{ {
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection(); int ret_enum = field->GetSelection();
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern") if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern")
{ {
if (!m_opt.enum_values.empty()) { if (!m_opt.enum_values.empty()) {
@ -752,8 +781,9 @@ boost::any& Choice::get_value()
m_value = static_cast<SLAPillarConnectionMode>(ret_enum); m_value = static_cast<SLAPillarConnectionMode>(ret_enum);
} }
else if (m_opt.gui_type == "f_enum_open") { else if (m_opt.gui_type == "f_enum_open") {
const int ret_enum = static_cast<wxComboBox*>(window)->GetSelection(); const int ret_enum = field->GetSelection();
if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings) if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
ret_str != m_opt.enum_values[ret_enum] && ret_str != m_opt.enum_labels[ret_enum] )
// modifies ret_string! // modifies ret_string!
get_value_by_opt_type(ret_str); get_value_by_opt_type(ret_str);
else else
@ -815,12 +845,16 @@ void PointCtrl::BUILD()
x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER); x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER);
y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER); y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER);
x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
auto static_text_x = new wxStaticText(m_parent, wxID_ANY, "x : "); auto static_text_x = new wxStaticText(m_parent, wxID_ANY, "x : ");
auto static_text_y = new wxStaticText(m_parent, wxID_ANY, " y : "); auto static_text_y = new wxStaticText(m_parent, wxID_ANY, " y : ");
static_text_x->SetFont(Slic3r::GUI::wxGetApp().normal_font());
static_text_x->SetBackgroundStyle(wxBG_STYLE_PAINT); static_text_x->SetBackgroundStyle(wxBG_STYLE_PAINT);
static_text_y->SetFont(Slic3r::GUI::wxGetApp().normal_font());
static_text_y->SetBackgroundStyle(wxBG_STYLE_PAINT); static_text_y->SetBackgroundStyle(wxBG_STYLE_PAINT);
temp->Add(static_text_x, 0, wxALIGN_CENTER_VERTICAL, 0); temp->Add(static_text_x, 0, wxALIGN_CENTER_VERTICAL, 0);
@ -894,6 +928,7 @@ void StaticText::BUILD()
const wxString legend(static_cast<const ConfigOptionString*>(m_opt.default_value)->value); const wxString legend(static_cast<const ConfigOptionString*>(m_opt.default_value)->value);
auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE); auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
temp->SetFont(wxGetApp().bold_font()); temp->SetFont(wxGetApp().bold_font());
@ -918,11 +953,13 @@ void SliderCtrl::BUILD()
m_slider = new wxSlider(m_parent, wxID_ANY, def_val * m_scale, m_slider = new wxSlider(m_parent, wxID_ANY, def_val * m_scale,
min * m_scale, max * m_scale, min * m_scale, max * m_scale,
wxDefaultPosition, size); wxDefaultPosition, size);
m_slider->SetFont(Slic3r::GUI::wxGetApp().normal_font());
m_slider->SetBackgroundStyle(wxBG_STYLE_PAINT); m_slider->SetBackgroundStyle(wxBG_STYLE_PAINT);
wxSize field_size(40, -1); wxSize field_size(40, -1);
m_textctrl = new wxTextCtrl(m_parent, wxID_ANY, wxString::Format("%d", m_slider->GetValue()/m_scale), m_textctrl = new wxTextCtrl(m_parent, wxID_ANY, wxString::Format("%d", m_slider->GetValue()/m_scale),
wxDefaultPosition, field_size); wxDefaultPosition, field_size);
m_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
m_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); m_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
temp->Add(m_slider, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL, 0); temp->Add(m_slider, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL, 0);

View File

@ -11,6 +11,7 @@
#include <boost/any.hpp> #include <boost/any.hpp>
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/bmpcbox.h>
#include <wx/clrpicker.h> #include <wx/clrpicker.h>
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
@ -351,14 +352,19 @@ public:
wxWindow* window{ nullptr }; wxWindow* window{ nullptr };
void BUILD() override; void BUILD() override;
/* Under OSX: wxBitmapComboBox->GetWindowStyle() returns some weard value,
* so let use a flag, which has TRUE value for a control without wxCB_READONLY style
*/
bool m_is_editable { false };
void set_selection(); void set_selection();
void set_value(const std::string& value, bool change_event = false); void set_value(const std::string& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false); void set_value(const boost::any& value, bool change_event = false);
void set_values(const std::vector<std::string> &values); void set_values(const std::vector<std::string> &values);
boost::any& get_value() override; boost::any& get_value() override;
void enable() override { dynamic_cast<wxComboBox*>(window)->Enable(); }; void enable() override { dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxComboBox*>(window)->Disable(); }; void disable() override{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); };
wxWindow* getWindow() override { return window; } wxWindow* getWindow() override { return window; }
}; };

View File

@ -94,7 +94,11 @@ bool GUI_App::OnInit()
SetAppName("Slic3rPE-beta"); SetAppName("Slic3rPE-beta");
SetAppDisplayName("Slic3r Prusa Edition"); SetAppDisplayName("Slic3r Prusa Edition");
// Enable this to get the default Win32 COMCTRL32 behavior of static boxes.
// wxSystemOptions::SetOption("msw.staticbox.optimized-paint", 0); // wxSystemOptions::SetOption("msw.staticbox.optimized-paint", 0);
// Enable this to disable Windows Vista themes for all wxNotebooks. The themes seem to lead to terrible
// performance when working on high resolution multi-display setups.
// wxSystemOptions::SetOption("msw.notebook.themed-background", 0);
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION; // Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
@ -249,6 +253,7 @@ void GUI_App::init_fonts()
{ {
m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
m_bold_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); m_bold_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold();
m_normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMAC__ #ifdef __WXMAC__
m_small_font.SetPointSize(11); m_small_font.SetPointSize(11);
@ -496,7 +501,7 @@ Tab* GUI_App::get_tab(Preset::Type type)
{ {
for (Tab* tab: tabs_list) for (Tab* tab: tabs_list)
if (tab->type() == type) if (tab->type() == type)
return tab; return tab->complited() ? tab : nullptr; // To avoid actions with no-completed Tab
return nullptr; return nullptr;
} }
@ -525,7 +530,7 @@ void GUI_App::update_mode()
sidebar().update_mode(); sidebar().update_mode();
for (auto tab : tabs_list) for (auto tab : tabs_list)
tab->update_visibility(); tab->update_mode();
plater()->update_object_menu(); plater()->update_object_menu();
} }

View File

@ -78,6 +78,7 @@ class GUI_App : public wxApp
wxFont m_small_font; wxFont m_small_font;
wxFont m_bold_font; wxFont m_bold_font;
wxFont m_normal_font;
size_t m_em_unit; // width of a "m"-symbol in pixels for current system font size_t m_em_unit; // width of a "m"-symbol in pixels for current system font
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls // Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
@ -106,6 +107,7 @@ public:
const wxFont& small_font() { return m_small_font; } const wxFont& small_font() { return m_small_font; }
const wxFont& bold_font() { return m_bold_font; } const wxFont& bold_font() { return m_bold_font; }
const wxFont& normal_font() { return m_normal_font; }
size_t em_unit() const { return m_em_unit; } size_t em_unit() const { return m_em_unit; }
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; } void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }

View File

@ -96,6 +96,12 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
return; return;
} }
// Weird things happen as the Paint messages are floating around the windows being destructed.
// Avoid the Paint messages by hiding the main window.
// Also the application closes much faster without these unnecessary screen refreshes.
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
this->Show(false);
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback, // Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
// but in rare cases it may not have been called yet. // but in rare cases it may not have been called yet.
wxGetApp().app_config->save(); wxGetApp().app_config->save();
@ -127,7 +133,9 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
void MainFrame::init_tabpanel() void MainFrame::init_tabpanel()
{ {
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL); // wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10
// with multiple high resolution displays connected.
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) { m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
auto panel = m_tabpanel->GetCurrentPage(); auto panel = m_tabpanel->GetCurrentPage();

View File

@ -138,7 +138,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
line.get_extra_widgets().size() == 0) { line.get_extra_widgets().size() == 0) {
wxSizer* tmp_sizer; wxSizer* tmp_sizer;
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
tmp_sizer = new wxBoxSizer(wxVERTICAL); tmp_sizer = new wxBoxSizer(wxVERTICAL);
m_panel->SetSizer(tmp_sizer); m_panel->SetSizer(tmp_sizer);
m_panel->Layout(); m_panel->Layout();
@ -160,7 +160,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
} }
auto grid_sizer = m_grid_sizer; auto grid_sizer = m_grid_sizer;
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
m_panel->SetSizer(m_grid_sizer); m_panel->SetSizer(m_grid_sizer);
m_panel->Layout(); m_panel->Layout();
#endif /* __WXGTK__ */ #endif /* __WXGTK__ */
@ -443,7 +443,7 @@ void ConfigOptionsGroup::Hide()
void ConfigOptionsGroup::Show(const bool show) void ConfigOptionsGroup::Show(const bool show)
{ {
sizer->ShowItems(show); sizer->ShowItems(show);
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
m_panel->Show(show); m_panel->Show(show);
m_grid_sizer->Show(show); m_grid_sizer->Show(show);
#endif /* __WXGTK__ */ #endif /* __WXGTK__ */

View File

@ -100,13 +100,13 @@ public:
/// Accessor function is because users are not allowed to change the parent /// Accessor function is because users are not allowed to change the parent
/// but defining it as const means a lot of const_casts to deal with wx functions. /// but defining it as const means a lot of const_casts to deal with wx functions.
inline wxWindow* parent() const { inline wxWindow* parent() const {
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
return m_panel; return m_panel;
#else #else
return m_parent; return m_parent;
#endif /* __WXGTK__ */ #endif /* __WXGTK__ */
} }
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
wxWindow* get_parent() const { wxWindow* get_parent() const {
return m_parent; return m_parent;
} }
@ -176,7 +176,7 @@ public:
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0); m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/); static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 ); static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 );
#ifdef __WXGTK__ #if 0//#ifdef __WXGTK__
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sizer->Fit(m_panel); sizer->Fit(m_panel);
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5); sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
@ -204,7 +204,7 @@ protected:
// This panel is needed for correct showing of the ToolTips for Button, StaticText and CheckBox // This panel is needed for correct showing of the ToolTips for Button, StaticText and CheckBox
// Tooltips on GTK doesn't work inside wxStaticBoxSizer unless you insert a panel // Tooltips on GTK doesn't work inside wxStaticBoxSizer unless you insert a panel
// inside it before you insert the other controls. // inside it before you insert the other controls.
#ifdef __WXGTK__ #if 0//#ifdef__WXGTK__
wxPanel* m_panel {nullptr}; wxPanel* m_panel {nullptr};
#endif /* __WXGTK__ */ #endif /* __WXGTK__ */

View File

@ -282,7 +282,7 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif #endif
edit_btn->SetBitmap(create_scaled_bitmap("cog.png")); edit_btn->SetBitmap(create_scaled_bitmap("cog.png"));
edit_btn->SetToolTip(_(L("Click to Edit a selected Filament Preset"))); edit_btn->SetToolTip(_(L("Click to edit preset")));
edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent) edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent)
{ {
@ -304,7 +304,7 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data(); const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
// Call select_preset() only if there is new preset and not just modified // Call select_preset() only if there is new preset and not just modified
if ( !boost::algorithm::ends_with(selected_preset, "(modified)") ) if ( !boost::algorithm::ends_with(selected_preset, Preset::suffix_modified()) )
tab->select_preset(selected_preset); tab->select_preset(selected_preset);
} }
})); }));

View File

@ -201,6 +201,7 @@ public:
static const std::vector<std::string>& sla_print_options(); static const std::vector<std::string>& sla_print_options();
static void update_suffix_modified(); static void update_suffix_modified();
static const std::string& suffix_modified();
static void normalize(DynamicPrintConfig &config); static void normalize(DynamicPrintConfig &config);
// Report configuration fields, which are misplaced into a wrong group, remove them from the config. // Report configuration fields, which are misplaced into a wrong group, remove them from the config.
static std::string remove_invalid_keys(DynamicPrintConfig &config, const DynamicPrintConfig &default_config); static std::string remove_invalid_keys(DynamicPrintConfig &config, const DynamicPrintConfig &default_config);
@ -210,7 +211,6 @@ protected:
friend class PresetBundle; friend class PresetBundle;
// Resize the extruder specific vectors () // Resize the extruder specific vectors ()
static void set_num_extruders(DynamicPrintConfig &config, unsigned int n); static void set_num_extruders(DynamicPrintConfig &config, unsigned int n);
static const std::string& suffix_modified();
static std::string remove_suffix_modified(const std::string &name); static std::string remove_suffix_modified(const std::string &name);
}; };

View File

@ -268,6 +268,7 @@ void Tab::create_preset_tab()
// Initialize the DynamicPrintConfig by default keys/values. // Initialize the DynamicPrintConfig by default keys/values.
build(); build();
rebuild_page_tree(); rebuild_page_tree();
m_complited = true;
} }
void Tab::load_initial_data() void Tab::load_initial_data()
@ -704,25 +705,28 @@ void Tab::reload_config()
// Thaw(); // Thaw();
} }
void Tab::update_visibility() void Tab::update_mode()
{ {
const ConfigOptionMode mode = wxGetApp().get_mode(); m_mode = wxGetApp().get_mode();
// Freeze();
for (auto page : m_pages)
page->update_visibility(mode);
update_page_tree_visibility();
// update mode for ModeSizer // update mode for ModeSizer
m_mode_sizer->SetMode(mode); m_mode_sizer->SetMode(m_mode);
update_visibility();
}
void Tab::update_visibility()
{
Freeze(); // There is needed Freeze/Thaw to avoid a flashing after Show/Layout
for (auto page : m_pages)
page->update_visibility(m_mode);
update_page_tree_visibility();
Layout(); Layout();
// Thaw(); // Thaw();
// to update tree items color
// wxTheApp->CallAfter([this]() {
update_changed_tree_ui(); update_changed_tree_ui();
// });
} }
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1498,6 +1502,7 @@ void TabFilament::build()
line = optgroup->create_single_option_line("filament_ramming_parameters");// { _(L("Ramming")), "" }; line = optgroup->create_single_option_line("filament_ramming_parameters");// { _(L("Ramming")), "" };
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
ramming_dialog_btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(ramming_dialog_btn); sizer->Add(ramming_dialog_btn);
@ -1633,6 +1638,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
auto printhost_browse = [=](wxWindow* parent) { auto printhost_browse = [=](wxWindow* parent) {
auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT); auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
btn->SetBitmap(create_scaled_bitmap("zoom.png")); btn->SetBitmap(create_scaled_bitmap("zoom.png"));
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn); sizer->Add(btn);
@ -1651,6 +1657,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
auto print_host_test = [this](wxWindow* parent) { auto print_host_test = [this](wxWindow* parent) {
auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")), auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
btn->SetBitmap(create_scaled_bitmap("wrench.png")); btn->SetBitmap(create_scaled_bitmap("wrench.png"));
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn); sizer->Add(btn);
@ -1688,6 +1695,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) { auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) {
auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT); auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
// btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG)); // btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
btn->SetBitmap(create_scaled_bitmap("zoom.png")); btn->SetBitmap(create_scaled_bitmap("zoom.png"));
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn); sizer->Add(btn);
@ -1726,6 +1734,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
\tOn this system, Slic3r uses HTTPS certificates from the system Certificate Store or Keychain.\n\ \tOn this system, Slic3r uses HTTPS certificates from the system Certificate Store or Keychain.\n\
\tTo use a custom CA file, please import your CA file into Certificate Store / Keychain.")), \tTo use a custom CA file, please import your CA file into Certificate Store / Keychain.")),
ca_file_hint)); ca_file_hint));
txt->SetFont(Slic3r::GUI::wxGetApp().normal_font());
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(txt); sizer->Add(txt);
return sizer; return sizer;
@ -1966,7 +1975,7 @@ void TabPrinter::build_sla()
Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" }; Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" };
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
auto btn = new wxButton(parent, wxID_ANY, _(L(" Set ")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); auto btn = new wxButton(parent, wxID_ANY, _(L(" Set ")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
// btn->SetFont(Slic3r::GUI::small_font); btn->SetFont(wxGetApp().small_font());
// btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG)); // btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG));
btn->SetBitmap(create_scaled_bitmap("printer_empty.png")); btn->SetBitmap(create_scaled_bitmap("printer_empty.png"));
@ -2258,7 +2267,7 @@ void TabPrinter::update_pages()
else else
m_pages_sla.empty() ? build_sla() : m_pages.swap(m_pages_sla); m_pages_sla.empty() ? build_sla() : m_pages.swap(m_pages_sla);
rebuild_page_tree(true); rebuild_page_tree();
} }
void TabPrinter::update() void TabPrinter::update()
@ -2464,10 +2473,8 @@ void Tab::load_current_preset()
} }
//Regerenerate content of the page tree. //Regerenerate content of the page tree.
void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/) void Tab::rebuild_page_tree()
{ {
// Freeze();
// get label of the currently selected item // get label of the currently selected item
const auto sel_item = m_treectrl->GetSelection(); const auto sel_item = m_treectrl->GetSelection();
const auto selected = sel_item ? m_treectrl->GetItemText(sel_item) : ""; const auto selected = sel_item ? m_treectrl->GetItemText(sel_item) : "";
@ -2480,10 +2487,7 @@ void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/)
auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID());
m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); m_treectrl->SetItemTextColour(itemId, p->get_item_colour());
if (p->title() == selected) { if (p->title() == selected) {
// if (!(p->title() == _(L("Machine limits")) || p->title() == _(L("Single extruder MM setup")))) // These Pages have to be updated inside OnTreeSelChange
// m_disable_tree_sel_changed_event = !tree_sel_change_event;
m_treectrl->SelectItem(itemId); m_treectrl->SelectItem(itemId);
m_disable_tree_sel_changed_event = false;
have_selection = 1; have_selection = 1;
} }
} }
@ -2883,7 +2887,9 @@ void Tab::update_ui_from_settings()
wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps) wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps)
{ {
deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All"))); deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All")));
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// deps.btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG)); // deps.btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG));
deps.btn->SetBitmap(create_scaled_bitmap("printer_empty.png")); deps.btn->SetBitmap(create_scaled_bitmap("printer_empty.png"));

View File

@ -207,6 +207,9 @@ protected:
void set_type(); void set_type();
int m_em_unit; int m_em_unit;
// To avoid actions with no-completed Tab
bool m_complited { false };
ConfigOptionMode m_mode = comSimple;
public: public:
PresetBundle* m_preset_bundle; PresetBundle* m_preset_bundle;
@ -229,11 +232,12 @@ public:
wxString title() const { return m_title; } wxString title() const { return m_title; }
std::string name() const { return m_name; } std::string name() const { return m_name; }
Preset::Type type() const { return m_type; } Preset::Type type() const { return m_type; }
bool complited() const { return m_complited; }
virtual bool supports_printer_technology(const PrinterTechnology tech) = 0; virtual bool supports_printer_technology(const PrinterTechnology tech) = 0;
void create_preset_tab(); void create_preset_tab();
void load_current_preset(); void load_current_preset();
void rebuild_page_tree(bool tree_sel_change_event = false); void rebuild_page_tree();
void update_page_tree_visibility(); void update_page_tree_visibility();
void select_preset(std::string preset_name = ""); void select_preset(std::string preset_name = "");
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = ""); bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
@ -267,6 +271,7 @@ public:
void update_tab_ui(); void update_tab_ui();
void load_config(const DynamicPrintConfig& config); void load_config(const DynamicPrintConfig& config);
virtual void reload_config(); virtual void reload_config();
void update_mode();
void update_visibility(); void update_visibility();
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
bool set_value(const t_config_option_key& opt_key, const boost::any& value); bool set_value(const t_config_option_key& opt_key, const boost::any& value);