From d218154b218adf52fccf702b2511da2b6348f8ca Mon Sep 17 00:00:00 2001 From: Simon Judd Date: Sat, 1 Jun 2024 01:24:19 +0930 Subject: [PATCH] Remove wxutil::scaledSize/Point/Rect Again replace with FromDIP where applicable --- src/MainEditor/UI/MainWindow.cpp | 12 +++---- src/MainEditor/UI/StartPanel.cpp | 2 +- .../UI/TextureXEditor/TextureEditorPanel.cpp | 2 +- .../UI/TextureXEditor/ZTextureEditorPanel.cpp | 2 +- src/MapEditor/UI/ArgsPanel.cpp | 7 ++-- src/MapEditor/UI/Dialogs/ShowItemDialog.cpp | 2 +- src/MapEditor/UI/MapEditorWindow.cpp | 27 ++++++++------- src/MapEditor/UI/ObjectEditPanel.cpp | 2 +- .../UI/PropsPanel/SectorPropsPanel.cpp | 2 +- .../UI/PropsPanel/SidePropsPanel.cpp | 4 +-- .../UI/PropsPanel/ThingPropsPanel.cpp | 2 +- src/MapEditor/UI/ScriptEditorPanel.cpp | 4 +-- src/MapEditor/UI/SectorSpecialPanel.cpp | 4 +-- src/Scripting/UI/ScriptManagerWindow.cpp | 8 ++--- src/TextEditor/UI/SCallTip.cpp | 5 ++- src/UI/Browser/BrowserWindow.cpp | 2 +- src/UI/Controls/BaseResourceChooser.cpp | 20 ++++++----- src/UI/Controls/ColourBox.cpp | 7 ++-- src/UI/Controls/ResourceArchiveChooser.cpp | 2 +- src/UI/Controls/SZoomSlider.cpp | 2 +- src/UI/Dialogs/GfxCropDialog.cpp | 2 +- src/UI/WxUtils.cpp | 33 ------------------- src/UI/WxUtils.h | 5 --- 23 files changed, 59 insertions(+), 99 deletions(-) diff --git a/src/MainEditor/UI/MainWindow.cpp b/src/MainEditor/UI/MainWindow.cpp index 4ff3f7db4..94787d473 100644 --- a/src/MainEditor/UI/MainWindow.cpp +++ b/src/MainEditor/UI/MainWindow.cpp @@ -223,9 +223,9 @@ void MainWindow::setupLayout() // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Float(); - p_inf.FloatingSize(wxutil::scaledSize(600, 400)); - p_inf.FloatingPosition(wxutil::scaledPoint(100, 100)); - p_inf.MinSize(wxutil::scaledSize(-1, 192)); + p_inf.FloatingSize(FromDIP(wxSize(600, 400))); + p_inf.FloatingPosition(FromDIP(wxPoint(100, 100))); + p_inf.MinSize(FromDIP(wxSize(-1, 192))); p_inf.Show(false); p_inf.Caption("Console"); p_inf.Name("console"); @@ -238,7 +238,7 @@ void MainWindow::setupLayout() // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Left(); - p_inf.BestSize(wxutil::scaledSize(192, 480)); + p_inf.BestSize(FromDIP(wxSize(192, 480))); p_inf.Caption("Archive Manager"); p_inf.Name("archive_manager"); p_inf.Show(true); @@ -252,7 +252,7 @@ void MainWindow::setupLayout() // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Right(); - p_inf.BestSize(wxutil::scaledSize(128, 480)); + p_inf.BestSize(FromDIP(wxSize(128, 480))); p_inf.Caption("Undo History"); p_inf.Name("undo_history"); p_inf.Show(false); @@ -556,7 +556,7 @@ bool MainWindow::handleAction(string_view id) auto m_mgr = wxAuiManager::GetManager(panel_archivemanager_); auto& p_inf = m_mgr->GetPane("console"); p_inf.Show(!p_inf.IsShown()); - p_inf.MinSize(wxutil::scaledSize(200, 128)); + p_inf.MinSize(FromDIP(wxSize(200, 128))); dynamic_cast(p_inf.window)->focusInput(); m_mgr->Update(); return true; diff --git a/src/MainEditor/UI/StartPanel.cpp b/src/MainEditor/UI/StartPanel.cpp index 8d382c88f..df9e027c9 100644 --- a/src/MainEditor/UI/StartPanel.cpp +++ b/src/MainEditor/UI/StartPanel.cpp @@ -76,7 +76,7 @@ namespace wxBitmapBundle getIconBitmapBundle(string_view icon, int size) { auto svg_entry = app::archiveManager().programResourceArchive()->entryAtPath(fmt::format("icons/{}", icon)); - return wxBitmapBundle::FromSVG(reinterpret_cast(svg_entry->rawData()), wxutil::scaledSize(size, size)); + return wxBitmapBundle::FromSVG(reinterpret_cast(svg_entry->rawData()), { size, size }); } // ----------------------------------------------------------------------------- diff --git a/src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp b/src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp index 5d6bb2c94..f77ae6ab6 100644 --- a/src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp +++ b/src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp @@ -320,7 +320,7 @@ wxPanel* TextureEditorPanel::createPatchControls(wxWindow* parent) tb_patches_->findActionButton("txed_patch_add")->Enable(); // Layout - list_patches_->SetInitialSize(wxutil::scaledSize(100, tb_patches_->group("_Patch")->GetBestSize().y)); + list_patches_->SetInitialSize({ FromDIP(100), tb_patches_->group("_Patch")->GetBestSize().y }); framesizer->Add(list_patches_, wx::sfWithBorder(1, wxLEFT | wxTOP | wxBOTTOM).Expand()); framesizer->Add(tb_patches_, wx::sfWithMinBorder(0, wxLEFT | wxTOP | wxBOTTOM).Expand()); diff --git a/src/MainEditor/UI/TextureXEditor/ZTextureEditorPanel.cpp b/src/MainEditor/UI/TextureXEditor/ZTextureEditorPanel.cpp index 2d22bbaba..a82b18bbc 100644 --- a/src/MainEditor/UI/TextureXEditor/ZTextureEditorPanel.cpp +++ b/src/MainEditor/UI/TextureXEditor/ZTextureEditorPanel.cpp @@ -249,7 +249,7 @@ wxPanel* ZTextureEditorPanel::createPatchControls(wxWindow* parent) tb_patches_->findActionButton("txed_patch_add")->Enable(); // Layout - list_patches_->SetInitialSize(wxutil::scaledSize(100, tb_patches_->group("_Patch")->GetBestSize().y)); + list_patches_->SetInitialSize({ FromDIP(100), tb_patches_->group("_Patch")->GetBestSize().y }); framesizer->Add(list_patches_, wx::sfWithBorder(1, wxLEFT | wxTOP | wxBOTTOM).Expand()); framesizer->Add(tb_patches_, wx::sfWithMinBorder(0, wxLEFT | wxTOP | wxBOTTOM).Expand()); diff --git a/src/MapEditor/UI/ArgsPanel.cpp b/src/MapEditor/UI/ArgsPanel.cpp index 48baa259c..44a7c6a40 100644 --- a/src/MapEditor/UI/ArgsPanel.cpp +++ b/src/MapEditor/UI/ArgsPanel.cpp @@ -33,7 +33,6 @@ #include "ArgsPanel.h" #include "Game/Args.h" #include "General/UI.h" -#include "UI/WxUtils.h" using namespace slade; @@ -74,7 +73,7 @@ class ArgsTextControl : public ArgsControl public: ArgsTextControl(wxWindow* parent, const game::Arg& arg, bool limit_byte) : ArgsControl(parent, arg) { - text_control_ = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxutil::scaledSize(40, -1)); + text_control_ = new wxTextCtrl(this, -1, "", wxDefaultPosition, FromDIP(wxSize(40, -1))); if (limit_byte) text_control_->SetValidator(wxIntegerValidator()); else @@ -147,7 +146,7 @@ class ArgsChoiceControl : public ArgsControl public: ArgsChoiceControl(wxWindow* parent, const game::Arg& arg) : ArgsControl(parent, arg) { - choice_control_ = new wxComboBox(this, -1, "", wxDefaultPosition, wxutil::scaledSize(100, -1)); + choice_control_ = new wxComboBox(this, -1, "", wxDefaultPosition, FromDIP(wxSize(100, -1))); choice_control_->SetValidator(ComboBoxAwareIntegerValidator()); for (const auto& custom_value : arg.custom_values) @@ -494,7 +493,7 @@ ArgsPanel::ArgsPanel(wxWindow* parent) : wxScrolled{ parent, -1, wxDefa { label_args_[a] = new wxStaticText(this, -1, ""); control_args_[a] = nullptr; - label_args_desc_[a] = new wxStaticText(this, -1, "", wxDefaultPosition, wxutil::scaledSize(100, -1)); + label_args_desc_[a] = new wxStaticText(this, -1, "", wxDefaultPosition, FromDIP(wxSize(100, -1))); } // Set up vertical scrollbar diff --git a/src/MapEditor/UI/Dialogs/ShowItemDialog.cpp b/src/MapEditor/UI/Dialogs/ShowItemDialog.cpp index 2d08d057e..5d67c6272 100644 --- a/src/MapEditor/UI/Dialogs/ShowItemDialog.cpp +++ b/src/MapEditor/UI/Dialogs/ShowItemDialog.cpp @@ -90,7 +90,7 @@ ShowItemDialog::ShowItemDialog(wxWindow* parent) : wxDialog(parent, -1, "Show It // Init layout gb_sizer->AddGrowableCol(1, 1); - SetInitialSize(wxutil::scaledSize(300, -1)); + SetInitialSize({ FromDIP(300), -1 }); CenterOnParent(); wxTopLevelWindowBase::Layout(); text_index_->SetFocus(); diff --git a/src/MapEditor/UI/MapEditorWindow.cpp b/src/MapEditor/UI/MapEditorWindow.cpp index cbdbfad60..77b0b289d 100644 --- a/src/MapEditor/UI/MapEditorWindow.cpp +++ b/src/MapEditor/UI/MapEditorWindow.cpp @@ -65,7 +65,6 @@ #include "UI/Dialogs/RunDialog.h" #include "UI/SAuiTabArt.h" #include "UI/SToolBar/SToolBar.h" -#include "UI/WxUtils.h" #include "Utility/SFileDialog.h" #include "Utility/Tokenizer.h" @@ -384,10 +383,10 @@ void MapEditorWindow::setupLayout() p_inf.DefaultPane(); p_inf.Bottom(); p_inf.Dock(); - p_inf.BestSize(wxutil::scaledSize(480, 192)); - p_inf.FloatingSize(wxutil::scaledSize(600, 400)); + p_inf.BestSize(FromDIP(wxSize(480, 192))); + p_inf.FloatingSize(FromDIP(wxSize(600, 400))); p_inf.FloatingPosition(100, 100); - p_inf.MinSize(wxutil::scaledSize(-1, 192)); + p_inf.MinSize(FromDIP(wxSize(-1, 192))); p_inf.Show(false); p_inf.Caption("Console"); p_inf.Name("console"); @@ -399,10 +398,10 @@ void MapEditorWindow::setupLayout() // Setup panel info & add panel p_inf.Right(); - p_inf.BestSize(wxutil::scaledSize(256, 256)); - p_inf.FloatingSize(wxutil::scaledSize(400, 600)); + p_inf.BestSize(FromDIP(wxSize(256, 256))); + p_inf.FloatingSize(FromDIP(wxSize(400, 600))); p_inf.FloatingPosition(120, 120); - p_inf.MinSize(wxutil::scaledSize(256, 256)); + p_inf.MinSize(FromDIP(wxSize(256, 256))); p_inf.Show(true); p_inf.Caption("Item Properties"); p_inf.Name("item_props"); @@ -414,10 +413,10 @@ void MapEditorWindow::setupLayout() // Setup panel info & add panel p_inf.Float(); - p_inf.BestSize(wxutil::scaledSize(300, 300)); - p_inf.FloatingSize(wxutil::scaledSize(500, 400)); + p_inf.BestSize(FromDIP(wxSize(300, 300))); + p_inf.FloatingSize(FromDIP(wxSize(500, 400))); p_inf.FloatingPosition(150, 150); - p_inf.MinSize(wxutil::scaledSize(300, 300)); + p_inf.MinSize(FromDIP(wxSize(300, 300))); p_inf.Show(false); p_inf.Caption("Script Editor"); p_inf.Name("script_editor"); @@ -493,7 +492,7 @@ void MapEditorWindow::setupLayout() // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Right(); - p_inf.BestSize(wxutil::scaledSize(128, 480)); + p_inf.BestSize(FromDIP(wxSize(128, 480))); p_inf.Caption("Undo History"); p_inf.Name("undo_history"); p_inf.Show(false); @@ -1277,7 +1276,7 @@ bool MapEditorWindow::handleAction(string_view id) p_inf.Show(!p_inf.IsShown()); map_canvas_->SetFocus(); - p_inf.MinSize(wxutil::scaledSize(256, 256)); + p_inf.MinSize(FromDIP(wxSize(256, 256))); m_mgr->Update(); return true; } @@ -1301,7 +1300,7 @@ bool MapEditorWindow::handleAction(string_view id) dynamic_cast(p_inf.window)->focusInput(); } - p_inf.MinSize(wxutil::scaledSize(200, 128)); + p_inf.MinSize(FromDIP(wxSize(200, 128))); m_mgr->Update(); return true; } @@ -1325,7 +1324,7 @@ bool MapEditorWindow::handleAction(string_view id) dynamic_cast(p_inf.window)->updateUI(); } - p_inf.MinSize(wxutil::scaledSize(200, 128)); + p_inf.MinSize(FromDIP(wxSize(200, 128))); m_mgr->Update(); return true; } diff --git a/src/MapEditor/UI/ObjectEditPanel.cpp b/src/MapEditor/UI/ObjectEditPanel.cpp index d055ba211..6001c4148 100644 --- a/src/MapEditor/UI/ObjectEditPanel.cpp +++ b/src/MapEditor/UI/ObjectEditPanel.cpp @@ -58,7 +58,7 @@ ObjectEditPanel::ObjectEditPanel(wxWindow* parent) : wxPanel(parent) wxIntegerValidator val_int(nullptr, wxNUM_VAL_DEFAULT); wxIntegerValidator val_uint(nullptr, wxNUM_VAL_DEFAULT); wxFloatingPointValidator val_double(2, nullptr, wxNUM_VAL_DEFAULT); - auto tb_size = wxutil::scaledSize(64, -1); + auto tb_size = FromDIP(wxSize(64, -1)); // Create controls text_xoff_ = new wxTextCtrl(this, -1, "", wxDefaultPosition, tb_size, 0, val_int); diff --git a/src/MapEditor/UI/PropsPanel/SectorPropsPanel.cpp b/src/MapEditor/UI/PropsPanel/SectorPropsPanel.cpp index 9d5076ce3..2f056d8ff 100644 --- a/src/MapEditor/UI/PropsPanel/SectorPropsPanel.cpp +++ b/src/MapEditor/UI/PropsPanel/SectorPropsPanel.cpp @@ -82,7 +82,7 @@ FlatTexCanvas::FlatTexCanvas(wxWindow* parent) : GLCanvas(parent, BGStyle::Check { // Init variables wxWindow::SetWindowStyleFlag(wxBORDER_SIMPLE); - SetInitialSize(wxutil::scaledSize(136, 136)); + SetInitialSize(FromDIP(wxSize(136, 136))); } // ----------------------------------------------------------------------------- diff --git a/src/MapEditor/UI/PropsPanel/SidePropsPanel.cpp b/src/MapEditor/UI/PropsPanel/SidePropsPanel.cpp index 16bb41707..b2aab5ac0 100644 --- a/src/MapEditor/UI/PropsPanel/SidePropsPanel.cpp +++ b/src/MapEditor/UI/PropsPanel/SidePropsPanel.cpp @@ -61,7 +61,7 @@ class slade::SideTexCanvas : public GLCanvas SideTexCanvas(wxWindow* parent) : GLCanvas(parent) { wxWindow::SetWindowStyleFlag(wxBORDER_SIMPLE); - SetInitialSize(wxutil::scaledSize(136, 136)); + SetInitialSize(FromDIP(wxSize(136, 136))); } ~SideTexCanvas() override = default; @@ -123,7 +123,7 @@ class slade::TextureComboBox : public wxComboBox TextureComboBox(wxWindow* parent) : wxComboBox(parent, -1) { // Init - SetInitialSize(wxutil::scaledSize(136, -1)); + SetInitialSize({ FromDIP(136), -1 }); wxArrayString list; list.Add("-"); diff --git a/src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp b/src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp index 8cea8a16a..092d1a6a5 100644 --- a/src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp +++ b/src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp @@ -98,7 +98,7 @@ class slade::SpriteTexCanvas : public GLCanvas SpriteTexCanvas(wxWindow* parent) : GLCanvas(parent) { wxWindow::SetWindowStyleFlag(wxBORDER_SIMPLE); - SetInitialSize(wxutil::scaledSize(128, 128)); + SetInitialSize(FromDIP(wxSize(128, 128))); } ~SpriteTexCanvas() override = default; diff --git a/src/MapEditor/UI/ScriptEditorPanel.cpp b/src/MapEditor/UI/ScriptEditorPanel.cpp index fb860109d..7d86bd5b7 100644 --- a/src/MapEditor/UI/ScriptEditorPanel.cpp +++ b/src/MapEditor/UI/ScriptEditorPanel.cpp @@ -93,7 +93,7 @@ ScriptEditorPanel::ScriptEditorPanel(wxWindow* parent) : // Jump To toolbar group auto group_jump_to = new SToolBarGroup(toolbar, "Jump To", true); - choice_jump_to_ = new wxChoice(group_jump_to, -1, wxDefaultPosition, wxutil::scaledSize(200, -1)); + choice_jump_to_ = new wxChoice(group_jump_to, -1, wxDefaultPosition, FromDIP(wxSize(200, -1))); group_jump_to->addCustomControl(choice_jump_to_); toolbar->addGroup(group_jump_to); @@ -132,7 +132,7 @@ ScriptEditorPanel::ScriptEditorPanel(wxWindow* parent) : // Add function/constants list list_words_ = new wxTreeListCtrl(this, -1); - list_words_->SetInitialSize(wxutil::scaledSize(200, -10)); + list_words_->SetInitialSize(FromDIP(wxSize(200, -1))); hbox->Add(list_words_, wxutil::sfWithBorder().Expand()); populateWordList(); list_words_->Show(script_show_language_list); diff --git a/src/MapEditor/UI/SectorSpecialPanel.cpp b/src/MapEditor/UI/SectorSpecialPanel.cpp index 603451b40..fb9530d1c 100644 --- a/src/MapEditor/UI/SectorSpecialPanel.cpp +++ b/src/MapEditor/UI/SectorSpecialPanel.cpp @@ -92,7 +92,7 @@ SectorSpecialPanel::SectorSpecialPanel(wxWindow* parent) : wxPanel(parent, -1) lv_specials_->updateSize(); // Boom Flags - int width = FromDIP(300); + int width = 300; if (game::configuration().supportsSectorFlags()) { frame = new wxStaticBox(this, -1, "Flags"); @@ -134,7 +134,7 @@ SectorSpecialPanel::SectorSpecialPanel(wxWindow* parent) : wxPanel(parent, -1) width = -1; } - wxWindowBase::SetMinSize(wx::scaledSize(width, 300)); + wxWindowBase::SetMinSize(FromDIP(wxSize(width, 300))); } // ----------------------------------------------------------------------------- diff --git a/src/Scripting/UI/ScriptManagerWindow.cpp b/src/Scripting/UI/ScriptManagerWindow.cpp index 5eeb9c4dd..33293e3ca 100644 --- a/src/Scripting/UI/ScriptManagerWindow.cpp +++ b/src/Scripting/UI/ScriptManagerWindow.cpp @@ -301,7 +301,7 @@ void ScriptManagerWindow::setupLayout() // -- Scripts Panel -- p_inf.DefaultPane(); p_inf.Left(); - p_inf.BestSize(wxutil::scaledSize(256, 480)); + p_inf.BestSize(FromDIP(wxSize(256, 480))); p_inf.Caption("Scripts"); p_inf.Name("scripts_area"); p_inf.Show(true); @@ -314,9 +314,9 @@ void ScriptManagerWindow::setupLayout() // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Float(); - p_inf.FloatingSize(wxutil::scaledSize(600, 400)); + p_inf.FloatingSize(FromDIP(wxSize(600, 400))); p_inf.FloatingPosition(100, 100); - p_inf.MinSize(wxutil::scaledSize(-1, 192)); + p_inf.MinSize(FromDIP(wxSize(-1, 192))); p_inf.Show(false); p_inf.Caption("Console"); p_inf.Name("console"); @@ -510,7 +510,7 @@ wxPanel* ScriptManagerWindow::setupScriptTreePanel() panel, -1, wxDefaultPosition, - wxutil::scaledSize(200, -1), + FromDIP(wxSize(200, -1)), wxTR_DEFAULT_STYLE | wxTR_NO_LINES | wxTR_HIDE_ROOT | wxTR_FULL_ROW_HIGHLIGHT); tree_scripts_->EnableSystemTheme(true); tree_scripts_->SetImageList(createTreeImageList()); diff --git a/src/TextEditor/UI/SCallTip.cpp b/src/TextEditor/UI/SCallTip.cpp index b7848f730..67d4d3e98 100644 --- a/src/TextEditor/UI/SCallTip.cpp +++ b/src/TextEditor/UI/SCallTip.cpp @@ -31,7 +31,6 @@ // ----------------------------------------------------------------------------- #include "Main.h" #include "SCallTip.h" -#include "UI/WxUtils.h" #include "Utility/Colour.h" using namespace slade; @@ -510,8 +509,8 @@ wxSize SCallTip::drawCallTip(wxDC& dc, int xoff, int yoff) &rect_btn_down_); left = rect_btn_down_.GetRight() + FromDIP(8); - rect_btn_up_.Offset(wxutil::scaledPoint(12, 8)); - rect_btn_down_.Offset(wxutil::scaledPoint(12, 8)); + rect_btn_up_.Offset(FromDIP(wxPoint(12, 8))); + rect_btn_down_.Offset(FromDIP(wxPoint(12, 8))); // Draw function (current context) rect = drawFunctionContext(dc, context_, left, yoff, wxcol_faded, bold); diff --git a/src/UI/Browser/BrowserWindow.cpp b/src/UI/Browser/BrowserWindow.cpp index 72d113701..a82c59c14 100644 --- a/src/UI/Browser/BrowserWindow.cpp +++ b/src/UI/Browser/BrowserWindow.cpp @@ -285,7 +285,7 @@ BrowserWindow::BrowserWindow(wxWindow* parent, bool truncate_names) : canvas_->Bind(wxEVT_CHAR, &BrowserWindow::onCanvasKeyChar, this); wxWindowBase::Layout(); - wxTopLevelWindowBase::SetMinSize(wxutil::scaledSize(540, 400)); + wxTopLevelWindowBase::SetMinSize(FromDIP(wxSize(540, 400))); if (browser_maximised) wxTopLevelWindow::Maximize(); diff --git a/src/UI/Controls/BaseResourceChooser.cpp b/src/UI/Controls/BaseResourceChooser.cpp index c4b7c4bb1..d5c37f4b9 100644 --- a/src/UI/Controls/BaseResourceChooser.cpp +++ b/src/UI/Controls/BaseResourceChooser.cpp @@ -35,7 +35,6 @@ #include "BaseResourceChooser.h" #include "App.h" #include "Archive/ArchiveManager.h" -#include "UI/WxUtils.h" using namespace slade; @@ -66,22 +65,25 @@ BaseResourceChooser::BaseResourceChooser(wxWindow* parent, bool load_change) : populateChoices(); // Bind events - Bind(wxEVT_CHOICE, [&](wxCommandEvent&) { - // Open the selected base resource - if (load_change_) - app::archiveManager().openBaseResource(GetSelection() - 1); - }); + Bind( + wxEVT_CHOICE, + [&](wxCommandEvent&) + { + // Open the selected base resource + if (load_change_) + app::archiveManager().openBaseResource(GetSelection() - 1); + }); // Handle base resource change signals from the Archive Manager auto& am_signals = app::archiveManager().signals(); signal_connections_ += am_signals.base_res_path_added.connect([this](unsigned) { populateChoices(); }); signal_connections_ += am_signals.base_res_path_removed.connect([this](unsigned) { populateChoices(); }); signal_connections_ += am_signals.base_res_current_cleared.connect([this]() { SetSelection(0); }); - signal_connections_ += am_signals.base_res_current_changed.connect( - [this](unsigned) { SetSelection(base_resource + 1); }); + signal_connections_ += am_signals.base_res_current_changed.connect([this](unsigned) + { SetSelection(base_resource + 1); }); if (app::platform() != app::Platform::Linux) - wxWindowBase::SetMinSize(wxutil::scaledSize(128, -1)); + wxWindowBase::SetMinSize(FromDIP(wxSize(128, -1))); } // ----------------------------------------------------------------------------- diff --git a/src/UI/Controls/ColourBox.cpp b/src/UI/Controls/ColourBox.cpp index b3147beb8..5d306a0ca 100644 --- a/src/UI/Controls/ColourBox.cpp +++ b/src/UI/Controls/ColourBox.cpp @@ -36,7 +36,6 @@ // ----------------------------------------------------------------------------- #include "Main.h" #include "ColourBox.h" -#include "General/UI.h" #include "Graphics/Palette/Palette.h" #include "UI/Dialogs/PaletteDialog.h" #include "UI/WxUtils.h" @@ -63,7 +62,7 @@ DEFINE_EVENT_TYPE(wxEVT_COLOURBOX_CHANGED) // ColourBox class constructor // ----------------------------------------------------------------------------- ColourBox::ColourBox(wxWindow* parent, int id, bool enable_alpha, bool mode) : - wxPanel{ parent, id, wxDefaultPosition, wxutil::scaledSize(32, 22), wxNO_BORDER }, + wxPanel{ parent, id, wxDefaultPosition, FromDIP(wxSize(32, 22)), wxNO_BORDER }, alpha_{ enable_alpha }, altmode_{ mode } { @@ -83,9 +82,9 @@ ColourBox::ColourBox(wxWindow* parent, int id, ColRGBA col, bool enable_alpha, b altmode_{ mode } { if (size > 0) - SetInitialSize({ size, size }); + SetInitialSize(FromDIP(wxSize{ size, size })); else - SetInitialSize(wxutil::scaledSize(32, 22)); + SetInitialSize(FromDIP(wxSize(32, 22))); // Bind events Bind(wxEVT_PAINT, &ColourBox::onPaint, this); diff --git a/src/UI/Controls/ResourceArchiveChooser.cpp b/src/UI/Controls/ResourceArchiveChooser.cpp index 95a41cd8c..a6aaddaf6 100644 --- a/src/UI/Controls/ResourceArchiveChooser.cpp +++ b/src/UI/Controls/ResourceArchiveChooser.cpp @@ -61,7 +61,7 @@ ResourceArchiveChooser::ResourceArchiveChooser(wxWindow* parent, const Archive* // Resource archive list list_resources_ = new wxCheckListBox(this, -1); sizer->Add(list_resources_, wxutil::sfWithBorder(1, wxBOTTOM).Expand()); - list_resources_->SetInitialSize(wxutil::scaledSize(350, 100)); + list_resources_->SetInitialSize(FromDIP(wxSize(350, 100))); // Populate resource archive list int index = 0; diff --git a/src/UI/Controls/SZoomSlider.cpp b/src/UI/Controls/SZoomSlider.cpp index 56e68b7f2..23b3005d2 100644 --- a/src/UI/Controls/SZoomSlider.cpp +++ b/src/UI/Controls/SZoomSlider.cpp @@ -72,7 +72,7 @@ SZoomSlider::SZoomSlider(wxWindow* parent, CTextureGLCanvas* linked_canvas) : void SZoomSlider::setup() { // Create controls - slider_zoom_ = new wxSlider(this, -1, 100, 20, 800, wxDefaultPosition, wxutil::scaledSize(150, -1)); + slider_zoom_ = new wxSlider(this, -1, 100, 20, 800, wxDefaultPosition, FromDIP(wxSize(150, -1))); slider_zoom_->SetLineSize(10); slider_zoom_->SetPageSize(100); label_zoom_amount_ = new wxStaticText(this, -1, "100%"); diff --git a/src/UI/Dialogs/GfxCropDialog.cpp b/src/UI/Dialogs/GfxCropDialog.cpp index f6125bbd3..10c9680b1 100644 --- a/src/UI/Dialogs/GfxCropDialog.cpp +++ b/src/UI/Dialogs/GfxCropDialog.cpp @@ -77,7 +77,7 @@ GfxCropDialog::GfxCropDialog(wxWindow* parent, const SImage& image, const Palett canvas_preview_->setPalette(palette); canvas_preview_->image().copyImage(&image); canvas_preview_->setCropRect(crop_rect_); - canvas_preview_->window()->SetInitialSize(wxutil::scaledSize(220, 220)); + canvas_preview_->window()->SetInitialSize(FromDIP(wxSize(220, 220))); sizer->Add(canvas_preview_->window(), wx::sfWithBorder(1, wxBOTTOM).Expand()); // Add crop controls diff --git a/src/UI/WxUtils.cpp b/src/UI/WxUtils.cpp index e14571298..180bd34b3 100644 --- a/src/UI/WxUtils.cpp +++ b/src/UI/WxUtils.cpp @@ -360,39 +360,6 @@ wxArrayString wxutil::arrayStringStd(const vector& vector) return list; } -// ----------------------------------------------------------------------------- -// Returns the size [x]x[y] as a wxSize, scaled by the DPI factor. -// Will keep any -1 value -// ----------------------------------------------------------------------------- -wxSize wxutil::scaledSize(int x, int y) -{ - // TODO: Remove - return { x, y }; - // return { x < 0 ? -1 : ui::scalePx(x), y < 0 ? -1 : ui::scalePx(y) }; -} - -// ----------------------------------------------------------------------------- -// Returns the position [x],[y] as a wxPoint, scaled by the DPI factor -// ----------------------------------------------------------------------------- -wxPoint wxutil::scaledPoint(int x, int y) -{ - // TODO: Remove - return { x, y }; - // return { ui::scalePx(x), ui::scalePx(y) }; -} - -// ----------------------------------------------------------------------------- -// Returns the rect at [x],[y] of size [width]x[height] as a wxRect, scaled by -// the DPI factor -// ----------------------------------------------------------------------------- -wxRect wxutil::scaledRect(int x, int y, int width, int height) -{ - // TODO: Remove - return { x, y, width, height }; - - // return { ui::scalePx(x), ui::scalePx(y), ui::scalePx(width), ui::scalePx(height) }; -} - // ----------------------------------------------------------------------------- // Sets the given [window]'s [icon] // ----------------------------------------------------------------------------- diff --git a/src/UI/WxUtils.h b/src/UI/WxUtils.h index 64977b947..d8f27ba19 100644 --- a/src/UI/WxUtils.h +++ b/src/UI/WxUtils.h @@ -47,11 +47,6 @@ inline wxString strFromView(string_view view) wxArrayString arrayString(const vector& vector); wxArrayString arrayStringStd(const vector& vector); -// Scaling -wxSize scaledSize(int x, int y); -wxPoint scaledPoint(int x, int y); -wxRect scaledRect(int x, int y, int width, int height); - // Misc void setWindowIcon(wxTopLevelWindow* window, string_view icon);