WX: HiDPI: Dolphin Main UI (CFrame)

This commit is contained in:
EmptyChaos 2016-08-14 19:54:01 +00:00
parent 73a20551df
commit 107d4afb08
10 changed files with 169 additions and 203 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <climits>
#include <memory>
#include "Common/CDUtils.h"
@ -138,8 +139,8 @@ void SConfig::SaveInterfaceSettings(IniFile& ini)
interface->Set("OnScreenDisplayMessages", bOnScreenDisplayMessages);
interface->Set("HideCursor", bHideCursor);
interface->Set("AutoHideCursor", bAutoHideCursor);
interface->Set("MainWindowPosX", (iPosX == -32000) ? 0 : iPosX); // TODO - HAX
interface->Set("MainWindowPosY", (iPosY == -32000) ? 0 : iPosY); // TODO - HAX
interface->Set("MainWindowPosX", iPosX);
interface->Set("MainWindowPosY", iPosY);
interface->Set("MainWindowWidth", iWidth);
interface->Set("MainWindowHeight", iHeight);
interface->Set("LanguageCode", m_InterfaceLanguage);
@ -402,10 +403,10 @@ void SConfig::LoadInterfaceSettings(IniFile& ini)
interface->Get("OnScreenDisplayMessages", &bOnScreenDisplayMessages, true);
interface->Get("HideCursor", &bHideCursor, false);
interface->Get("AutoHideCursor", &bAutoHideCursor, false);
interface->Get("MainWindowPosX", &iPosX, 100);
interface->Get("MainWindowPosY", &iPosY, 100);
interface->Get("MainWindowWidth", &iWidth, 800);
interface->Get("MainWindowHeight", &iHeight, 600);
interface->Get("MainWindowPosX", &iPosX, INT_MIN);
interface->Get("MainWindowPosY", &iPosY, INT_MIN);
interface->Get("MainWindowWidth", &iWidth, -1);
interface->Get("MainWindowHeight", &iHeight, -1);
interface->Get("LanguageCode", &m_InterfaceLanguage, "");
interface->Get("ShowToolbar", &m_InterfaceToolbar, true);
interface->Get("ShowStatusbar", &m_InterfaceStatusbar, true);
@ -663,10 +664,10 @@ void SConfig::LoadDefaults()
bDPL2Decoder = false;
iLatency = 14;
iPosX = 100;
iPosY = 100;
iWidth = 800;
iHeight = 600;
iPosX = INT_MIN;
iPosY = INT_MIN;
iWidth = -1;
iHeight = -1;
m_analytics_id = "";
m_analytics_enabled = false;

View File

@ -4,6 +4,7 @@
#pragma once
#include <limits>
#include <string>
#include <vector>
@ -129,8 +130,10 @@ struct SConfig : NonCopyable
// Display settings
std::string strFullscreenResolution;
int iRenderWindowXPos = -1, iRenderWindowYPos = -1;
int iRenderWindowWidth = 640, iRenderWindowHeight = 480;
int iRenderWindowXPos = std::numeric_limits<int>::min();
int iRenderWindowYPos = std::numeric_limits<int>::min();
int iRenderWindowWidth = -1;
int iRenderWindowHeight = -1;
bool bRenderWindowAutoSize = false, bKeepWindowOnTop = false;
bool bFullscreen = false, bRenderToMain = false;
bool bProgressive = false, bPAL60 = false;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <array>
#include <cstdio>
#include <string>
#include <vector>
@ -666,19 +667,18 @@ bool CCodeWindow::JITNoBlockLinking()
// Toolbar
void CCodeWindow::InitBitmaps()
{
m_Bitmaps[Toolbar_Step] = WxUtils::LoadResourceBitmap("toolbar_debugger_step");
m_Bitmaps[Toolbar_StepOver] = WxUtils::LoadResourceBitmap("toolbar_debugger_step_over");
m_Bitmaps[Toolbar_StepOut] = WxUtils::LoadResourceBitmap("toolbar_debugger_step_out");
m_Bitmaps[Toolbar_Skip] = WxUtils::LoadResourceBitmap("toolbar_debugger_skip");
m_Bitmaps[Toolbar_GotoPC] = WxUtils::LoadResourceBitmap("toolbar_debugger_goto_pc");
m_Bitmaps[Toolbar_SetPC] = WxUtils::LoadResourceBitmap("toolbar_debugger_set_pc");
static constexpr std::array<const char* const, Toolbar_Debug_Bitmap_Max> s_image_names{
{"toolbar_debugger_step", "toolbar_debugger_step_over", "toolbar_debugger_step_out",
"toolbar_debugger_skip", "toolbar_debugger_goto_pc", "toolbar_debugger_set_pc"}};
const wxSize tool_size = Parent->GetToolbarBitmapSize();
for (std::size_t i = 0; i < s_image_names.size(); ++i)
m_Bitmaps[i] =
WxUtils::LoadScaledResourceBitmap(s_image_names[i], Parent, tool_size, wxDefaultSize,
WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER);
}
void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
{
int w = m_Bitmaps[0].GetWidth(), h = m_Bitmaps[0].GetHeight();
toolBar->SetToolBitmapSize(wxSize(w, h));
WxUtils::AddToolbarButton(toolBar, IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step],
_("Step into the next instruction"));
WxUtils::AddToolbarButton(toolBar, IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver],

