Update wxWidgets to v3.2.1 (#2905)

* Upgrade wxWidgets to 3.2.1
Based on prusa3d/PrusaSlicer@9a7e024

Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>

* Implement BitmapCache

* update wxExtensions while keeping legacy items

* update dc.DrawBitmap calls to use get_bitmap

* Fix GetSize/Width/Height calls

* update BitmapComboBox

* fix ifndef in wxExtensions.hpp

* update my todos to OcraftyoneTODO

* Get to a compilable state
Everything seems to be working (including the plater). I am not seeing any graphical issues

* fix extruder color icons

* fix crash on opening support tab

* remove GetBmpSize method from DropDown.cpp

* Update TextInput to use bitmap bundles

* update a TODO after testing

* fix the rendering of the icons on combobox

* fix a few todos

* fix WipeTowerDialog.cpp

* Overhaul WipeTowerDialog

Removed simple version of the dialog since BBS removed the functionality but left the code.
Center the table (only seen when the table is smaller than the minimum size of the dialog)
Fix issue where editing a value causes the m_min_flush_label to change colors slightly
Fix an issue where changing a value or running an auto calc changes the disabled value from "-" to "0"

* update a few todos

* Update some todos

* Show dropdown when editing is started

* Update NanoSVG.cmake

Update NanoSVG to work with PR #2780

* Dim the icon on ComboBox when disabled

* solve ObjectDataViewModel todos

leaving colPrint and colEditing cases alone as it does not seem to impact anything

* Update names in wxExtensions

-Rename msw_rescale to sys_color_changed
-Replace GetBmpSize, GetBmpWidth, GetBmpHeight with renamed version (same name without "Bmp")

Both of these changes were also made by PrusaSlicer.

Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>

* update BitmapCache::from_svg

disable finding bundle in the cache to match load_svg
update to match values used in load_svg

* Update ScalableButton

change the signature and remove functions/vars pertaining to a default bmp
fix TODOs in ScalableButton

Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>

* fix up some more todos in wxExtensions

* update ScalableBitmap to use bmp bundles

use wxBitmapBundle by default
add flag to use old scaled bitmap function (specifically to solve issue with advanced toggle)

* attempt to fix macos deps build

* fix ubuntu build

* Revert "attempt to fix macos deps build"

Mistakenly made change to wrong file

This reverts commit d9c20b5121.

* update wxWidgets patch

an attempt to fix macOS build

* Remove duplicate variable from OrcaSlicer.cpp

* Fix macOS build issue

* Fix blank DataViewItem being added to objects list

* Filament ComboBox editor updates

-Add show drop down feature to ObjectTable
-Call finish editing when ComboBox is closed in ObjectList

* remove Apple specific declarations missed during refactor

* delete old wxWidgets patch

* fix ubuntu seg fault

* include patch from #2926

* update patch to include wxWidgets/wxWidgets@991a74c

* fix deps not compiling on Windows

* update WipeTowerDialog

relocates the recalculate button back to its previous position
changes the wording of the tip message label
add spacing below the matrix

* finish patching wxWidgets

from prusa3d/PrusaSlicer@f8477d1 and prusa3d/PrusaSlicer@066b567

Co-authored-by: YuSanka <yusanka@gmail.com>

* fix combobox crash

* revert outside plate changes

---------

Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
Ocraftyone 2023-12-04 10:21:49 -05:00 committed by GitHub
parent 0bf65aa217
commit 25a055491e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 1639 additions and 6221 deletions

View file

@ -229,8 +229,6 @@ void Tab::create_preset_tab()
// add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
m_show_incompatible_presets = false;
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green");
//add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name());
@ -395,7 +393,7 @@ void Tab::create_preset_tab()
#endif
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
const float scale_factor = em_unit(this)*0.1;// GetContentScaleFactor();
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
@ -444,11 +442,8 @@ void Tab::create_preset_tab()
m_tabctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable right select
m_tabctrl->SetFont(Label::Body_14);
//m_left_sizer->Add(m_tabctrl, 1, wxEXPAND);
const int img_sz = int(32 * scale_factor + 0.5f);
m_icons = new wxImageList(img_sz, img_sz, false, 1);
// Index of the last icon inserted into $self->{icons}.
// Index of the last icon inserted into m_tabctrl.
m_icon_count = -1;
m_tabctrl->AssignImageList(m_icons);
wxGetApp().UpdateDarkUI(m_tabctrl);
// Delay processing of the following handler until the message queue is flushed.
@ -526,6 +521,22 @@ void Tab::create_preset_tab()
// Initialize the DynamicPrintConfig by default keys/values.
build();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
// This instance was added by PS when updating wx
/* if (!m_scaled_icons_list.empty()) {
// update icons for tree_ctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);
}*/
// ys_FIXME: Following should not be needed, the function will be called later
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
// second call of rebuild_page_tree m_tabctrl->GetFirstVisibleItem(); returns zero
@ -541,7 +552,7 @@ void Tab::add_scaled_button(wxWindow* parent,
const wxString& label/* = wxEmptyString*/,
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
{
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style, true);
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
(*btn)->SetBackgroundColour(parent->GetBackgroundColour());
m_scaled_buttons.push_back(*btn);
}
@ -572,7 +583,6 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
if (icon_idx == -1) {
// Add a new icon to the icon list.
m_scaled_icons_list.push_back(ScalableBitmap(this, icon, 32, false, true));
//m_icons->Add(m_scaled_icons_list.back().bmp());
icon_idx = ++m_icon_count;
m_icon_index[icon] = icon_idx;
}
@ -887,18 +897,6 @@ void TabPrinter::init_options_list()
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabPrinter::msw_rescale()
{
Tab::msw_rescale();
if (m_reset_to_filament_color)
m_reset_to_filament_color->msw_rescale();
//BBS: GUI refactor
//Layout();
m_parent->Layout();
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
@ -1174,35 +1172,30 @@ void Tab::msw_rescale()
m_top_sizer->SetMinSize(-1, 3 * m_em_unit);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
if (m_presets_choice)
m_presets_choice->msw_rescale();
m_tabctrl->SetMinSize(wxSize(20 * m_em_unit, -1));
// rescale buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->msw_rescale();
bmp->sys_color_changed();
if (m_mode_view)
m_mode_view->Rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->msw_rescale();
m_detach_preset_btn->sys_color_changed();
// rescale icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// rescale options_groups
if (m_active_page)
@ -1222,21 +1215,24 @@ void Tab::sys_color_changed()
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->msw_rescale();
btn->sys_color_changed();
for (const auto bmp : m_scaled_bitmaps)
bmp->msw_rescale();
bmp->sys_color_changed();
if (m_detach_preset_btn)
m_detach_preset_btn->msw_rescale();
m_detach_preset_btn->sys_color_changed();
// update icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
update_show_hide_incompatible_button();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// Colors for ui "decoration"
update_label_colours();
@ -1244,7 +1240,7 @@ void Tab::sys_color_changed()
wxWindowUpdateLocker noUpdates(this);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
// m_mode_sizer->sys_color_changed();
wxGetApp().UpdateDarkUI(this);
wxGetApp().UpdateDarkUI(m_tabctrl);
#endif
@ -1257,6 +1253,7 @@ void Tab::sys_color_changed()
//BBS: GUI refactor
//Layout();
m_parent->Layout();
m_parent->Refresh();
}
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1737,7 +1734,7 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
auto detach_preset_btn = [this](wxWindow* parent) {
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_normal_sys", "",
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -2197,7 +2194,7 @@ void TabPrint::build()
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced.png");
//page = add_options_page(L("Dependencies"), "advanced");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -3607,7 +3604,7 @@ void TabPrinter::build_sla()
//optgroup->append_single_option_line("min_initial_exposure_time");
//optgroup->append_single_option_line("max_initial_exposure_time");
//page = add_options_page(L("Dependencies"), "wrench.png");
//page = add_options_page(L("Dependencies"), "wrench");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//build_preset_description_line(optgroup.get());
@ -3879,7 +3876,7 @@ if (is_marlin_flavor)
//auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
// m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
// ScalableButton* btn = m_reset_to_filament_color;
// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// btn->SetSize(btn->GetBestSize());
@ -5242,8 +5239,7 @@ void Tab::toggle_show_hide_incompatible()
void Tab::update_show_hide_incompatible_button()
{
//BBS: GUI refactor
/*m_btn_hide_incompatible_presets->SetBitmap_(m_show_incompatible_presets ?
m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets);
/*m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
"Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");*/
@ -5290,7 +5286,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
@ -5365,7 +5361,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
@ -5783,7 +5779,7 @@ void TabSLAMaterial::build()
//optgroup->append_line(line);
//page = add_options_page(L("Dependencies"), "wrench.png");
//page = add_options_page(L("Dependencies"), "wrench");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -5804,7 +5800,7 @@ void TabSLAMaterial::build()
//build_preset_description_line(optgroup.get());
//page = add_options_page(L("Material printing profile"), "printer.png");
//page = add_options_page(L("Material printing profile"), "printer");
//optgroup = page->new_optgroup(L("Material printing profile"));
//option = optgroup->get_option("material_print_speed");
//optgroup->append_single_option_line(option);