Skip to content

Commit e1fe8ca

Browse files
committed
Remove ui::scalePx(U)
Replace with FromDIP where applicable
1 parent 916d97a commit e1fe8ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+88
-130
lines changed

src/General/UI.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,6 @@ int ui::px(Size size)
217217
return 0;
218218
}
219219

220-
// -----------------------------------------------------------------------------
221-
// Returns [px] scaled by the current scaling factor (in pixels).
222-
// Will use the lower bound when converting to int
223-
// -----------------------------------------------------------------------------
224-
int ui::scalePx(int px)
225-
{
226-
return px;
227-
}
228-
229-
// -----------------------------------------------------------------------------
230-
// Returns [px] scaled by the current scaling factor (in pixels)
231-
// Will use the upper bound when converting to int
232-
// -----------------------------------------------------------------------------
233-
int ui::scalePxU(int px)
234-
{
235-
return static_cast<int>(std::ceil(static_cast<double>(px)));
236-
}
237-
238220
// -----------------------------------------------------------------------------
239221
// Returns the standard padding size in pixels
240222
// -----------------------------------------------------------------------------

src/General/UI.h

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ enum class Size
4040
SpinCtrlWidth
4141
};
4242
int px(Size size);
43-
int scalePx(int px);
44-
int scalePxU(int px);
4543
int pad(); // Shortcut for ui::px(UI::Size::Pad)
4644
int padLarge(); // Shortcut for ui::px(UI::Size::PadLarge)
4745
int padMin(); // Shortcut for ui::px(ui::Size::PadMinimum)

src/MainEditor/UI/ArchiveManagerPanel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ ArchiveManagerPanel::ArchiveManagerPanel(wxWindow* parent, STabCtrl* nb_archives
338338

339339
// Create/setup tabs
340340
stc_tabs_ = new STabCtrl(this, false);
341-
stc_tabs_->SetInitialSize(wxSize(ui::scalePx(224), -1));
341+
stc_tabs_->SetInitialSize(wxSize(FromDIP(224), -1));
342342
vbox->Add(stc_tabs_, wxutil::sfWithBorder(1).Expand());
343343

344344
// Open archives tab
@@ -408,7 +408,7 @@ ArchiveManagerPanel::ArchiveManagerPanel(wxWindow* parent, STabCtrl* nb_archives
408408

409409
// Init layout
410410
wxWindowBase::Layout();
411-
SetInitialSize(wxSize(ui::scalePx(256), -1));
411+
SetInitialSize(wxSize(FromDIP(256), -1));
412412
}
413413

414414
// -----------------------------------------------------------------------------

src/MainEditor/UI/ArchivePanel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void ArchivePanel::setup(const Archive* archive)
360360
cur_area_->setUndoManager(undo_manager_.get());
361361

362362
// Setup splitter
363-
splitter_->SetMinimumPaneSize(ui::scalePx(300));
363+
splitter_->SetMinimumPaneSize(FromDIP(300));
364364
m_hbox->Add(splitter_, wxutil::sfWithBorder(1).Expand());
365365
int split_pos = ap_splitter_position_list;
366366
if (archive && archive->formatInfo().supports_dirs)

src/MainEditor/UI/EntryPanel/AudioEntryPanel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ AudioEntryPanel::AudioEntryPanel(wxWindow* parent) :
115115
-1,
116116
wxEmptyString,
117117
wxDefaultPosition,
118-
{ -1, ui::scalePx(200) },
118+
{ -1, FromDIP(200) },
119119
wxTE_MULTILINE | wxTE_READONLY | wxTE_BESTWRAP);
120120
sizer_gb->Add(txt_info_, wxGBPosition(4, 0), wxGBSpan(1, 9), wxEXPAND | wxHORIZONTAL);
121121

@@ -132,7 +132,7 @@ AudioEntryPanel::AudioEntryPanel(wxWindow* parent) :
132132

133133
// Add volume slider
134134
sizer_gb->Add(new wxStaticText(this, -1, "Volume:"), wxGBPosition(1, 7), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
135-
slider_volume_ = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxSize(ui::scalePx(128), -1));
135+
slider_volume_ = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxSize(FromDIP(128), -1));
136136
slider_volume_->SetValue(snd_volume);
137137
sizer_gb->Add(slider_volume_, wxGBPosition(1, 8), { 1, 1 }, wxALIGN_CENTER_VERTICAL);
138138

src/MainEditor/UI/EntryPanel/DataEntryPanel.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "Archive/EntryType/EntryType.h"
3737
#include "General/ColourConfiguration.h"
3838
#include "General/SAction.h"
39-
#include "General/UI.h"
4039
#include "MainEditor/BinaryControlLump.h"
4140
#include "MainEditor/MainEditor.h"
4241
#include "UI/SToolBar/SToolBar.h"
@@ -951,7 +950,7 @@ bool DataEntryPanel::loadEntry(ArchiveEntry* entry)
951950
combo_cell_value_->Clear();
952951