View File

@ -86,7 +86,7 @@ CRenderFrame::CRenderFrame(wxFrame* parent, wxWindowID id, const wxString& title
{
// Give it an icon
wxIcon IconTemp;
IconTemp.CopyFromBitmap(WxUtils::LoadResourceBitmap("Dolphin"));
IconTemp.CopyFromBitmap(WxUtils::LoadScaledResourceBitmap("Dolphin", this));
SetIcon(IconTemp);
DragAcceptFiles(true);
@ -381,22 +381,18 @@ static BOOL WINAPI s_ctrl_handler(DWORD fdwCtrlType)
}
#endif
CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
const wxSize& size, bool _UseDebugger, bool _BatchMode, bool ShowLogWindow,
long style)
: CRenderFrame(parent, id, title, pos, size, style), UseDebugger(_UseDebugger),
m_bBatchMode(_BatchMode)
CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geometry,
bool use_debugger, bool batch_mode, bool show_log_window, long style)
: CRenderFrame(parent, id, title, wxDefaultPosition, wxSize(800, 600), style),
UseDebugger(use_debugger), m_bBatchMode(batch_mode),
m_toolbar_bitmap_size(FromDIP(wxSize(32, 32)))
{
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
bFloatWindow[i] = false;
if (ShowLogWindow)
if (show_log_window)
SConfig::GetInstance().m_InterfaceLogWindow = true;
// Start debugging maximized
if (UseDebugger)
this->Maximize(true);
// Debugger class
if (UseDebugger)
{
@ -487,15 +483,23 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPo
ToggleLogConfigWindow(true);
}
// Set the size of the window after the UI has been built, but before we show it
SetSize(size);
// Setup the window size.
// This has to be done here instead of in Main because the Show() happens here.
SetMinSize(FromDIP(wxSize(400, 300)));
WxUtils::SetWindowSizeAndFitToScreen(this, geometry.GetPosition(), geometry.GetSize(),
FromDIP(wxSize(800, 600)));
// Show window
Show();
// Start debugging maximized (Must be after the window has been positioned)
if (UseDebugger)
Maximize(true);
// Commit
m_Mgr->Update();
// The window must be shown for m_XRRConfig to be created (wxGTK will not allocate X11
// resources until the window is shown for the first time).
Show();
#ifdef _WIN32
SetToolTip("");
GetToolTip()->SetAutoPop(25000);
@ -680,7 +684,8 @@ void CFrame::OnResize(wxSizeEvent& event)
{
event.Skip();
if (!IsMaximized() && !(SConfig::GetInstance().bRenderToMain && RendererIsFullscreen()) &&
if (!IsMaximized() && !IsIconized() &&
!(SConfig::GetInstance().bRenderToMain && RendererIsFullscreen()) &&
!(Core::GetState() != Core::CORE_UNINITIALIZED && SConfig::GetInstance().bRenderToMain &&
SConfig::GetInstance().bRenderWindowAutoSize))
{
@ -930,7 +935,7 @@ void CFrame::OnGameListCtrlItemActivated(wxListEvent& WXUNUSED(event))
GetMenuBar()->FindItem(IDM_LIST_WORLD)->Check(true);
GetMenuBar()->FindItem(IDM_LIST_UNKNOWN)->Check(true);
m_GameListCtrl->Update();
UpdateGameList();
}
else if (!m_GameListCtrl->GetISO(0))
{

View File

@ -63,8 +63,8 @@ class CFrame : public CRenderFrame
{
public:
CFrame(wxFrame* parent, wxWindowID id = wxID_ANY, const wxString& title = "Dolphin",
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
bool _UseDebugger = false, bool _BatchMode = false, bool ShowLogWindow = false,
wxRect geometry = wxDefaultSize, bool use_debugger = false, bool batch_mode = false,
bool show_log_window = false,
long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
virtual ~CFrame();
@ -113,6 +113,7 @@ public:
const CGameListCtrl* GetGameListCtrl() const;
wxMenuBar* GetMenuBar() const override;
const wxSize& GetToolbarBitmapSize() const; // Needed before the toolbar exists
#ifdef __WXGTK__
Common::Event panic_event;
@ -191,6 +192,7 @@ private:
wxTimer m_poll_hotkey_timer;
wxTimer m_handle_signal_timer;
wxSize m_toolbar_bitmap_size;
wxBitmap m_Bitmaps[EToolbar_Max];
wxMenuBar* m_menubar_shadow = nullptr;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <array>
#include <cstdarg>
#include <cstdio>
#include <mutex>
@ -77,21 +78,6 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#ifdef _WIN32
#ifndef SM_XVIRTUALSCREEN
#define SM_XVIRTUALSCREEN 76
#endif
#ifndef SM_YVIRTUALSCREEN
#define SM_YVIRTUALSCREEN 77
#endif
#ifndef SM_CXVIRTUALSCREEN
#define SM_CXVIRTUALSCREEN 78
#endif
#ifndef SM_CYVIRTUALSCREEN
#define SM_CYVIRTUALSCREEN 79
#endif
#endif
class InputConfig;
class wxFrame;
@ -108,6 +94,11 @@ wxMenuBar* CFrame::GetMenuBar() const
}
}
const wxSize& CFrame::GetToolbarBitmapSize() const
{
return m_toolbar_bitmap_size;
}
// Create menu items
// ---------------------
wxMenuBar* CFrame::CreateMenu()
@ -528,9 +519,6 @@ wxString CFrame::GetMenuLabel(int Id)
// ---------------------
void CFrame::PopulateToolbar(wxToolBar* ToolBar)
{
int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(), h = m_Bitmaps[Toolbar_FileOpen].GetHeight();
ToolBar->SetToolBitmapSize(wxSize(w, h));
WxUtils::AddToolbarButton(ToolBar, wxID_OPEN, _("Open"), m_Bitmaps[Toolbar_FileOpen],
_("Open file..."));
WxUtils::AddToolbarButton(ToolBar, wxID_REFRESH, _("Refresh"), m_Bitmaps[Toolbar_Refresh],
@ -554,7 +542,7 @@ void CFrame::PopulateToolbar(wxToolBar* ToolBar)
// Delete and recreate the toolbar
void CFrame::RecreateToolbar()
{
static const long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT | wxTB_FLAT;
static constexpr long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT | wxTB_FLAT;
if (m_ToolBar != nullptr)
{
@ -563,6 +551,7 @@ void CFrame::RecreateToolbar()
}
m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY);
m_ToolBar->SetToolBitmapSize(m_toolbar_bitmap_size);
if (g_pCodeWindow)
{
@ -580,18 +569,11 @@ void CFrame::RecreateToolbar()
void CFrame::InitBitmaps()
{
auto const dir = StrToWxStr(File::GetThemeDir(SConfig::GetInstance().theme_name));
m_Bitmaps[Toolbar_FileOpen].LoadFile(dir + "open.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Refresh].LoadFile(dir + "refresh.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Play].LoadFile(dir + "play.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Stop].LoadFile(dir + "stop.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Pause].LoadFile(dir + "pause.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_ConfigMain].LoadFile(dir + "config.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_ConfigGFX].LoadFile(dir + "graphics.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Controller].LoadFile(dir + "classic.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Screenshot].LoadFile(dir + "screenshot.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_FullScreen].LoadFile(dir + "fullscreen.png", wxBITMAP_TYPE_PNG);
static constexpr std::array<const char* const, EToolbar_Max> s_image_names{
{"open", "refresh", "play", "stop", "pause", "screenshot", "fullscreen", "config", "graphics",
"classic"}};
for (std::size_t i = 0; i < s_image_names.size(); ++i)
m_Bitmaps[i] = WxUtils::LoadScaledThemeBitmap(s_image_names[i], this, m_toolbar_bitmap_size);
// Update in case the bitmap has been updated
if (m_ToolBar != nullptr)
@ -606,7 +588,7 @@ void CFrame::OpenGeneralConfiguration(int tab)
HotkeyManagerEmu::Enable(false);
if (config_main.ShowModal() == wxID_OK)
m_GameListCtrl->Update();
UpdateGameList();
HotkeyManagerEmu::Enable(true);
UpdateGUI();
@ -987,36 +969,29 @@ void CFrame::StartGame(const std::string& filename)
}
else
{
wxPoint position(SConfig::GetInstance().iRenderWindowXPos,
SConfig::GetInstance().iRenderWindowYPos);
#ifdef __APPLE__
// On OS X, the render window's title bar is not visible,
// and the window therefore not easily moved, when the
// position is 0,0. Weed out the 0's from existing configs.
if (position == wxPoint(0, 0))
position = wxDefaultPosition;
#endif
wxRect window_geometry(
SConfig::GetInstance().iRenderWindowXPos, SConfig::GetInstance().iRenderWindowYPos,
SConfig::GetInstance().iRenderWindowWidth, SConfig::GetInstance().iRenderWindowHeight);
// Set window size in framebuffer pixels since the 3D rendering will be operating at
// that level.
wxSize default_size{wxSize(640, 480) * (1.0 / GetContentScaleFactor())};
m_RenderFrame = new CRenderFrame(this, wxID_ANY, _("Dolphin"), wxDefaultPosition, default_size);
// Convert ClientSize coordinates to frame sizes.
wxSize decoration_fudge = m_RenderFrame->GetSize() - m_RenderFrame->GetClientSize();
default_size += decoration_fudge;
if (!window_geometry.IsEmpty())
window_geometry.SetSize(window_geometry.GetSize() + decoration_fudge);
WxUtils::SetWindowSizeAndFitToScreen(m_RenderFrame, window_geometry.GetPosition(),
window_geometry.GetSize(), default_size);
wxSize size(SConfig::GetInstance().iRenderWindowWidth,
SConfig::GetInstance().iRenderWindowHeight);
#ifdef _WIN32
// Out of desktop check
int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
if ((leftPos + width) < (position.x + size.GetWidth()) || leftPos > position.x ||
(topPos + height) < (position.y + size.GetHeight()) || topPos > position.y)
position.x = position.y = wxDefaultCoord;
#endif
m_RenderFrame = new CRenderFrame((wxFrame*)this, wxID_ANY, _("Dolphin"), position);
if (SConfig::GetInstance().bKeepWindowOnTop)
m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP);
else
m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
m_RenderFrame->SetBackgroundColour(*wxBLACK);
m_RenderFrame->SetClientSize(size.GetWidth(), size.GetHeight());
m_RenderFrame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnRenderParentClose, this);
m_RenderFrame->Bind(wxEVT_ACTIVATE, &CFrame::OnActive, this);
m_RenderFrame->Bind(wxEVT_MOVE, &CFrame::OnRenderParentMove, this);
@ -1035,7 +1010,7 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->EnableFullScreenView(true);
#endif
wxBeginBusyCursor();
wxBusyCursor hourglass;
DoFullscreen(SConfig::GetInstance().bFullscreen);
@ -1045,6 +1020,7 @@ void CFrame::StartGame(const std::string& filename)
// Destroy the renderer frame when not rendering to main
if (!SConfig::GetInstance().bRenderToMain)
m_RenderFrame->Destroy();
m_RenderFrame = nullptr;
m_RenderParent = nullptr;
m_bGameLoading = false;
UpdateGUI();
@ -1076,8 +1052,6 @@ void CFrame::StartGame(const std::string& filename)
wxTheApp->Bind(wxEVT_KILL_FOCUS, &CFrame::OnFocusChange, this);
m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this);
}
wxEndBusyCursor();
}
void CFrame::OnBootDrive(wxCommandEvent& event)
@ -1088,10 +1062,7 @@ void CFrame::OnBootDrive(wxCommandEvent& event)
// Refresh the file list and browse for a favorites directory
void CFrame::OnRefresh(wxCommandEvent& WXUNUSED(event))
{
if (m_GameListCtrl)
{
m_GameListCtrl->Update();
}
UpdateGameList();
}
// Create screenshot
@ -1912,7 +1883,8 @@ void CFrame::UpdateGUI()
void CFrame::UpdateGameList()
{
m_GameListCtrl->Update();
if (m_GameListCtrl)
m_GameListCtrl->ReloadList();
}
void CFrame::GameListChanged(wxCommandEvent& event)
@ -1987,11 +1959,7 @@ void CFrame::GameListChanged(wxCommandEvent& event)
break;
}
// Update gamelist
if (m_GameListCtrl)
{
m_GameListCtrl->Update();
}
UpdateGameList();
}
// Enable and disable the toolbar
@ -2047,6 +2015,6 @@ void CFrame::OnChangeColumnsVisible(wxCommandEvent& event)
default:
return;
}
m_GameListCtrl->Update();
UpdateGameList();
SConfig::GetInstance().SaveSettings();
}

