@@ -2052,6 +2052,75 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe)
20522052 wxGetApp ().UpdateDlgDarkUI (this );
20532053}
20542054
2055+ DiffPresetDialog::DiffPresetDialog (wxWindow* parent, Preset::Type type, const std::string &left, const std::string &right)
2056+ : DPIDialog(parent, wxID_ANY, _L(" Compare presets" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
2057+ m_pr_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology())
2058+ {
2059+ m_preset_bundle_left = std::make_unique<PresetBundle>(*wxGetApp ().preset_bundle );
2060+ m_preset_bundle_right = std::make_unique<PresetBundle>(*wxGetApp ().preset_bundle );
2061+
2062+ int border = 10 ;
2063+ int em = em_unit ();
2064+
2065+ m_top_info_line = new wxStaticText (this , wxID_ANY, " " );
2066+ m_bottom_info_line = new wxStaticText (this , wxID_ANY, " " );
2067+
2068+ m_tree = new DiffViewCtrl (this , wxSize (em * 65 , em * 40 ));
2069+ m_tree->AppendBmpTextColumn (" " , DiffModel::colIconText, 35 );
2070+ m_tree->AppendBmpTextColumn (" Left Preset Value" , DiffModel::colOldValue, 15 );
2071+ m_tree->AppendBmpTextColumn (" Right Preset Value" ,DiffModel::colNewValue, 15 );
2072+
2073+ // Create combo boxes for the target type only
2074+ wxFlexGridSizer *presets_sizer = new wxFlexGridSizer (3 , 2 , border, border);
2075+ presets_sizer->AddGrowableCol (0 , 1 );
2076+ presets_sizer->AddGrowableCol (2 , 1 );
2077+
2078+ auto add_preset_combobox = [this , presets_sizer, type](PresetComboBox** cb, PresetBundle* bundle) {
2079+ *cb = new PresetComboBox (this , type);
2080+ (*cb)->set_selection_changed_function ([this ](int ) { update_tree (); });
2081+ (*cb)->SetFont (Label::Body_13);
2082+ presets_sizer->Add (*cb, 1 , wxEXPAND);
2083+ };
2084+
2085+ PresetComboBox *presets_left, *presets_right;
2086+ add_preset_combobox (&presets_left, m_preset_bundle_left.get ());
2087+ auto equal_bmp = new ScalableButton (this , wxID_ANY, " equal" );
2088+ presets_sizer->Add (equal_bmp, 0 , wxALIGN_CENTER);
2089+ add_preset_combobox (&presets_right, m_preset_bundle_right.get ());
2090+ m_preset_combos.push_back ({presets_left, equal_bmp, presets_right});
2091+
2092+ m_show_all_presets = new wxCheckBox (this , wxID_ANY, _L (" Show all presets (including incompatible)" ));
2093+ m_show_all_presets->Bind (wxEVT_CHECKBOX, [this ](wxCommandEvent&) {
2094+ bool show_all = m_show_all_presets->GetValue ();
2095+ for (auto &pc : m_preset_combos) {
2096+ pc.presets_left ->show_all (show_all);
2097+ pc.presets_right ->show_all (show_all);
2098+ }
2099+ update_tree ();
2100+ });
2101+
2102+ wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL);
2103+ topSizer->Add (m_top_info_line, 0 , wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 2 * border);
2104+ topSizer->Add (presets_sizer, 0 , wxEXPAND | wxLEFT | wxTOP | wxRIGHT, border);
2105+ topSizer->Add (m_show_all_presets, 0 , wxEXPAND | wxALL, border);
2106+ topSizer->Add (m_bottom_info_line, 0 , wxEXPAND | wxALL, 2 * border);
2107+ topSizer->Add (m_tree, 1 , wxEXPAND | wxALL, border);
2108+
2109+ this ->SetMinSize (wxSize (80 * em, 30 * em));
2110+ this ->SetSizer (topSizer);
2111+ topSizer->SetSizeHints (this );
2112+
2113+ m_view_type = type;
2114+ update_controls_visibility (type);
2115+
2116+ if (!left.empty ()) presets_left->update (left);
2117+ if (!right.empty ()) presets_right->update (right);
2118+ update_tree ();
2119+
2120+ wxGetApp ().UpdateDlgDarkUI (this );
2121+ CenterOnParent ();
2122+ }
2123+
20552124void DiffPresetDialog::update_controls_visibility (Preset::Type type /* = Preset::TYPE_INVALID*/ )
20562125{
20572126 for (auto preset_combos : m_preset_combos) {
0 commit comments