953952
// Set column widths
954-
grid_data_->SetColMinimalAcceptableWidth(ui::scalePx(64));
953+
grid_data_->SetColMinimalAcceptableWidth(FromDIP(64));
955954
for (int a = 0; a < table_data_->GetNumberCols(); a++)
956955
grid_data_->AutoSizeColLabelSize(a);
957956
grid_data_->ForceRefresh();

src/MainEditor/UI/EntryPanel/PaletteEntryPanel.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "Archive/Archive.h"
3737
#include "Archive/ArchiveEntry.h"
3838
#include "General/SAction.h"
39-
#include "General/UI.h"
4039
#include "Graphics/Palette/Palette.h"
4140
#include "Graphics/Palette/PaletteManager.h"
4241
#include "Graphics/SImage/SIFormat.h"
@@ -120,7 +119,7 @@ class PaletteColouriseDialog : public wxDialog
120119

121120
// Setup preview
122121
pal_preview_->setSelectionType(PaletteCanvas::SelectionType::Range);
123-
pal_preview_->SetInitialSize(wxSize(ui::scalePx(384), ui::scalePx(384)));
122+
pal_preview_->SetInitialSize(FromDIP(wxSize(384, 384)));
124123
redraw();
125124

126125
// Init layout
@@ -207,7 +206,7 @@ class PaletteTintDialog : public wxDialog
207206

208207
// Setup preview
209208
pal_preview_->setSelectionType(PaletteCanvas::SelectionType::Range);
210-
pal_preview_->SetInitialSize(wxSize(ui::scalePx(384), ui::scalePx(384)));
209+
pal_preview_->SetInitialSize(FromDIP(wxSize(384, 384)));
211210
redraw();
212211

213212
// Init layout
@@ -331,7 +330,7 @@ class PaletteColourTweakDialog : public wxDialog
331330

332331
// Setup preview
333332
pal_preview_->setSelectionType(PaletteCanvas::SelectionType::Range);
334-
pal_preview_->SetInitialSize(wxSize(ui::scalePx(384), ui::scalePx(384)));
333+
pal_preview_->SetInitialSize(FromDIP(wxSize(384, 384)));
335334
redraw();
336335

337336
// Init layout
@@ -434,7 +433,7 @@ class PaletteInvertDialog : public wxDialog
434433

435434
// Setup preview
436435
pal_preview_->setSelectionType(PaletteCanvas::SelectionType::Range);
437-
pal_preview_->SetInitialSize(wxSize(ui::scalePx(384), ui::scalePx(384)));
436+
pal_preview_->SetInitialSize(FromDIP(wxSize(384, 384)));
438437
redraw();
439438

440439
// Init layout
@@ -574,7 +573,7 @@ class PaletteGradientDialog : public wxDialog
574573

575574
// Setup preview
576575
pal_preview_->setSelectionType(PaletteCanvas::SelectionType::Range);
577-
pal_preview_->SetInitialSize(wxSize(ui::scalePx(384), ui::scalePx(384)));
576+
pal_preview_->SetInitialSize(FromDIP(wxSize(384, 384)));
578577
redraw();
579578

580579
// Init layout

src/MainEditor/UI/EntryPanel/TextEntryPanel.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@
3333
#include "TextEntryPanel.h"
3434
#include "Archive/ArchiveEntry.h"
3535
#include "Archive/EntryType/EntryType.h"
36-
#include "Game/Configuration.h"
3736
#include "Game/Game.h"
3837
#include "General/SAction.h"
39-
#include "General/UI.h"
4038
#include "MainEditor/EntryOperations.h"
4139
#include "MainEditor/MainEditor.h"
4240
#include "TextEditor/TextLanguage.h"
@@ -93,7 +91,7 @@ TextEntryPanel::TextEntryPanel(wxWindow* parent) : EntryPanel(parent, "text")
9391

9492
// Add 'Jump To' choice to toolbar
9593
auto group_jump_to = new SToolBarGroup(toolbar_, "Jump To", true);
96-
choice_jump_to_ = new wxChoice(group_jump_to, -1, wxDefaultPosition, wxSize(ui::scalePx(200), -1));
94+
choice_jump_to_ = new wxChoice(group_jump_to, -1, wxDefaultPosition, wxSize(FromDIP(200), -1));
9795
group_jump_to->addCustomControl(choice_jump_to_);
9896
toolbar_->addGroup(group_jump_to);
9997
text_area_->setJumpToControl(choice_jump_to_);

src/MainEditor/UI/TextureXEditor/TextureXPanel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class NewTextureDialog : public wxDialog
247247
});
248248

249249
// Setup dialog size
250-
SetInitialSize({ ui::scalePx(400), -1 });
250+
SetInitialSize({ FromDIP(400), -1 });
251251
wxTopLevelWindowBase::Layout();
252252
wxWindowBase::Fit();
253253
wxTopLevelWindowBase::SetMinSize(GetBestSize());

src/MapEditor/UI/ActionSpecialPanel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ ActionSpecialTreeView::ActionSpecialTreeView(wxWindow* parent) : wxDataViewTreeC
123123