View File

@ -11,6 +11,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <wx/app.h>
#include <wx/bitmap.h>
@ -187,47 +188,70 @@ CGameListCtrl::~CGameListCtrl()
}
template <typename T>
static void InitBitmap(wxImageList* img_list, std::vector<int>* vector, T index,
const std::string& name)
static void InitBitmap(wxImageList* img_list, std::vector<int>* vector, wxWindow* context,
const wxSize& usable_size, T index, const std::string& name)
{
wxSize size(96, 32);
(*vector)[static_cast<size_t>(index)] = img_list->Add(WxUtils::LoadResourceBitmap(name, size));
wxSize size = img_list->GetSize();
(*vector)[static_cast<size_t>(index)] = img_list->Add(WxUtils::LoadScaledResourceBitmap(
name, context, size, usable_size, WxUtils::LSI_SCALE | WxUtils::LSI_ALIGN_VCENTER));
}
void CGameListCtrl::InitBitmaps()
{
wxImageList* img_list = new wxImageList(96, 32);
const wxSize size = FromDIP(wxSize(96, 32));
const wxSize flag_bmp_size = FromDIP(wxSize(32, 32));
const wxSize platform_bmp_size = flag_bmp_size;
const wxSize rating_bmp_size = FromDIP(wxSize(48, 32));
wxImageList* img_list = new wxImageList(size.GetWidth(), size.GetHeight());
AssignImageList(img_list, wxIMAGE_LIST_SMALL);
m_FlagImageIndex.resize(static_cast<size_t>(DiscIO::Country::NUMBER_OF_COUNTRIES));
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_JAPAN, "Flag_Japan");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_EUROPE, "Flag_Europe");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_USA, "Flag_USA");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_AUSTRALIA, "Flag_Australia");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_FRANCE, "Flag_France");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_GERMANY, "Flag_Germany");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_ITALY, "Flag_Italy");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_KOREA, "Flag_Korea");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_NETHERLANDS, "Flag_Netherlands");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_RUSSIA, "Flag_Russia");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_SPAIN, "Flag_Spain");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_TAIWAN, "Flag_Taiwan");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_WORLD, "Flag_International");
InitBitmap(img_list, &m_FlagImageIndex, DiscIO::Country::COUNTRY_UNKNOWN, "Flag_Unknown");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_JAPAN,
"Flag_Japan");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_EUROPE,
"Flag_Europe");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_USA,
"Flag_USA");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_AUSTRALIA,
"Flag_Australia");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_FRANCE,
"Flag_France");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_GERMANY,
"Flag_Germany");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_ITALY,
"Flag_Italy");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_KOREA,
"Flag_Korea");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_NETHERLANDS,
"Flag_Netherlands");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_RUSSIA,
"Flag_Russia");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_SPAIN,
"Flag_Spain");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_TAIWAN,
"Flag_Taiwan");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_WORLD,
"Flag_International");
InitBitmap(img_list, &m_FlagImageIndex, this, flag_bmp_size, DiscIO::Country::COUNTRY_UNKNOWN,
"Flag_Unknown");
m_PlatformImageIndex.resize(static_cast<size_t>(DiscIO::Platform::NUMBER_OF_PLATFORMS));
InitBitmap(img_list, &m_PlatformImageIndex, DiscIO::Platform::GAMECUBE_DISC, "Platform_Gamecube");
InitBitmap(img_list, &m_PlatformImageIndex, DiscIO::Platform::WII_DISC, "Platform_Wii");
InitBitmap(img_list, &m_PlatformImageIndex, DiscIO::Platform::WII_WAD, "Platform_Wad");
InitBitmap(img_list, &m_PlatformImageIndex, DiscIO::Platform::ELF_DOL, "Platform_File");
InitBitmap(img_list, &m_PlatformImageIndex, this, platform_bmp_size,
DiscIO::Platform::GAMECUBE_DISC, "Platform_Gamecube");
InitBitmap(img_list, &m_PlatformImageIndex, this, platform_bmp_size, DiscIO::Platform::WII_DISC,
"Platform_Wii");
InitBitmap(img_list, &m_PlatformImageIndex, this, platform_bmp_size, DiscIO::Platform::WII_WAD,
"Platform_Wad");
InitBitmap(img_list, &m_PlatformImageIndex, this, platform_bmp_size, DiscIO::Platform::ELF_DOL,
"Platform_File");
m_EmuStateImageIndex.resize(6);
InitBitmap(img_list, &m_EmuStateImageIndex, 0, "rating0");
InitBitmap(img_list, &m_EmuStateImageIndex, 1, "rating1");
InitBitmap(img_list, &m_EmuStateImageIndex, 2, "rating2");
InitBitmap(img_list, &m_EmuStateImageIndex, 3, "rating3");
InitBitmap(img_list, &m_EmuStateImageIndex, 4, "rating4");
InitBitmap(img_list, &m_EmuStateImageIndex, 5, "rating5");
InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 0, "rating0");
InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 1, "rating1");
InitBitmap(img_list, &m_EmuStateImageIndex, this, rating_bmp_size, 2, "rating2");
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");
}
void CGameListCtrl::BrowseForDirectory()
@ -252,11 +276,11 @@ void CGameListCtrl::BrowseForDirectory()
SConfig::GetInstance().SaveSettings();
}
Update();
ReloadList();
}
}
void CGameListCtrl::Update()
void CGameListCtrl::ReloadList()
{
int scrollPos = wxWindow::GetScrollPos(wxVERTICAL);
// Don't let the user refresh it while a game is running
@ -297,20 +321,22 @@ void CGameListCtrl::Update()
// set initial sizes for columns
SetColumnWidth(COLUMN_DUMMY, 0);
SetColumnWidth(COLUMN_PLATFORM, SConfig::GetInstance().m_showSystemColumn ?
32 + platform_icon_padding + platform_padding :
FromDIP(32 + platform_icon_padding + platform_padding) :
0);
SetColumnWidth(COLUMN_BANNER,
SConfig::GetInstance().m_showBannerColumn ? 96 + platform_padding : 0);
SetColumnWidth(COLUMN_TITLE, 175 + platform_padding);
SConfig::GetInstance().m_showBannerColumn ? FromDIP(96 + platform_padding) : 0);
SetColumnWidth(COLUMN_TITLE, FromDIP(175 + platform_padding));
SetColumnWidth(COLUMN_MAKER,
SConfig::GetInstance().m_showMakerColumn ? 150 + platform_padding : 0);
SetColumnWidth(COLUMN_FILENAME,
SConfig::GetInstance().m_showFileNameColumn ? 100 + platform_padding : 0);
SetColumnWidth(COLUMN_ID, SConfig::GetInstance().m_showIDColumn ? 75 + platform_padding : 0);
SConfig::GetInstance().m_showMakerColumn ? FromDIP(150 + platform_padding) : 0);
SetColumnWidth(COLUMN_FILENAME, SConfig::GetInstance().m_showFileNameColumn ?
FromDIP(100 + platform_padding) :
0);
SetColumnWidth(COLUMN_ID,
SConfig::GetInstance().m_showIDColumn ? FromDIP(75 + platform_padding) : 0);
SetColumnWidth(COLUMN_COUNTRY,
SConfig::GetInstance().m_showRegionColumn ? 32 + platform_padding : 0);
SConfig::GetInstance().m_showRegionColumn ? FromDIP(32 + platform_padding) : 0);
SetColumnWidth(COLUMN_EMULATION_STATE,
SConfig::GetInstance().m_showStateColumn ? 48 + platform_padding : 0);
SConfig::GetInstance().m_showStateColumn ? FromDIP(48 + platform_padding) : 0);
// add all items
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
@ -502,7 +528,7 @@ void CGameListCtrl::SetBackgroundColor()
void CGameListCtrl::ScanForISOs()
{
ClearIsoFiles();
m_ISOFiles.clear();
// Load custom game titles from titles.txt
// http://www.gametdb.com/Wii/Downloads
@ -1098,7 +1124,7 @@ void CGameListCtrl::OnDeleteISO(wxCommandEvent& WXUNUSED(event))
{
for (const GameListItem* iso : GetAllSelectedISOs())
File::Delete(iso->GetFileName());
Update();
ReloadList();
}
}
@ -1269,7 +1295,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
if (!all_good)
WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action."));
Update();
ReloadList();
}
bool CGameListCtrl::CompressCB(const std::string& text, float percent, void* arg)
@ -1342,7 +1368,7 @@ void CGameListCtrl::OnCompressISO(wxCommandEvent& WXUNUSED(event))
if (!all_good)
WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action."));
Update();
ReloadList();
}
void CGameListCtrl::OnChangeDisc(wxCommandEvent& WXUNUSED(event))

