Skip to content

Commit

Permalink
Remove wxutil::scaledSize/Point/Rect
Browse files Browse the repository at this point in the history
Again replace with FromDIP where applicable
  • Loading branch information
sirjuddington committed May 31, 2024
1 parent e1fe8ca commit d218154
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 99 deletions.
12 changes: 6 additions & 6 deletions src/MainEditor/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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<ConsolePanel*>(p_inf.window)->focusInput();
m_mgr->Update();
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/MainEditor/UI/StartPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(svg_entry->rawData()), wxutil::scaledSize(size, size));
return wxBitmapBundle::FromSVG(reinterpret_cast<const char*>(svg_entry->rawData()), { size, size });
}

// -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion src/MainEditor/UI/TextureXEditor/ZTextureEditorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
7 changes: 3 additions & 4 deletions src/MapEditor/UI/ArgsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "ArgsPanel.h"
#include "Game/Args.h"
#include "General/UI.h"
#include "UI/WxUtils.h"

using namespace slade;

Expand Down Expand Up @@ -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<unsigned char>());
else
Expand Down Expand Up @@ -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<unsigned char>());

for (const auto& custom_value : arg.custom_values)
Expand Down Expand Up @@ -494,7 +493,7 @@ ArgsPanel::ArgsPanel(wxWindow* parent) : wxScrolled<wxPanel>{ 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
Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/Dialogs/ShowItemDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
27 changes: 13 additions & 14 deletions src/MapEditor/UI/MapEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -1301,7 +1300,7 @@ bool MapEditorWindow::handleAction(string_view id)
dynamic_cast<ConsolePanel*>(p_inf.window)->focusInput();
}

p_inf.MinSize(wxutil::scaledSize(200, 128));
p_inf.MinSize(FromDIP(wxSize(200, 128)));
m_mgr->Update();
return true;
}
Expand All @@ -1325,7 +1324,7 @@ bool MapEditorWindow::handleAction(string_view id)
dynamic_cast<ScriptEditorPanel*>(p_inf.window)->updateUI();
}

p_inf.MinSize(wxutil::scaledSize(200, 128));
p_inf.MinSize(FromDIP(wxSize(200, 128)));
m_mgr->Update();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/ObjectEditPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ObjectEditPanel::ObjectEditPanel(wxWindow* parent) : wxPanel(parent)
wxIntegerValidator<int> val_int(nullptr, wxNUM_VAL_DEFAULT);
wxIntegerValidator<unsigned int> val_uint(nullptr, wxNUM_VAL_DEFAULT);
wxFloatingPointValidator<double> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/PropsPanel/SectorPropsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

// -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/MapEditor/UI/PropsPanel/SidePropsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("-");

Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/MapEditor/UI/ScriptEditorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/MapEditor/UI/SectorSpecialPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)));
}

// -----------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/Scripting/UI/ScriptManagerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 2 additions & 3 deletions src/TextEditor/UI/SCallTip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
// -----------------------------------------------------------------------------
#include "Main.h"
#include "SCallTip.h"
#include "UI/WxUtils.h"
#include "Utility/Colour.h"

using namespace slade;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Browser/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 11 additions & 9 deletions src/UI/Controls/BaseResourceChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "BaseResourceChooser.h"
#include "App.h"
#include "Archive/ArchiveManager.h"
#include "UI/WxUtils.h"

using namespace slade;

Expand Down Expand Up @@ -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)));
}

// -----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit d218154

Please sign in to comment.