124124
// 64 is an arbitrary fudge factor -- should be at least the width of a
125125
// scrollbar plus the expand icons plus any extra padding
126-
int min_width = textsize.GetWidth() + GetIndent() + ui::scalePx(64);
127-
wxWindowBase::SetMinSize({ min_width, ui::scalePx(200) });
126+
int min_width = textsize.GetWidth() + GetIndent() + 64;
127+
wxWindowBase::SetMinSize(FromDIP(wxSize{ min_width, 200 }));
128128
}
129129

130130
// -----------------------------------------------------------------------------

src/MapEditor/UI/Dialogs/SpecialPresetDialog.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "SpecialPresetDialog.h"
3535
#include "Game/Configuration.h"
3636
#include "Game/SpecialPreset.h"
37-
#include "General/UI.h"
3837
#include "UI/WxUtils.h"
3938

4039
using namespace slade;
@@ -98,8 +97,8 @@ class SpecialPresetTreeView : public wxDataViewTreeCtrl
9897

9998
// 64 is an arbitrary fudge factor -- should be at least the width of a
10099
// scrollbar plus the expand icons plus any extra padding
101-
int min_width = textsize.GetWidth() + GetIndent() + ui::scalePx(64);
102-
wxWindowBase::SetMinSize(wxSize(min_width, ui::scalePx(200)));
100+
int min_width = textsize.GetWidth() + GetIndent() + 64;
101+
wxWindowBase::SetMinSize(FromDIP(wxSize(min_width, 200)));
103102
}
104103

105104
game::SpecialPreset selectedPreset() const
@@ -160,7 +159,7 @@ class SpecialPresetTreeView : public wxDataViewTreeCtrl
160159

161160
if (!found)
162161
{
163-
current = AppendContainer(current, path[p], -1, 1);
162+
current = AppendContainer(current, path[p]);
164163
groups_.emplace_back(current, fullpath);
165164
}
166165
}
@@ -213,6 +212,9 @@ SpecialPresetDialog::SpecialPresetDialog(wxWindow* parent) : SDialog{ parent, "S
213212
auto btn_cancel = new wxButton(this, -1, "Cancel");
214213
hbox->Add(btn_cancel, wxSizerFlags().Expand());
215214
btn_cancel->Bind(wxEVT_BUTTON, [&](wxCommandEvent& e) { EndModal(wxID_CANCEL); });
215+
216+
wxWindowBase::SetMinClientSize(sizer->GetMinSize());
217+
CenterOnParent();
216218
}
217219

218220
// -----------------------------------------------------------------------------

src/MapEditor/UI/MapEditorWindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void MapEditorWindow::setupLayout()
374374

375375
// Status bar
376376
CreateStatusBar(4);
377-
int status_widths[4] = { -1, ui::scalePx(240), ui::scalePx(240), ui::scalePx(240) };
377+
int status_widths[4] = { -1, FromDIP(240), FromDIP(240), FromDIP(240) };
378378
SetStatusWidths(4, status_widths);
379379

380380
// -- Console Panel --

src/MapEditor/UI/PropsPanel/ThingPropsPanel.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ ThingDirCanvas::ThingDirCanvas(AngleControl* parent) : wxPanel(parent), parent_{
205205
Bind(wxEVT_PAINT, &ThingDirCanvas::onPaint, this);
206206

207207
// Fixed size
208-
auto size = ui::scalePx(128);
208+
auto size = FromDIP(128);
209209
SetInitialSize(wxSize(size, size));
210210
wxWindowBase::SetMaxSize(wxSize(size, size));
211211
}
@@ -329,9 +329,9 @@ void ThingDirCanvas::onPaint(wxPaintEvent& e)
329329
auto gc = wxGraphicsContext::Create(dc);
330330

331331
auto half_size = GetSize().x / 2;
332-
auto pad = ui::scalePx(8);
332+
auto pad = FromDIP(8);
333333
auto radius = half_size - pad;
334-
auto point_radius = ui::scalePx(7);
334+
auto point_radius = FromDIP(7);
335335
auto col_bg = wxutil::systemPanelBGColour();
336336
auto col_fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
337337
auto pi = wxGraphicsPenInfo(wxColour(col_fg.Red(), col_fg.Green(), col_fg.Blue(), 80), 1.75);

src/MapEditor/UI/SectorSpecialPanel.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "Main.h"
3333
#include "SectorSpecialPanel.h"
3434
#include "Game/Configuration.h"
35-
#include "General/UI.h"
3635
#include "UI/Lists/ListView.h"
3736
#include "UI/WxUtils.h"
3837

@@ -93,7 +92,7 @@ SectorSpecialPanel::SectorSpecialPanel(wxWindow* parent) : wxPanel(parent, -1)
9392
lv_specials_->updateSize();
9493

9594
// Boom Flags
96-
int width = ui::scalePx(300);
95+
int width = FromDIP(300);
9796
if (game::configuration().supportsSectorFlags())
9897
{
9998
frame = new wxStaticBox(this, -1, "Flags");

0 commit comments

Comments
 (0)