View File

@ -38,7 +38,7 @@ public:
long style);
~CGameListCtrl();
void Update() override;
void ReloadList();
void BrowseForDirectory();
const GameListItem* GetISO(size_t index) const;

View File

@ -283,19 +283,16 @@ bool GameListItem::ReadPNGBanner(const std::string& path)
wxBitmap GameListItem::ScaleBanner(wxImage* image)
{
const double gui_scale = wxTheApp->GetTopWindow()->GetContentScaleFactor();
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_HIGH);
wxIMAGE_QUALITY_BICUBIC);
image->Resize(wxSize(target_width, target_height), wxPoint(), 0xFF, 0xFF, 0xFF);
#ifdef __APPLE__
return wxBitmap(*image, -1, gui_scale);
#else
return wxBitmap(*image, -1);
#endif
return wxBitmap(*image, wxBITMAP_SCREEN_DEPTH, window->GetContentScaleFactor());
}
std::string GameListItem::GetDescription(DiscIO::Language language) const

View File

@ -53,25 +53,6 @@
#include <X11/Xlib.h>
#endif
#ifdef _WIN32
#ifndef SM_XVIRTUALSCREEN
#define SM_XVIRTUALSCREEN 76
#endif
#ifndef SM_YVIRTUALSCREEN
#define SM_YVIRTUALSCREEN 77
#endif
#ifndef SM_CXVIRTUALSCREEN
#define SM_CXVIRTUALSCREEN 78
#endif
#ifndef SM_CYVIRTUALSCREEN
#define SM_CYVIRTUALSCREEN 79
#endif
#endif
class wxFrame;
// ------------
// Main window
@ -130,31 +111,14 @@ bool DolphinApp::OnInit()
// Enable the PNG image handler for screenshots
wxImage::AddHandler(new wxPNGHandler);
int x = SConfig::GetInstance().iPosX;
int y = SConfig::GetInstance().iPosY;
int w = SConfig::GetInstance().iWidth;
int h = SConfig::GetInstance().iHeight;
// The following is not needed with X11, where window managers
// do not allow windows to be created off the desktop.
#ifdef _WIN32
// Out of desktop check
int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y)
x = y = wxDefaultCoord;
#elif defined __APPLE__
if (y < 1)
y = wxDefaultCoord;
#endif
main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h),
// We have to copy the size and position out of SConfig now because CFrame's OnMove
// handler will corrupt them during window creation (various APIs like SetMenuBar cause
// event dispatch including WM_MOVE/WM_SIZE)
wxRect window_geometry(SConfig::GetInstance().iPosX, SConfig::GetInstance().iPosY,
SConfig::GetInstance().iWidth, SConfig::GetInstance().iHeight);
main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), window_geometry,
m_use_debugger, m_batch_mode, m_use_logger);
SetTopWindow(main_frame);
main_frame->SetMinSize(wxSize(400, 300));
AfterInit();