From 3b11581aff0fc7b1e248f1e9a67e35854f7c32b8 Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Wed, 3 Aug 2016 11:14:52 +0000 Subject: [PATCH] WX: HiDPI: ISOProperties And related ARCodeAddEdit/PatchAddEdit. Change ISOFile to use wxImage instead of wxBitmap since bitmaps require a screen context and banner images have a fixed resolution. --- Source/Core/DolphinWX/GameListCtrl.cpp | 13 +- Source/Core/DolphinWX/GameListCtrl.h | 1 + Source/Core/DolphinWX/ISOFile.cpp | 31 +--- Source/Core/DolphinWX/ISOFile.h | 8 +- Source/Core/DolphinWX/ISOProperties.cpp | 223 ++++++++++++++---------- Source/Core/DolphinWX/ISOProperties.h | 4 +- Source/Core/DolphinWX/PatchAddEdit.cpp | 45 +++-- 7 files changed, 179 insertions(+), 146 deletions(-) diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index c5b093880d..858d273996 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -252,6 +252,9 @@ void CGameListCtrl::InitBitmaps() InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 3, "rating3"); InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 4, "rating4"); InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 5, "rating5"); + + m_utility_game_banners.resize(1); + InitBitmap(img_list, &m_utility_game_banners, this, size, 0, "nobanner"); } void CGameListCtrl::BrowseForDirectory() @@ -431,10 +434,14 @@ void CGameListCtrl::UpdateItemAtColumn(long _Index, int column) } case COLUMN_BANNER: { - int ImageIndex = -1; + int ImageIndex = m_utility_game_banners[0]; // nobanner - if (rISOFile.GetBitmap().IsOk()) - ImageIndex = GetImageList(wxIMAGE_LIST_SMALL)->Add(rISOFile.GetBitmap()); + if (rISOFile.GetBannerImage().IsOk()) + { + wxImageList* img_list = GetImageList(wxIMAGE_LIST_SMALL); + ImageIndex = img_list->Add( + WxUtils::ScaleImageToBitmap(rISOFile.GetBannerImage(), this, img_list->GetSize())); + } SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex); break; diff --git a/Source/Core/DolphinWX/GameListCtrl.h b/Source/Core/DolphinWX/GameListCtrl.h index 34f65fa725..467271d68e 100644 --- a/Source/Core/DolphinWX/GameListCtrl.h +++ b/Source/Core/DolphinWX/GameListCtrl.h @@ -70,6 +70,7 @@ private: std::vector m_FlagImageIndex; std::vector m_PlatformImageIndex; std::vector m_EmuStateImageIndex; + std::vector m_utility_game_banners; std::vector> m_ISOFiles; void ClearIsoFiles() { m_ISOFiles.clear(); } diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 54669a34a5..05379a98a8 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -38,9 +38,6 @@ static const u32 CACHE_REVISION = 0x127; // Last changed in PR 3309 -#define DVD_BANNER_WIDTH 96 -#define DVD_BANNER_HEIGHT 32 - static std::string GetLanguageString(DiscIO::Language language, std::map strings) { @@ -165,13 +162,12 @@ GameListItem::GameListItem(const std::string& _rFileName, // Volume banner. Typical for everything that isn't a DOL or ELF. if (!m_pImage.empty()) { - wxImage image(m_ImageWidth, m_ImageHeight, &m_pImage[0], true); - m_Bitmap = ScaleBanner(&image); + // Need to make explicit copy as wxImage uses reference counting for copies combined with only + // taking a pointer, not the content, when given a buffer to its constructor. + m_image.Create(m_ImageWidth, m_ImageHeight, false); + std::memcpy(m_image.GetData(), m_pImage.data(), m_pImage.size()); return; } - - // Fallback in case no banner is available. - ReadPNGBanner(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + "nobanner.png"); } GameListItem::~GameListItem() @@ -277,22 +273,11 @@ bool GameListItem::ReadPNGBanner(const std::string& path) return false; wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG); - m_Bitmap = ScaleBanner(&image); - return true; -} + if (!image.IsOk()) + return false; -wxBitmap GameListItem::ScaleBanner(wxImage* image) -{ - wxWindow* window = wxTheApp->GetTopWindow(); - const double gui_scale = window->GetContentScaleFactor() * (window->FromDIP(1024) / 1024.0); - const double target_width = DVD_BANNER_WIDTH * gui_scale; - const double target_height = DVD_BANNER_HEIGHT * gui_scale; - const double banner_scale = - std::min(target_width / image->GetWidth(), target_height / image->GetHeight()); - image->Rescale(image->GetWidth() * banner_scale, image->GetHeight() * banner_scale, - wxIMAGE_QUALITY_BICUBIC); - image->Resize(wxSize(target_width, target_height), wxPoint(), 0xFF, 0xFF, 0xFF); - return wxBitmap(*image, wxBITMAP_SCREEN_DEPTH, window->GetContentScaleFactor()); + m_image = image; + return true; } std::string GameListItem::GetDescription(DiscIO::Language language) const diff --git a/Source/Core/DolphinWX/ISOFile.h b/Source/Core/DolphinWX/ISOFile.h index b5c19dd5ef..b8b0127e70 100644 --- a/Source/Core/DolphinWX/ISOFile.h +++ b/Source/Core/DolphinWX/ISOFile.h @@ -59,7 +59,9 @@ public: // 0 is the first disc, 1 is the second disc u8 GetDiscNumber() const { return m_disc_number; } #if defined(HAVE_WX) && HAVE_WX - const wxBitmap& GetBitmap() const { return m_Bitmap; } + // NOTE: Banner image is at the original resolution, use WxUtils::ScaleImageToBitmap + // to display it + const wxImage& GetBannerImage() const { return m_image; } #endif void DoState(PointerWrap& p); @@ -86,7 +88,7 @@ private: u16 m_Revision; #if defined(HAVE_WX) && HAVE_WX - wxBitmap m_Bitmap; + wxImage m_image; #endif bool m_Valid; std::vector m_pImage; @@ -107,6 +109,4 @@ private: void ReadVolumeBanner(const std::vector& buffer, int width, int height); // Outputs to m_Bitmap bool ReadPNGBanner(const std::string& path); - - static wxBitmap ScaleBanner(wxImage* image); }; diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp index 54ca974fdb..5dcbcf591a 100644 --- a/Source/Core/DolphinWX/ISOProperties.cpp +++ b/Source/Core/DolphinWX/ISOProperties.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -63,6 +63,7 @@ #include "DiscIO/VolumeCreator.h" #include "DolphinWX/Cheats/ActionReplayCodesPanel.h" #include "DolphinWX/Cheats/GeckoCodeDiag.h" +#include "DolphinWX/DolphinSlider.h" #include "DolphinWX/Frame.h" #include "DolphinWX/Globals.h" #include "DolphinWX/ISOFile.h" @@ -110,6 +111,9 @@ private: void CreateGUI() { + int space10 = FromDIP(10); + int space15 = FromDIP(15); + wxStaticBitmap* icon = new wxStaticBitmap(this, wxID_ANY, wxArtProvider::GetMessageBoxIcon(wxICON_WARNING)); m_message = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, @@ -119,10 +123,10 @@ private: m_btn_configure->Bind(wxEVT_BUTTON, &CheatWarningMessage::OnConfigureClicked, this); wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 15); - sizer->Add(m_message, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 15); - sizer->Add(m_btn_configure, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); - sizer->AddSpacer(10); + sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space15); + sizer->Add(m_message, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, space15); + sizer->Add(m_btn_configure, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space10); + sizer->AddSpacer(space10); SetSizer(sizer); } @@ -286,8 +290,17 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par bool wii = m_open_iso->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC; ChangeBannerDetails(SConfig::GetInstance().GetCurrentLanguage(wii)); - m_Banner->SetBitmap(OpenGameListItem.GetBitmap()); - m_Banner->Bind(wxEVT_RIGHT_DOWN, &CISOProperties::RightClickOnBanner, this); + if (OpenGameListItem.GetBannerImage().IsOk()) + { + m_Banner->SetBitmap(WxUtils::ScaleImageToBitmap(OpenGameListItem.GetBannerImage(), this, + m_Banner->GetMinSize())); + m_Banner->Bind(wxEVT_RIGHT_DOWN, &CISOProperties::RightClickOnBanner, this); + } + else + { + m_Banner->SetBitmap( + WxUtils::LoadScaledResourceBitmap("nobanner", this, m_Banner->GetMinSize())); + } // Filesystem browser/dumper // TODO : Should we add a way to browse the wad file ? @@ -410,6 +423,9 @@ long CISOProperties::GetElementStyle(const char* section, const char* key) void CISOProperties::CreateGUIControls() { + const int space5 = FromDIP(5); + const int space10 = FromDIP(10); + wxButton* const EditConfig = new wxButton(this, ID_EDITCONFIG, _("Edit Config")); EditConfig->SetToolTip(_("This will let you manually edit the INI config file.")); @@ -473,8 +489,8 @@ void CISOProperties::CreateGUIControls() arrayStringFor_GPUDeterminism.Add(_("fake-completion")); GPUDeterminism = new wxChoice(m_GameConfig, ID_GPUDETERMINISM, wxDefaultPosition, wxDefaultSize, arrayStringFor_GPUDeterminism); - sGPUDeterminism->Add(GPUDeterminismText); - sGPUDeterminism->Add(GPUDeterminism); + sGPUDeterminism->Add(GPUDeterminismText, 0, wxALIGN_CENTER_VERTICAL); + sGPUDeterminism->Add(GPUDeterminism, 0, wxALIGN_CENTER_VERTICAL); // Wii Console EnableWideScreen = @@ -485,7 +501,7 @@ void CISOProperties::CreateGUIControls() wxBoxSizer* const sDepthPercentage = new wxBoxSizer(wxHORIZONTAL); wxStaticText* const DepthPercentageText = new wxStaticText(m_GameConfig, wxID_ANY, _("Depth Percentage: ")); - DepthPercentage = new wxSlider(m_GameConfig, ID_DEPTHPERCENTAGE, 100, 0, 200); + DepthPercentage = new DolphinSlider(m_GameConfig, ID_DEPTHPERCENTAGE, 100, 0, 200); DepthPercentage->SetToolTip( _("This value is multiplied with the depth set in the graphics configuration.")); sDepthPercentage->Add(DepthPercentageText); @@ -518,19 +534,23 @@ void CISOProperties::CreateGUIControls() EmuState = new wxChoice(m_GameConfig, ID_EMUSTATE, wxDefaultPosition, wxDefaultSize, arrayStringFor_EmuState); EmuIssues = new wxTextCtrl(m_GameConfig, ID_EMU_ISSUES, wxEmptyString); + sEmuState->Add(EmuStateText, 0, wxALIGN_CENTER_VERTICAL); + sEmuState->Add(EmuState, 0, wxALIGN_CENTER_VERTICAL); + sEmuState->Add(EmuIssues, 1, wxEXPAND); - wxBoxSizer* const sConfigPage = new wxBoxSizer(wxVERTICAL); wxStaticBoxSizer* const sbCoreOverrides = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Core")); - sbCoreOverrides->Add(CPUThread, 0, wxLEFT, 5); - sbCoreOverrides->Add(SkipIdle, 0, wxLEFT, 5); - sbCoreOverrides->Add(MMU, 0, wxLEFT, 5); - sbCoreOverrides->Add(DCBZOFF, 0, wxLEFT, 5); - sbCoreOverrides->Add(FPRF, 0, wxLEFT, 5); - sbCoreOverrides->Add(SyncGPU, 0, wxLEFT, 5); - sbCoreOverrides->Add(FastDiscSpeed, 0, wxLEFT, 5); - sbCoreOverrides->Add(DSPHLE, 0, wxLEFT, 5); - sbCoreOverrides->Add(sGPUDeterminism, 0, wxEXPAND | wxALL, 5); + sbCoreOverrides->Add(CPUThread, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(SkipIdle, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(MMU, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(DCBZOFF, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(FPRF, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(SyncGPU, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(FastDiscSpeed, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->Add(DSPHLE, 0, wxLEFT | wxRIGHT, space5); + sbCoreOverrides->AddSpacer(space5); + sbCoreOverrides->Add(sGPUDeterminism, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbCoreOverrides->AddSpacer(space5); wxStaticBoxSizer* const sbWiiOverrides = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Wii Console")); @@ -539,7 +559,7 @@ void CISOProperties::CreateGUIControls() sbWiiOverrides->ShowItems(false); EnableWideScreen->Hide(); } - sbWiiOverrides->Add(EnableWideScreen, 0, wxLEFT, 5); + sbWiiOverrides->Add(EnableWideScreen, 0, wxLEFT, space5); wxStaticBoxSizer* const sbStereoOverrides = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Stereoscopy")); @@ -549,15 +569,19 @@ void CISOProperties::CreateGUIControls() wxStaticBoxSizer* const sbGameConfig = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Game-Specific Settings")); - sbGameConfig->Add(OverrideText, 0, wxEXPAND | wxALL, 5); + sbGameConfig->AddSpacer(space5); + sbGameConfig->Add(OverrideText, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbGameConfig->AddSpacer(space5); sbGameConfig->Add(sbCoreOverrides, 0, wxEXPAND); sbGameConfig->Add(sbWiiOverrides, 0, wxEXPAND); sbGameConfig->Add(sbStereoOverrides, 0, wxEXPAND); - sConfigPage->Add(sbGameConfig, 0, wxEXPAND | wxALL, 5); - sEmuState->Add(EmuStateText, 0, wxALIGN_CENTER_VERTICAL); - sEmuState->Add(EmuState, 0, wxEXPAND); - sEmuState->Add(EmuIssues, 1, wxEXPAND); - sConfigPage->Add(sEmuState, 0, wxEXPAND | wxALL, 5); + + wxBoxSizer* const sConfigPage = new wxBoxSizer(wxVERTICAL); + sConfigPage->AddSpacer(space5); + sConfigPage->Add(sbGameConfig, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sConfigPage->AddSpacer(space5); + sConfigPage->Add(sEmuState, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sConfigPage->AddSpacer(space5); m_GameConfig->SetSizer(sConfigPage); // Patches @@ -572,13 +596,15 @@ void CISOProperties::CreateGUIControls() RemovePatch->Disable(); wxBoxSizer* sPatchPage = new wxBoxSizer(wxVERTICAL); - sPatches->Add(Patches, 1, wxEXPAND | wxALL, 0); - sPatchButtons->Add(EditPatch, 0, wxEXPAND | wxALL, 0); + sPatches->Add(Patches, 1, wxEXPAND); + sPatchButtons->Add(EditPatch, 0, wxEXPAND); sPatchButtons->AddStretchSpacer(); - sPatchButtons->Add(AddPatch, 0, wxEXPAND | wxALL, 0); - sPatchButtons->Add(RemovePatch, 0, wxEXPAND | wxALL, 0); - sPatches->Add(sPatchButtons, 0, wxEXPAND | wxALL, 0); - sPatchPage->Add(sPatches, 1, wxEXPAND | wxALL, 5); + sPatchButtons->Add(AddPatch, 0, wxEXPAND); + sPatchButtons->Add(RemovePatch, 0, wxEXPAND); + sPatches->Add(sPatchButtons, 0, wxEXPAND); + sPatchPage->AddSpacer(space5); + sPatchPage->Add(sPatches, 1, wxEXPAND | wxLEFT | wxRIGHT, space5); + sPatchPage->AddSpacer(space5); m_PatchPage->SetSizer(sPatchPage); // Action Replay Cheats @@ -589,8 +615,8 @@ void CISOProperties::CreateGUIControls() m_ar_code_panel->Bind(DOLPHIN_EVT_ARCODE_TOGGLED, &CISOProperties::OnCheatCodeToggled, this); wxBoxSizer* const sCheatPage = new wxBoxSizer(wxVERTICAL); - sCheatPage->Add(m_cheats_disabled_ar, 0, wxEXPAND | wxTOP, 5); - sCheatPage->Add(m_ar_code_panel, 1, wxEXPAND | wxALL, 5); + sCheatPage->Add(m_cheats_disabled_ar, 0, wxEXPAND | wxTOP, space5); + sCheatPage->Add(m_ar_code_panel, 1, wxEXPAND | wxALL, space5); m_CheatPage->SetSizer(sCheatPage); // Gecko Cheats @@ -600,7 +626,7 @@ void CISOProperties::CreateGUIControls() m_geckocode_panel->Bind(DOLPHIN_EVT_GECKOCODE_TOGGLED, &CISOProperties::OnCheatCodeToggled, this); wxBoxSizer* gecko_layout = new wxBoxSizer(wxVERTICAL); - gecko_layout->Add(m_cheats_disabled_gecko, 0, wxEXPAND | wxTOP, 5); + gecko_layout->Add(m_cheats_disabled_gecko, 0, wxEXPAND | wxTOP, space5); gecko_layout->Add(m_geckocode_panel, 1, wxEXPAND); gecko_cheat_page->SetSizer(gecko_layout); @@ -698,67 +724,63 @@ void CISOProperties::CreateGUIControls() m_Comment = new wxTextCtrl(m_Information, ID_COMMENT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); wxStaticText* const m_BannerText = new wxStaticText(m_Information, wxID_ANY, _("Banner:")); - m_Banner = - new wxStaticBitmap(m_Information, ID_BANNER, wxNullBitmap, wxDefaultPosition, wxSize(96, 32)); + m_Banner = new wxStaticBitmap(m_Information, ID_BANNER, wxNullBitmap, wxDefaultPosition, + FromDIP(wxSize(96, 32))); // ISO Details - wxGridBagSizer* const sISODetails = new wxGridBagSizer(0, 0); - sISODetails->Add(m_InternalNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_InternalName, wxGBPosition(0, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_GameIDText, wxGBPosition(1, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_GameID, wxGBPosition(1, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_CountryText, wxGBPosition(2, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_Country, wxGBPosition(2, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_MakerIDText, wxGBPosition(3, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_MakerID, wxGBPosition(3, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_RevisionText, wxGBPosition(4, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_Revision, wxGBPosition(4, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_DateText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, - 5); - sISODetails->Add(m_Date, wxGBPosition(5, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_FSTText, wxGBPosition(6, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, - 5); - sISODetails->Add(m_FST, wxGBPosition(6, 1), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sISODetails->Add(m_MD5SumText, wxGBPosition(7, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sISODetails->Add(m_MD5Sum, wxGBPosition(7, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - wxSizer* sMD5SumButtonSizer = CreateButtonSizer(wxNO_DEFAULT); - sMD5SumButtonSizer->Add(m_MD5SumCompute); - sISODetails->Add(sMD5SumButtonSizer, wxGBPosition(7, 2), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); + wxGridBagSizer* const sISODetails = new wxGridBagSizer(space10, space10); + sISODetails->Add(m_InternalNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_InternalName, wxGBPosition(0, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_GameIDText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_GameID, wxGBPosition(1, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_CountryText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_Country, wxGBPosition(2, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_MakerIDText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_MakerID, wxGBPosition(3, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_RevisionText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_Revision, wxGBPosition(4, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_DateText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_Date, wxGBPosition(5, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_FSTText, wxGBPosition(6, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_FST, wxGBPosition(6, 1), wxGBSpan(1, 2), wxEXPAND); + sISODetails->Add(m_MD5SumText, wxGBPosition(7, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sISODetails->Add(m_MD5Sum, wxGBPosition(7, 1), wxGBSpan(1, 1), wxEXPAND); + sISODetails->Add(m_MD5SumCompute, wxGBPosition(7, 2), wxGBSpan(1, 1), wxEXPAND); sISODetails->AddGrowableCol(1); wxStaticBoxSizer* const sbISODetails = new wxStaticBoxSizer(wxVERTICAL, m_Information, _("ISO Details")); - sbISODetails->Add(sISODetails, 0, wxEXPAND, 5); + sbISODetails->AddSpacer(space5); + sbISODetails->Add(sISODetails, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbISODetails->AddSpacer(space5); // Banner Details - wxGridBagSizer* const sBannerDetails = new wxGridBagSizer(0, 0); - sBannerDetails->Add(m_LangText, wxGBPosition(0, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sBannerDetails->Add(m_Lang, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sBannerDetails->Add(m_NameText, wxGBPosition(1, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sBannerDetails->Add(m_Name, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sBannerDetails->Add(m_MakerText, wxGBPosition(2, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sBannerDetails->Add(m_Maker, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sBannerDetails->Add(m_CommentText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5); - sBannerDetails->Add(m_Comment, wxGBPosition(3, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sBannerDetails->Add(m_BannerText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5); - sBannerDetails->Add(m_Banner, wxGBPosition(4, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); + wxGridBagSizer* const sBannerDetails = new wxGridBagSizer(space10, space10); + sBannerDetails->Add(m_LangText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + // Comboboxes cannot be safely stretched vertically on Windows. + sBannerDetails->Add(WxUtils::GiveMinSize(m_Lang, wxDefaultSize), wxGBPosition(0, 1), + wxGBSpan(1, 1), wxEXPAND); + sBannerDetails->Add(m_NameText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sBannerDetails->Add(m_Name, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND); + sBannerDetails->Add(m_MakerText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sBannerDetails->Add(m_Maker, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND); + sBannerDetails->Add(m_CommentText, wxGBPosition(3, 0), wxGBSpan(1, 1)); + sBannerDetails->Add(m_Comment, wxGBPosition(3, 1), wxGBSpan(1, 1), wxEXPAND); + sBannerDetails->Add(m_BannerText, wxGBPosition(4, 0), wxGBSpan(1, 1)); + sBannerDetails->Add(m_Banner, wxGBPosition(4, 1), wxGBSpan(1, 1), wxEXPAND); sBannerDetails->AddGrowableCol(1); wxStaticBoxSizer* const sbBannerDetails = new wxStaticBoxSizer(wxVERTICAL, m_Information, _("Banner Details")); - sbBannerDetails->Add(sBannerDetails, 0, wxEXPAND, 5); + sbBannerDetails->AddSpacer(space5); + sbBannerDetails->Add(sBannerDetails, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbBannerDetails->AddSpacer(space5); wxBoxSizer* const sInfoPage = new wxBoxSizer(wxVERTICAL); - sInfoPage->Add(sbISODetails, 0, wxEXPAND | wxALL, 5); - sInfoPage->Add(sbBannerDetails, 0, wxEXPAND | wxALL, 5); + sInfoPage->AddSpacer(space5); + sInfoPage->Add(sbISODetails, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sInfoPage->AddSpacer(space5); + sInfoPage->Add(sbBannerDetails, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sInfoPage->AddSpacer(space5); m_Information->SetSizer(sInfoPage); if (m_open_iso->GetVolumeType() != DiscIO::Platform::WII_WAD) @@ -767,10 +789,14 @@ void CISOProperties::CreateGUIControls() m_Notebook->AddPage(filesystem_panel, _("Filesystem")); // Filesystem icons - wxImageList* const m_iconList = new wxImageList(16, 16); - m_iconList->Add(WxUtils::LoadResourceBitmap("isoproperties_disc")); // 0 - m_iconList->Add(WxUtils::LoadResourceBitmap("isoproperties_folder")); // 1 - m_iconList->Add(WxUtils::LoadResourceBitmap("isoproperties_file")); // 2 + wxSize icon_size = FromDIP(wxSize(16, 16)); + wxImageList* const m_iconList = new wxImageList(icon_size.GetWidth(), icon_size.GetHeight()); + static const std::array s_icon_names{ + {"isoproperties_disc", "isoproperties_folder", "isoproperties_file"}}; + for (const auto& name : s_icon_names) + m_iconList->Add( + WxUtils::LoadScaledResourceBitmap(name, this, icon_size, wxDefaultSize, + WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER)); // Filesystem tree m_Treectrl = new wxTreeCtrl(filesystem_panel, ID_TREECTRL); @@ -778,14 +804,16 @@ void CISOProperties::CreateGUIControls() RootId = m_Treectrl->AddRoot(_("Disc"), 0, 0, nullptr); wxBoxSizer* sTreePage = new wxBoxSizer(wxVERTICAL); - sTreePage->Add(m_Treectrl, 1, wxEXPAND | wxALL, 5); + sTreePage->AddSpacer(space5); + sTreePage->Add(m_Treectrl, 1, wxEXPAND | wxLEFT | wxRIGHT, space5); + sTreePage->AddSpacer(space5); filesystem_panel->SetSizer(sTreePage); } - wxSizer* sButtons = CreateButtonSizer(wxNO_DEFAULT); + wxStdDialogButtonSizer* sButtons = CreateStdDialogButtonSizer(wxOK | wxNO_DEFAULT); sButtons->Prepend(EditConfigDefault); sButtons->Prepend(EditConfig); - sButtons->Add(new wxButton(this, wxID_OK, _("Close"))); + sButtons->GetAffirmativeButton()->SetLabel(_("Close")); // If there is no default gameini, disable the button. bool game_ini_exists = false; @@ -803,10 +831,15 @@ void CISOProperties::CreateGUIControls() // Add notebook and buttons to the dialog wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL); - sMain->Add(m_Notebook, 1, wxEXPAND | wxALL, 5); - sMain->Add(sButtons, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - sMain->SetMinSize(wxSize(500, -1)); + sMain->AddSpacer(space5); + sMain->Add(m_Notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5); + sMain->AddSpacer(space5); + sMain->Add(sButtons, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sMain->AddSpacer(space5); + sMain->SetMinSize(FromDIP(wxSize(500, -1))); + SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED); + SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER); SetSizerAndFit(sMain); Center(); SetFocus(); @@ -842,7 +875,7 @@ void CISOProperties::OnBannerImageSave(wxCommandEvent& WXUNUSED(event)) wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dialog.ShowModal() == wxID_OK) { - m_Banner->GetBitmap().ConvertToImage().SaveFile(dialog.GetPath()); + OpenGameListItem.GetBannerImage().SaveFile(dialog.GetPath()); } Raise(); } diff --git a/Source/Core/DolphinWX/ISOProperties.h b/Source/Core/DolphinWX/ISOProperties.h index c3e70e62dd..922b188dde 100644 --- a/Source/Core/DolphinWX/ISOProperties.h +++ b/Source/Core/DolphinWX/ISOProperties.h @@ -19,11 +19,11 @@ #include "DolphinWX/ISOFile.h" #include "DolphinWX/PatchAddEdit.h" +class DolphinSlider; class wxButton; class wxCheckBox; class wxCheckListBox; class wxChoice; -class wxSlider; class wxSpinCtrl; class wxStaticBitmap; class wxTextCtrl; @@ -90,7 +90,7 @@ private: wxCheckBox* EnableWideScreen; // Stereoscopy - wxSlider* DepthPercentage; + DolphinSlider* DepthPercentage; wxSpinCtrl* Convergence; wxCheckBox* MonoDepth; diff --git a/Source/Core/DolphinWX/PatchAddEdit.cpp b/Source/Core/DolphinWX/PatchAddEdit.cpp index a845c60016..e58b90a913 100644 --- a/Source/Core/DolphinWX/PatchAddEdit.cpp +++ b/Source/Core/DolphinWX/PatchAddEdit.cpp @@ -52,7 +52,8 @@ void CPatchAddEdit::CreateGUIControls(int _selection) itCurEntry = tempEntries.begin(); - wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); + const int space5 = FromDIP(5); + const int space10 = FromDIP(10); wxStaticText* EditPatchNameText = new wxStaticText(this, wxID_ANY, _("Name:")); EditPatchName = new wxTextCtrl(this, wxID_ANY); @@ -89,32 +90,38 @@ void CPatchAddEdit::CreateGUIControls(int _selection) EntryRemove->Disable(); wxBoxSizer* sEditPatchName = new wxBoxSizer(wxHORIZONTAL); - sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - sEditPatchName->Add(EditPatchName, 1, wxEXPAND | wxALL, 5); - sEditPatch->Add(sEditPatchName, 0, wxEXPAND); + sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL); + sEditPatchName->Add(EditPatchName, 1, wxEXPAND | wxLEFT, space5); sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(_("Entry 1/%d"), (int)tempEntries.size())); currentItem = 1; - wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); - sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND | wxALL, 5); - sgEntry->Add(EditPatchOffsetText, wxGBPosition(1, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sgEntry->Add(EditPatchOffset, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sgEntry->Add(EditPatchValueText, wxGBPosition(2, 0), wxGBSpan(1, 1), - wxALIGN_CENTER_VERTICAL | wxALL, 5); - sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); - sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND | wxALL, 5); + wxGridBagSizer* sgEntry = new wxGridBagSizer(space10, space10); + sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND); + sgEntry->Add(EditPatchOffsetText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sgEntry->Add(EditPatchOffset, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND); + sgEntry->Add(EditPatchValueText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL); + sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND); + sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND); sgEntry->AddGrowableCol(1); wxBoxSizer* sEntryAddRemove = new wxBoxSizer(wxHORIZONTAL); - sEntryAddRemove->Add(EntryAdd, 0, wxALL, 5); - sEntryAddRemove->Add(EntryRemove, 0, wxALL, 5); - sbEntry->Add(sgEntry, 0, wxEXPAND); - sbEntry->Add(sEntryAddRemove, 0, wxEXPAND); + sEntryAddRemove->Add(EntryAdd, 0, wxALIGN_CENTER_VERTICAL); + sEntryAddRemove->Add(EntryRemove, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space5); + sbEntry->AddSpacer(space5); + sbEntry->Add(sgEntry, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbEntry->AddSpacer(space5); + sbEntry->Add(sEntryAddRemove, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sbEntry->AddSpacer(space5); - sEditPatch->Add(sbEntry, 0, wxEXPAND | wxALL, 5); - sEditPatch->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); + sEditPatch->AddSpacer(space5); + sEditPatch->Add(sEditPatchName, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sEditPatch->AddSpacer(space5); + sEditPatch->Add(sbEntry, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sEditPatch->AddSpacer(space5); + sEditPatch->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + sEditPatch->AddSpacer(space5); SetSizerAndFit(sEditPatch); SetFocus(); }