Linux specific: Using a pop-up menu on the "cog" wheel for changing of an extruder color.(related to #6759)
+ some code refactoring + change a little bit gray color in colorchange_del icons to avoid collision in Dark mode
This commit is contained in:
parent
9c35e0cb75
commit
8ef03718d0
@ -4,7 +4,7 @@
|
|||||||
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||||
<g id="hex_x5F_X">
|
<g id="hex_x5F_X">
|
||||||
<g>
|
<g>
|
||||||
<polygon fill="#808080" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
<polygon fill="#818181" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
||||||
</g>
|
</g>
|
||||||
<g id="plus_2_">
|
<g id="plus_2_">
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 782 B |
@ -4,7 +4,7 @@
|
|||||||
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||||
<g id="hex_x5F_X">
|
<g id="hex_x5F_X">
|
||||||
<g>
|
<g>
|
||||||
<polygon fill="#808080" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
<polygon fill="#818181" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
||||||
</g>
|
</g>
|
||||||
<g id="plus_2_">
|
<g id="plus_2_">
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 786 B |
@ -573,31 +573,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Swallow the mouse click and open the color picker.
|
// Swallow the mouse click and open the color picker.
|
||||||
|
change_extruder_color();
|
||||||
// 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[m_extruder_idx]);
|
|
||||||
if (!clr.IsOk())
|
|
||||||
clr = wxColour(0,0,0); // Don't set alfa to transparence
|
|
||||||
|
|
||||||
auto data = new wxColourData();
|
|
||||||
data->SetChooseFull(1);
|
|
||||||
data->SetColour(clr);
|
|
||||||
|
|
||||||
wxColourDialog dialog(this, data);
|
|
||||||
dialog.CenterOnParent();
|
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
|
||||||
{
|
|
||||||
colors->values[m_extruder_idx] = dialog.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
|
|
||||||
|
|
||||||
DynamicPrintConfig cfg_new = *cfg;
|
|
||||||
cfg_new.set_key_value("extruder_colour", colors);
|
|
||||||
|
|
||||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
|
|
||||||
this->update();
|
|
||||||
wxGetApp().plater()->on_config_change(cfg_new);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,28 +583,15 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
|||||||
edit_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent)
|
edit_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent)
|
||||||
{
|
{
|
||||||
// In a case of a physical printer, for its editing open PhysicalPrinterDialog
|
// In a case of a physical printer, for its editing open PhysicalPrinterDialog
|
||||||
if (m_type == Preset::TYPE_PRINTER/* && this->is_selected_physical_printer()*/) {
|
if (m_type == Preset::TYPE_PRINTER
|
||||||
this->show_edit_menu();
|
#ifdef __linux__
|
||||||
return;
|
// To edit extruder color from the sidebar
|
||||||
}
|
|| m_type == Preset::TYPE_FILAMENT
|
||||||
|
#endif //__linux__
|
||||||
if (!switch_to_tab())
|
)
|
||||||
return;
|
show_edit_menu();
|
||||||
|
else
|
||||||
/* In a case of a multi-material printing, for editing another Filament Preset
|
switch_to_tab();
|
||||||
* it's needed to select this preset for the "Filament settings" Tab
|
|
||||||
*/
|
|
||||||
if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
|
|
||||||
{
|
|
||||||
const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
|
|
||||||
|
|
||||||
// Call select_preset() only if there is new preset and not just modified
|
|
||||||
if ( !boost::algorithm::ends_with(selected_preset, Preset::suffix_modified()) )
|
|
||||||
{
|
|
||||||
const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
|
|
||||||
wxGetApp().get_tab(m_type)->select_preset(preset_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,20 +635,59 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
|||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlaterPresetComboBox::switch_to_tab()
|
void PlaterPresetComboBox::switch_to_tab()
|
||||||
{
|
{
|
||||||
Tab* tab = wxGetApp().get_tab(m_type);
|
Tab* tab = wxGetApp().get_tab(m_type);
|
||||||
if (!tab)
|
if (!tab)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
int page_id = wxGetApp().tab_panel()->FindPage(tab);
|
if (int page_id = wxGetApp().tab_panel()->FindPage(tab); page_id != wxNOT_FOUND)
|
||||||
if (page_id == wxNOT_FOUND)
|
{
|
||||||
return false;
|
wxGetApp().tab_panel()->SetSelection(page_id);
|
||||||
|
// Switch to Settings NotePad
|
||||||
|
wxGetApp().mainframe->select_tab();
|
||||||
|
|
||||||
wxGetApp().tab_panel()->SetSelection(page_id);
|
//In a case of a multi-material printing, for editing another Filament Preset
|
||||||
// Switch to Settings NotePad
|
//it's needed to select this preset for the "Filament settings" Tab
|
||||||
wxGetApp().mainframe->select_tab();
|
if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
|
||||||
return true;
|
{
|
||||||
|
const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
|
||||||
|
// Call select_preset() only if there is new preset and not just modified
|
||||||
|
if (!boost::algorithm::ends_with(selected_preset, Preset::suffix_modified()))
|
||||||
|
{
|
||||||
|
const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
|
||||||
|
wxGetApp().get_tab(m_type)->select_preset(preset_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlaterPresetComboBox::change_extruder_color()
|
||||||
|
{
|
||||||
|
// 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[m_extruder_idx]);
|
||||||
|
if (!clr.IsOk())
|
||||||
|
clr = wxColour(0, 0, 0); // Don't set alfa to transparence
|
||||||
|
|
||||||
|
auto data = new wxColourData();
|
||||||
|
data->SetChooseFull(1);
|
||||||
|
data->SetColour(clr);
|
||||||
|
|
||||||
|
wxColourDialog dialog(this, data);
|
||||||
|
dialog.CenterOnParent();
|
||||||
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
|
colors->values[m_extruder_idx] = dialog.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
|
||||||
|
|
||||||
|
DynamicPrintConfig cfg_new = *cfg;
|
||||||
|
cfg_new.set_key_value("extruder_colour", colors);
|
||||||
|
|
||||||
|
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
|
||||||
|
this->update();
|
||||||
|
wxGetApp().plater()->on_config_change(cfg_new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaterPresetComboBox::show_add_menu()
|
void PlaterPresetComboBox::show_add_menu()
|
||||||
@ -714,6 +716,16 @@ void PlaterPresetComboBox::show_edit_menu()
|
|||||||
append_menu_item(menu, wxID_ANY, _L("Edit preset"), "",
|
append_menu_item(menu, wxID_ANY, _L("Edit preset"), "",
|
||||||
[this](wxCommandEvent&) { this->switch_to_tab(); }, "cog", menu, []() { return true; }, wxGetApp().plater());
|
[this](wxCommandEvent&) { this->switch_to_tab(); }, "cog", menu, []() { return true; }, wxGetApp().plater());
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
// To edit extruder color from the sidebar
|
||||||
|
if (m_type == Preset::TYPE_FILAMENT) {
|
||||||
|
append_menu_item(menu, wxID_ANY, _L("Change extruder color"), "",
|
||||||
|
[this](wxCommandEvent&) { this->change_extruder_color(); }, "funnel", menu, []() { return true; }, wxGetApp().plater());
|
||||||
|
wxGetApp().plater()->PopupMenu(menu);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif //__linux__
|
||||||
|
|
||||||
if (this->is_selected_physical_printer()) {
|
if (this->is_selected_physical_printer()) {
|
||||||
append_menu_item(menu, wxID_ANY, _L("Edit physical printer"), "",
|
append_menu_item(menu, wxID_ANY, _L("Edit physical printer"), "",
|
||||||
[this](wxCommandEvent&) { this->edit_physical_printer(); }, "cog", menu, []() { return true; }, wxGetApp().plater());
|
[this](wxCommandEvent&) { this->edit_physical_printer(); }, "cog", menu, []() { return true; }, wxGetApp().plater());
|
||||||
|
@ -147,7 +147,8 @@ public:
|
|||||||
void set_extruder_idx(const int extr_idx) { m_extruder_idx = extr_idx; }
|
void set_extruder_idx(const int extr_idx) { m_extruder_idx = extr_idx; }
|
||||||
int get_extruder_idx() const { return m_extruder_idx; }
|
int get_extruder_idx() const { return m_extruder_idx; }
|
||||||
|
|
||||||
bool switch_to_tab();
|
void switch_to_tab();
|
||||||
|
void change_extruder_color();
|
||||||
void show_add_menu();
|
void show_add_menu();
|
||||||
void show_edit_menu();
|
void show_edit_menu();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user