First filling of the PhysicalPrinterDialog

+ Fixed scaling of the icons for the BitmapComboBoxes
 + Fixed calling of the blinking icons on the Tabs
This commit is contained in:
YuSanka 2020-06-18 11:39:25 +02:00
parent 19c4f32604
commit 7c7dcab032
4 changed files with 34 additions and 24 deletions

View file

@ -295,6 +295,7 @@ void Field::msw_rescale(bool rescale_sidetext)
{ {
m_Undo_to_sys_btn->msw_rescale(); m_Undo_to_sys_btn->msw_rescale();
m_Undo_btn->msw_rescale(); m_Undo_btn->msw_rescale();
m_blinking_bmp->msw_rescale();
// update em_unit value // update em_unit value
m_em_unit = em_unit(m_parent); m_em_unit = em_unit(m_parent);

View file

@ -58,7 +58,7 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, 0, nullptr, wxCB_READONLY), wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, 0, nullptr, wxCB_READONLY),
m_type(preset_type), m_type(preset_type),
m_last_selected(wxNOT_FOUND), m_last_selected(wxNOT_FOUND),
m_em_unit(wxGetApp().em_unit()), m_em_unit(em_unit(this)),
m_preset_bundle(wxGetApp().preset_bundle), m_preset_bundle(wxGetApp().preset_bundle),
m_bitmap_cache(new BitmapCache) m_bitmap_cache(new BitmapCache)
{ {
@ -99,9 +99,9 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
default: break; default: break;
} }
m_bitmapCompatible = ScalableBitmap(nullptr, "flag_green"); m_bitmapCompatible = ScalableBitmap(this, "flag_green");
m_bitmapIncompatible = ScalableBitmap(nullptr, "flag_red"); m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
m_bitmapLock = ScalableBitmap(nullptr, "lock_closed"); m_bitmapLock = ScalableBitmap(this, "lock_closed");
// parameters for an icon's drawing // parameters for an icon's drawing
fill_width_height(); fill_width_height();
@ -120,7 +120,7 @@ void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
void PresetComboBox::msw_rescale() void PresetComboBox::msw_rescale()
{ {
m_em_unit = wxGetApp().em_unit(); m_em_unit = em_unit(this);
m_bitmapLock.msw_rescale(); m_bitmapLock.msw_rescale();
m_bitmapIncompatible.msw_rescale(); m_bitmapIncompatible.msw_rescale();
@ -241,7 +241,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
evt.StopPropagation(); evt.StopPropagation();
if (marker == LABEL_ITEM_PHYSICAL_PRINTERS) if (marker == LABEL_ITEM_PHYSICAL_PRINTERS)
{ {
PhysicalPrinterDialog dlg; PhysicalPrinterDialog dlg(_L("New Physical Printer"), this->m_last_selected);
dlg.ShowModal(); dlg.ShowModal();
return; return;
} }
@ -360,7 +360,7 @@ PlaterPresetComboBox::~PlaterPresetComboBox()
void PlaterPresetComboBox::update() void PlaterPresetComboBox::update()
{ {
if (m_type == Preset::TYPE_FILAMENT && if (m_type == Preset::TYPE_FILAMENT &&
(m_collection->get_edited_preset().printer_technology() == ptSLA || (m_preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA ||
m_preset_bundle->filament_presets.size() <= m_extruder_idx) ) m_preset_bundle->filament_presets.size() <= m_extruder_idx) )
return; return;
@ -586,13 +586,13 @@ void PlaterPresetComboBox::msw_rescale()
// --------------------------------- // ---------------------------------
// *** PlaterPresetComboBox *** // *** TabPresetComboBox ***
// --------------------------------- // ---------------------------------
TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type) : TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type, bool is_from_physical_printer/* = false*/) :
PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1)) PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1))
{ {
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { Bind(wxEVT_COMBOBOX, [this, is_from_physical_printer](wxCommandEvent& evt) {
// see https://github.com/prusa3d/PrusaSlicer/issues/3889 // see https://github.com/prusa3d/PrusaSlicer/issues/3889
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender") // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
@ -603,9 +603,16 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) { if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
this->SetSelection(this->m_last_selected); this->SetSelection(this->m_last_selected);
if (marker == LABEL_ITEM_WIZARD_PRINTERS) if (marker == LABEL_ITEM_WIZARD_PRINTERS)
wxTheApp->CallAfter([]() { wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS); }); wxTheApp->CallAfter([this, is_from_physical_printer]() {
wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS);
if (is_from_physical_printer)
update();
});
} }
else if (m_last_selected != selected_item || m_collection->current_is_dirty()) { else if ( is_from_physical_printer) {
// do nothing
}
else if (m_last_selected != selected_item || m_collection->current_is_dirty() ) {
std::string selected_string = this->GetString(selected_item).ToUTF8().data(); std::string selected_string = this->GetString(selected_item).ToUTF8().data();
Tab* tab = wxGetApp().get_tab(this->m_type); Tab* tab = wxGetApp().get_tab(this->m_type);
assert (tab); assert (tab);
@ -638,7 +645,7 @@ void TabPresetComboBox::update()
continue; continue;
std::string bitmap_key = "tab"; std::string bitmap_key = "tab";
wxBitmap main_bmp = create_scaled_bitmap(m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name); wxBitmap main_bmp = create_scaled_bitmap(m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name, this);
if (m_type == Preset::TYPE_PRINTER) { if (m_type == Preset::TYPE_PRINTER) {
bitmap_key += "_printer"; bitmap_key += "_printer";
if (preset.printer_technology() == ptSLA) if (preset.printer_technology() == ptSLA)
@ -694,8 +701,8 @@ void TabPresetComboBox::update()
if (bmp == nullptr) { if (bmp == nullptr) {
// Create the bitmap with color bars. // Create the bitmap with color bars.
std::vector<wxBitmap> bmps; std::vector<wxBitmap> bmps;
bmps.emplace_back(create_scaled_bitmap(m_main_bitmap_name)); bmps.emplace_back(create_scaled_bitmap(m_main_bitmap_name, this));
bmps.emplace_back(create_scaled_bitmap("edit_uni")); bmps.emplace_back(create_scaled_bitmap("edit_uni", this));
bmp = m_bitmap_cache->insert(bitmap_key, bmps); bmp = m_bitmap_cache->insert(bitmap_key, bmps);
} }
set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS); set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
@ -753,8 +760,8 @@ void TabPresetComboBox::update_dirty()
//------------------------------------------ //------------------------------------------
PhysicalPrinterDialog::PhysicalPrinterDialog() PhysicalPrinterDialog::PhysicalPrinterDialog(const wxString& printer_name, int last_selected_preset)
: DPIDialog(NULL, wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) : DPIDialog(NULL, wxID_ANY, _L("PhysicalPrinter"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{ {
SetFont(wxGetApp().normal_font()); SetFont(wxGetApp().normal_font());
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
@ -762,8 +769,9 @@ PhysicalPrinterDialog::PhysicalPrinterDialog()
int border = 10; int border = 10;
int em = em_unit(); int em = em_unit();
printer_text = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); printer_text = new wxTextCtrl(this, wxID_ANY, printer_name, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
printer_presets = new PlaterPresetComboBox(this, Preset::TYPE_PRINTER); printer_presets = new TabPresetComboBox(this, Preset::TYPE_PRINTER, true);
printer_presets->update();
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL); wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);

View file

@ -43,7 +43,6 @@ public:
}; };
void set_label_marker(int item, LabelItemType label_item_type = LABEL_ITEM_MARKER); void set_label_marker(int item, LabelItemType label_item_type = LABEL_ITEM_MARKER);
int em_unit() const { return m_em_unit; }
virtual void update() {}; virtual void update() {};
virtual void msw_rescale(); virtual void msw_rescale();
@ -131,13 +130,13 @@ private:
// --------------------------------- // ---------------------------------
// *** PlaterPresetComboBox *** // *** TabPresetComboBox ***
// --------------------------------- // ---------------------------------
class TabPresetComboBox : public PresetComboBox class TabPresetComboBox : public PresetComboBox
{ {
public: public:
TabPresetComboBox(wxWindow *parent, Preset::Type preset_type); TabPresetComboBox(wxWindow *parent, Preset::Type preset_type, bool is_from_physical_printer = false);
~TabPresetComboBox() {} ~TabPresetComboBox() {}
void set_show_incompatible_presets(bool show_incompatible_presets) { void set_show_incompatible_presets(bool show_incompatible_presets) {
show_incompatible = show_incompatible_presets; show_incompatible = show_incompatible_presets;
@ -165,7 +164,7 @@ class PhysicalPrinterDialog : public DPIDialog
PresetComboBox* printer_presets; PresetComboBox* printer_presets;
public: public:
PhysicalPrinterDialog(); PhysicalPrinterDialog(const wxString& printer_name, int last_selected_preset);
~PhysicalPrinterDialog() {} ~PhysicalPrinterDialog() {}
protected: protected:

View file

@ -815,7 +815,7 @@ void Tab::update_visibility()
void Tab::msw_rescale() void Tab::msw_rescale()
{ {
m_em_unit = wxGetApp().em_unit(); m_em_unit = em_unit(m_parent);
m_mode_sizer->msw_rescale(); m_mode_sizer->msw_rescale();
m_presets_choice->msw_rescale(); m_presets_choice->msw_rescale();
@ -827,6 +827,8 @@ void Tab::msw_rescale()
btn->msw_rescale(); btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps) for (const auto bmp : m_scaled_bitmaps)
bmp->msw_rescale(); bmp->msw_rescale();
for (const auto ikon : m_blinking_ikons)
ikon.second->msw_rescale();
for (ScalableBitmap& bmp : m_mode_bitmap_cache) for (ScalableBitmap& bmp : m_mode_bitmap_cache)
bmp.msw_rescale(); bmp.msw_rescale();