Set current filament color to the ColorPicker
This commit is contained in:
parent
8e12189b37
commit
6de5b34312
@ -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<ConfigOptionStrings*>(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<ConfigOptionStrings*>(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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user