From 6f67a5bcccadfc74ffbb75f2e05aac6b7424a341 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 6 Mar 2020 14:22:14 +0100 Subject: [PATCH] Fixed : * the editing of extruder color from PresetComboBox, when incompatible filament preset is selected and red flag is shown. *OSX specific bug : empty icons for PresetComboBox had non-scaled width --- src/slic3r/GUI/Plater.cpp | 17 +++++++++++------ src/slic3r/GUI/PresetBundle.cpp | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0ebad64d1c..739a4e50b9 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -296,15 +296,20 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)), if (preset_type == Slic3r::Preset::TYPE_FILAMENT) { Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) { - int shifl_Left = 0; + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + const Preset* selected_preset = preset_bundle->filaments.find_preset(preset_bundle->filament_presets[extruder_idx]); + // Wide icons are shown if the currently selected preset is not compatible with the current printer, + // and red flag is drown in front of the selected preset. + bool wide_icons = selected_preset != nullptr && !selected_preset->is_compatible; float scale = m_em_unit*0.1f; + + int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0; #if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED) - shifl_Left = int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image + shifl_Left += int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image #endif - int icon_right_pos = int(scale * (24+4) + 0.5); + int icon_right_pos = shifl_Left + int(scale * (24+4) + 0.5); int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x; -// if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) { - if ( extruder_idx < 0 || mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) { + if (mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) { // Let the combo box process the mouse click. event.Skip(); return; @@ -333,7 +338,7 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)), cfg_new.set_key_value("extruder_colour", colors); wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new); - wxGetApp().preset_bundle->update_plater_filament_ui(extruder_idx, this); + preset_bundle->update_plater_filament_ui(extruder_idx, this); wxGetApp().plater()->on_config_change(cfg_new); } }); diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 5c9dc2ec9a..3aa947f1b2 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -1599,21 +1599,23 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre // To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so // set a bitmap height to m_bitmapLock->GetHeight() - // Note, under OSX we should use a ScaledHeight because of Retina scale + // + // To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size. + // But for some display scaling (for example 125% or 175%) normal_icon_width differs from icon width. + // So: + // for nonsystem presets set a width of empty bitmap to m_bitmapLock->GetWidth() + // for compatible presets set a width of empty bitmap to m_bitmapIncompatible->GetWidth() + // + // Note, under OSX we should use a Scaled Height/Width because of Retina scale #ifdef __APPLE__ const int icon_height = m_bitmapLock->GetScaledHeight(); + const int lock_icon_width = m_bitmapLock->GetScaledWidth(); + const int flag_icon_width = m_bitmapIncompatible->GetScaledWidth(); #else const int icon_height = m_bitmapLock->GetHeight(); -#endif - - /* To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size. - * But for some display scaling (for example 125% or 175%) normal_icon_width differs from icon width. - * So: - * for nonsystem presets set a width of empty bitmap to m_bitmapLock->GetWidth() - * for compatible presets set a width of empty bitmap to m_bitmapIncompatible->GetWidth() - **/ const int lock_icon_width = m_bitmapLock->GetWidth(); const int flag_icon_width = m_bitmapIncompatible->GetWidth(); +#endif wxString tooltip = "";