diff --git a/Source/Core/DolphinWX/AboutDolphin.cpp b/Source/Core/DolphinWX/AboutDolphin.cpp index 17c723ec14..00b7e97d67 100644 --- a/Source/Core/DolphinWX/AboutDolphin.cpp +++ b/Source/Core/DolphinWX/AboutDolphin.cpp @@ -26,7 +26,7 @@ AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id, : wxDialog(parent, id, title, position, size, style) { wxGenericStaticBitmap* const sbDolphinLogo = new wxGenericStaticBitmap(this, wxID_ANY, - WxUtils::LoadResourceBitmap("dolphin_logo", true)); + WxUtils::LoadResourceBitmap("dolphin_logo")); const wxString DolphinText = _("Dolphin"); const wxString RevisionText = scm_desc_str; diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index 3644adfbfa..18b69e3f23 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -173,34 +173,34 @@ void CGameListCtrl::InitBitmaps() SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL); m_FlagImageIndex.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_JAPAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Japan", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_EUROPE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Europe", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_USA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_USA", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_AUSTRALIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Australia", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_FRANCE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_France", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_GERMANY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Germany", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_ITALY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Italy", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_KOREA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Korea", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_NETHERLANDS] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Netherlands", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_RUSSIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Russia", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_SPAIN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Spain", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_TAIWAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Taiwan", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_WORLD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_International", size)); - m_FlagImageIndex[DiscIO::IVolume::COUNTRY_UNKNOWN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Unknown", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_JAPAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Japan", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_EUROPE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Europe", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_USA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_USA", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_AUSTRALIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Australia", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_FRANCE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_France", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_GERMANY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Germany", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_ITALY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Italy", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_KOREA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Korea", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_NETHERLANDS] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Netherlands", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_RUSSIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Russia", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_SPAIN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Spain", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_TAIWAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Taiwan", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_WORLD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_International", size)); + m_FlagImageIndex[DiscIO::IVolume::COUNTRY_UNKNOWN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Unknown", size)); m_PlatformImageIndex.resize(4); - m_PlatformImageIndex[DiscIO::IVolume::GAMECUBE_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Gamecube", size)); - m_PlatformImageIndex[DiscIO::IVolume::WII_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Wii", size)); - m_PlatformImageIndex[DiscIO::IVolume::WII_WAD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Wad", size)); - m_PlatformImageIndex[DiscIO::IVolume::ELF_DOL] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_File", size)); + m_PlatformImageIndex[DiscIO::IVolume::GAMECUBE_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Gamecube", size)); + m_PlatformImageIndex[DiscIO::IVolume::WII_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Wii", size)); + m_PlatformImageIndex[DiscIO::IVolume::WII_WAD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Wad", size)); + m_PlatformImageIndex[DiscIO::IVolume::ELF_DOL] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_File", size)); m_EmuStateImageIndex.resize(6); - m_EmuStateImageIndex[0] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating0", size)); - m_EmuStateImageIndex[1] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating1", size)); - m_EmuStateImageIndex[2] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating2", size)); - m_EmuStateImageIndex[3] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating3", size)); - m_EmuStateImageIndex[4] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating4", size)); - m_EmuStateImageIndex[5] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating5", size)); + m_EmuStateImageIndex[0] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating0", size)); + m_EmuStateImageIndex[1] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating1", size)); + m_EmuStateImageIndex[2] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating2", size)); + m_EmuStateImageIndex[3] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating3", size)); + m_EmuStateImageIndex[4] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating4", size)); + m_EmuStateImageIndex[5] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating5", size)); } void CGameListCtrl::BrowseForDirectory() diff --git a/Source/Core/DolphinWX/WxUtils.cpp b/Source/Core/DolphinWX/WxUtils.cpp index 45e3b3dd52..14f5977e53 100644 --- a/Source/Core/DolphinWX/WxUtils.cpp +++ b/Source/Core/DolphinWX/WxUtils.cpp @@ -60,13 +60,13 @@ void ShowErrorDialog(const wxString& error_msg) wxMessageBox(error_msg, _("Error"), wxOK | wxICON_ERROR); } -wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x) +wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size) { const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name; std::string path = path_base + ".png"; -#ifdef __APPLE__ double scale_factor = 1.0; - if (allow_2x && wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2) +#ifdef __APPLE__ + if (wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2) { const std::string path_2x = path_base + "@2x.png"; if (File::Exists(path_2x)) @@ -77,6 +77,15 @@ wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x) } #endif wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG); + + if (padded_size != wxSize()) + { + // Add padding if necessary (or crop, but images aren't supposed to be large enough to require that). + // The image will be left-aligned and vertically centered. + const wxSize scaled_padded_size = padded_size * scale_factor; + image.Resize(scaled_padded_size, wxPoint(0, (scaled_padded_size.GetHeight() - image.GetHeight()) / 2)); + } + #ifdef __APPLE__ return wxBitmap(image, -1, scale_factor); #else @@ -84,13 +93,6 @@ wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x) #endif } -wxBitmap LoadResourceBitmapPadded(const std::string& name, const wxSize& size) -{ - wxImage image(StrToWxStr(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name + ".png"), wxBITMAP_TYPE_PNG); - image.Resize(size, wxPoint(0, (size.GetHeight() - image.GetHeight()) / 2)); // Vertically centered - return wxBitmap(image); -} - wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original) { wxImage image = original.ConvertToImage(); diff --git a/Source/Core/DolphinWX/WxUtils.h b/Source/Core/DolphinWX/WxUtils.h index 7c6b0cbd21..25c3ed2458 100644 --- a/Source/Core/DolphinWX/WxUtils.h +++ b/Source/Core/DolphinWX/WxUtils.h @@ -5,10 +5,10 @@ #pragma once #include +#include #include class wxBitmap; -class wxSize; class wxToolBar; namespace WxUtils @@ -24,8 +24,7 @@ void Explore(const std::string& path); void ShowErrorDialog(const wxString& error_msg); // Reads a PNG from the Resources folder -wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x = false); -wxBitmap LoadResourceBitmapPadded(const std::string& name, const wxSize& size); +wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size = wxSize()); // From a wxBitmap, creates the corresponding disabled version for toolbar buttons wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original);