diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f3ad9c55d..f2220b3ea 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -274,22 +274,30 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 * } // Swallow the mouse click and open the color picker. + + // get current color + DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config(); + auto colors = static_cast(cfg->option("extruder_colour")->clone()); + wxColour clr(colors->values[extruder_idx]); + if (!clr.IsOk()) + clr = wxTransparentColour; + auto data = new wxColourData(); data->SetChooseFull(1); - auto dialog = new wxColourDialog(/* wxGetApp().mainframe */this, data); - dialog->CenterOnParent(); - if (dialog->ShowModal() == wxID_OK) { - DynamicPrintConfig cfg = *wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config(); + data->SetColour(clr); - //FIXME this is too expensive to call full_config to get just the extruder color! - auto colors = static_cast(wxGetApp().preset_bundle->full_config().option("extruder_colour")->clone()); + auto dialog = new wxColourDialog(this, data); + dialog->CenterOnParent(); + if (dialog->ShowModal() == wxID_OK) + { colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX); - cfg.set_key_value("extruder_colour", colors); + DynamicPrintConfig cfg_new = *cfg; + cfg_new.set_key_value("extruder_colour", colors); - wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg); + wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new); wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this); - wxGetApp().plater()->on_config_change(cfg); + wxGetApp().plater()->on_config_change(cfg_new); } dialog->Destroy(); });