mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-08 03:28:31 +03:00
Refactor GameListCtrl
This commit is contained in:
parent
8028564a07
commit
303b54a3a5
2 changed files with 46 additions and 64 deletions
|
@ -273,9 +273,28 @@ static bool ShouldDisplayGameListItem(const GameListItem& item)
|
||||||
|
|
||||||
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent);
|
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent);
|
||||||
|
|
||||||
|
struct CGameListCtrl::ColumnInfo
|
||||||
|
{
|
||||||
|
const int id;
|
||||||
|
const int default_width;
|
||||||
|
const bool resizable;
|
||||||
|
bool& visible;
|
||||||
|
};
|
||||||
|
|
||||||
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos,
|
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos,
|
||||||
const wxSize& size, long style)
|
const wxSize& size, long style)
|
||||||
: wxListCtrl(parent, id, pos, size, style), toolTip(nullptr)
|
: wxListCtrl(parent, id, pos, size, style), toolTip(nullptr),
|
||||||
|
m_columns({// {COLUMN, {default_width (without platform padding), resizability, visibility}}
|
||||||
|
{COLUMN_PLATFORM, 32 + 1 /* icon padding */, false,
|
||||||
|
SConfig::GetInstance().m_showSystemColumn},
|
||||||
|
{COLUMN_BANNER, 96, false, SConfig::GetInstance().m_showBannerColumn},
|
||||||
|
{COLUMN_TITLE, 175, true, SConfig::GetInstance().m_showTitleColumn},
|
||||||
|
{COLUMN_MAKER, 150, true, SConfig::GetInstance().m_showMakerColumn},
|
||||||
|
{COLUMN_FILENAME, 100, true, SConfig::GetInstance().m_showFileNameColumn},
|
||||||
|
{COLUMN_ID, 75, false, SConfig::GetInstance().m_showIDColumn},
|
||||||
|
{COLUMN_COUNTRY, 32, false, SConfig::GetInstance().m_showRegionColumn},
|
||||||
|
{COLUMN_EMULATION_STATE, 48, false, SConfig::GetInstance().m_showStateColumn},
|
||||||
|
{COLUMN_SIZE, wxLIST_AUTOSIZE, false, SConfig::GetInstance().m_showSizeColumn}})
|
||||||
{
|
{
|
||||||
Bind(wxEVT_SIZE, &CGameListCtrl::OnSize, this);
|
Bind(wxEVT_SIZE, &CGameListCtrl::OnSize, this);
|
||||||
Bind(wxEVT_RIGHT_DOWN, &CGameListCtrl::OnRightClick, this);
|
Bind(wxEVT_RIGHT_DOWN, &CGameListCtrl::OnRightClick, this);
|
||||||
|
@ -438,29 +457,13 @@ void CGameListCtrl::ReloadList()
|
||||||
#else
|
#else
|
||||||
const int platform_padding = 8;
|
const int platform_padding = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int platform_icon_padding = 1;
|
|
||||||
|
|
||||||
// set initial sizes for columns
|
// set initial sizes for columns
|
||||||
SetColumnWidth(COLUMN_DUMMY, 0);
|
SetColumnWidth(COLUMN_DUMMY, 0);
|
||||||
SetColumnWidth(COLUMN_PLATFORM, SConfig::GetInstance().m_showSystemColumn ?
|
|
||||||
FromDIP(32 + platform_icon_padding + platform_padding) :
|
for (const auto& c : m_columns)
|
||||||
0);
|
{
|
||||||
SetColumnWidth(COLUMN_BANNER,
|
SetColumnWidth(c.id, c.visible ? FromDIP(c.default_width + platform_padding) : 0);
|
||||||
SConfig::GetInstance().m_showBannerColumn ? FromDIP(96 + platform_padding) : 0);
|
}
|
||||||
SetColumnWidth(COLUMN_TITLE,
|
|
||||||
SConfig::GetInstance().m_showTitleColumn ? FromDIP(175 + platform_padding) : 0);
|
|
||||||
SetColumnWidth(COLUMN_MAKER,
|
|
||||||
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 ? FromDIP(32 + platform_padding) : 0);
|
|
||||||
SetColumnWidth(COLUMN_EMULATION_STATE,
|
|
||||||
SConfig::GetInstance().m_showStateColumn ? FromDIP(48 + platform_padding) : 0);
|
|
||||||
|
|
||||||
// add all items
|
// add all items
|
||||||
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
||||||
|
@ -1430,50 +1433,25 @@ void CGameListCtrl::AutomaticColumnWidth()
|
||||||
}
|
}
|
||||||
else if (GetColumnCount() > 0)
|
else if (GetColumnCount() > 0)
|
||||||
{
|
{
|
||||||
int resizable =
|
int remaining_width = rc.GetWidth();
|
||||||
rc.GetWidth() - (GetColumnWidth(COLUMN_PLATFORM) + GetColumnWidth(COLUMN_BANNER) +
|
std::vector<int> visible_columns;
|
||||||
GetColumnWidth(COLUMN_ID) + GetColumnWidth(COLUMN_COUNTRY) +
|
|
||||||
GetColumnWidth(COLUMN_SIZE) + GetColumnWidth(COLUMN_EMULATION_STATE));
|
for (const auto& c : m_columns)
|
||||||
if (SConfig::GetInstance().m_showTitleColumn && SConfig::GetInstance().m_showMakerColumn &&
|
|
||||||
SConfig::GetInstance().m_showFileNameColumn)
|
|
||||||
{
|
{
|
||||||
SetColumnWidth(COLUMN_TITLE, resizable / 3);
|
if (c.visible)
|
||||||
SetColumnWidth(COLUMN_MAKER, resizable / 3);
|
{
|
||||||
SetColumnWidth(COLUMN_FILENAME, resizable / 3);
|
if (c.resizable)
|
||||||
}
|
visible_columns.push_back(c.id);
|
||||||
else if (SConfig::GetInstance().m_showMakerColumn &&
|
else
|
||||||
SConfig::GetInstance().m_showFileNameColumn)
|
remaining_width -= c.default_width;
|
||||||
{
|
}
|
||||||
SetColumnWidth(COLUMN_MAKER, resizable / 2);
|
|
||||||
SetColumnWidth(COLUMN_FILENAME, resizable / 2);
|
|
||||||
}
|
|
||||||
else if (SConfig::GetInstance().m_showMakerColumn && SConfig::GetInstance().m_showTitleColumn)
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_MAKER, resizable / 2);
|
|
||||||
SetColumnWidth(COLUMN_TITLE, resizable / 2);
|
|
||||||
}
|
|
||||||
else if (SConfig::GetInstance().m_showFileNameColumn &&
|
|
||||||
SConfig::GetInstance().m_showTitleColumn)
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_TITLE, resizable / 2);
|
|
||||||
SetColumnWidth(COLUMN_FILENAME, resizable / 2);
|
|
||||||
}
|
|
||||||
else if (SConfig::GetInstance().m_showMakerColumn)
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_MAKER, resizable);
|
|
||||||
}
|
|
||||||
else if (SConfig::GetInstance().m_showFileNameColumn)
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_FILENAME, resizable);
|
|
||||||
}
|
|
||||||
else if (SConfig::GetInstance().m_showTitleColumn)
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_TITLE, resizable);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetColumnWidth(COLUMN_DUMMY, resizable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visible_columns.empty())
|
||||||
|
visible_columns.push_back(COLUMN_DUMMY);
|
||||||
|
|
||||||
|
for (const int column : visible_columns)
|
||||||
|
SetColumnWidth(column, static_cast<int>(remaining_width / visible_columns.size()));
|
||||||
}
|
}
|
||||||
Thaw();
|
Thaw();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct ColumnInfo;
|
||||||
|
|
||||||
void ReloadList();
|
void ReloadList();
|
||||||
|
|
||||||
void ClearIsoFiles() { m_ISOFiles.clear(); }
|
void ClearIsoFiles() { m_ISOFiles.clear(); }
|
||||||
|
@ -117,4 +119,6 @@ private:
|
||||||
int last_sort;
|
int last_sort;
|
||||||
wxSize lastpos;
|
wxSize lastpos;
|
||||||
wxEmuStateTip* toolTip;
|
wxEmuStateTip* toolTip;
|
||||||
|
|
||||||
|
std::vector<ColumnInfo> m_columns;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue