mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Some improvements
This commit is contained in:
parent
99e43d6b24
commit
b382ad1ffb
6 changed files with 43 additions and 24 deletions
BIN
resources/icons/empty_icon.png
Normal file
BIN
resources/icons/empty_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 893 B |
|
@ -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"
|
||||||
|
|
||||||
|
@ -493,13 +494,15 @@ 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);
|
||||||
|
|
||||||
wxBitmapComboBox* 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) {
|
||||||
|
m_is_editable = true;
|
||||||
temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
|
temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
|
||||||
|
|
||||||
|
@ -511,14 +514,14 @@ 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/*, *m_undo_bitmap*/);
|
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;
|
||||||
|
@ -540,6 +543,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: {
|
||||||
|
@ -554,13 +559,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<wxBitmapComboBox*>(window)->SetValue(text_value) :
|
field->SetValue(text_value) :
|
||||||
dynamic_cast<wxBitmapComboBox*>(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<wxBitmapComboBox*>(window)->SetSelection(id_value);
|
field->SetSelection(id_value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case coInt:{
|
case coInt:{
|
||||||
|
@ -574,8 +579,8 @@ void Choice::set_selection()
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
idx == m_opt.enum_values.size() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetValue(text_value) :
|
field->SetValue(text_value) :
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case coStrings:{
|
case coStrings:{
|
||||||
|
@ -589,8 +594,8 @@ void Choice::set_selection()
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
idx == m_opt.enum_values.size() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetValue(text_value) :
|
field->SetValue(text_value) :
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,9 +613,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<wxBitmapComboBox*>(window)->SetValue(value) :
|
field->SetValue(value) :
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
|
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
|
@ -619,6 +625,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:
|
||||||
|
@ -640,11 +648,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<wxBitmapComboBox*>(window)->SetSelection(-1);
|
field->SetSelection(-1);
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetValue(text_value);
|
field->SetValue(text_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case coEnum: {
|
case coEnum: {
|
||||||
|
@ -674,7 +682,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
||||||
else
|
else
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
dynamic_cast<wxBitmapComboBox*>(window)->SetSelection(val);
|
field->SetSelection(val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -706,8 +714,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<wxBitmapComboBox*>(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" };
|
||||||
|
@ -717,7 +726,7 @@ boost::any& Choice::get_value()
|
||||||
|
|
||||||
if (m_opt.type == coEnum)
|
if (m_opt.type == coEnum)
|
||||||
{
|
{
|
||||||
int ret_enum = static_cast<wxBitmapComboBox*>(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()) {
|
||||||
|
@ -746,8 +755,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<wxBitmapComboBox*>(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
|
||||||
|
|
|
@ -352,6 +352,11 @@ 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);
|
||||||
|
|
|
@ -506,7 +506,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,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()
|
||||||
|
|
|
@ -204,6 +204,8 @@ 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 };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PresetBundle* m_preset_bundle;
|
PresetBundle* m_preset_bundle;
|
||||||
|
@ -226,6 +228,7 @@ 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();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue