mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-29 07:37:03 +00:00
UI: Use wxListView instead of wxListCtrl (#1584)
This commit is contained in:
parent
3eff2d4a60
commit
2eec6b44c3
14 changed files with 61 additions and 65 deletions
|
|
@ -25,9 +25,8 @@
|
|||
|
||||
wxDEFINE_EVENT(wxEVT_REMOVE_ENTRY, wxCommandEvent);
|
||||
|
||||
|
||||
wxDownloadManagerList::wxDownloadManagerList(wxWindow* parent, wxWindowID id)
|
||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL)
|
||||
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL)
|
||||
{
|
||||
AddColumns();
|
||||
|
||||
|
|
@ -52,7 +51,7 @@ wxDownloadManagerList::wxDownloadManagerList(wxWindow* parent, wxWindowID id)
|
|||
|
||||
boost::optional<const wxDownloadManagerList::TitleEntry&> wxDownloadManagerList::GetSelectedTitleEntry() const
|
||||
{
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto tmp = GetTitleEntry(selection);
|
||||
|
|
@ -65,7 +64,7 @@ boost::optional<const wxDownloadManagerList::TitleEntry&> wxDownloadManagerList:
|
|||
|
||||
boost::optional<wxDownloadManagerList::TitleEntry&> wxDownloadManagerList::GetSelectedTitleEntry()
|
||||
{
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto tmp = GetTitleEntry(selection);
|
||||
|
|
@ -324,7 +323,7 @@ void wxDownloadManagerList::OnContextMenu(wxContextMenuEvent& event)
|
|||
wxMenu menu;
|
||||
menu.Bind(wxEVT_COMMAND_MENU_SELECTED, &wxDownloadManagerList::OnContextMenuSelected, this);
|
||||
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
|
|
@ -379,8 +378,8 @@ void wxDownloadManagerList::OnContextMenuSelected(wxCommandEvent& event)
|
|||
// still doing work
|
||||
if (m_context_worker.valid() && !future_is_ready(m_context_worker))
|
||||
return;
|
||||
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class wxDownloadManagerList : public wxListCtrl
|
||||
class wxDownloadManagerList : public wxListView
|
||||
{
|
||||
friend class TitleManager;
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <numeric>
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/wupdlock.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/mstream.h>
|
||||
|
|
@ -133,7 +134,7 @@ bool writeICNS(const fs::path& pngPath, const fs::path& icnsPath) {
|
|||
}
|
||||
|
||||
wxGameList::wxGameList(wxWindow* parent, wxWindowID id)
|
||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, GetStyleFlags(Style::kList)), m_style(Style::kList)
|
||||
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, GetStyleFlags(Style::kList)), m_style(Style::kList)
|
||||
{
|
||||
const auto& config = GetConfig();
|
||||
|
||||
|
|
@ -393,7 +394,7 @@ void wxGameList::SetStyle(Style style, bool save)
|
|||
SetWindowStyleFlag(GetStyleFlags(m_style));
|
||||
|
||||
uint64 selected_title_id = 0;
|
||||
auto selection = GetNextItem(wxNOT_FOUND, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
selected_title_id = (uint64)GetItemData(selection);
|
||||
|
|
@ -416,8 +417,8 @@ void wxGameList::SetStyle(Style style, bool save)
|
|||
|
||||
if(selection != wxNOT_FOUND)
|
||||
{
|
||||
SetItemState(selection, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
EnsureVisible(selection);
|
||||
Select(selection);
|
||||
Focus(selection);
|
||||
}
|
||||
|
||||
if(save)
|
||||
|
|
@ -549,15 +550,14 @@ void wxGameList::OnKeyDown(wxListEvent& event)
|
|||
const auto item_count = GetItemCount();
|
||||
if (item_count > 0)
|
||||
{
|
||||
auto selection = (int)GetNextItem(wxNOT_FOUND, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
auto selection = (int)GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
selection = 0;
|
||||
else
|
||||
selection = std::max(0, selection - GetCountPerPage());
|
||||
|
||||
SetItemState(wxNOT_FOUND, 0, wxLIST_STATE_SELECTED);
|
||||
SetItemState(selection, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
EnsureVisible(selection);
|
||||
Select(selection);
|
||||
Focus(selection);
|
||||
}
|
||||
}
|
||||
else if (keycode == WXK_RIGHT)
|
||||
|
|
@ -565,15 +565,14 @@ void wxGameList::OnKeyDown(wxListEvent& event)
|
|||
const auto item_count = GetItemCount();
|
||||
if (item_count > 0)
|
||||
{
|
||||
auto selection = (int)GetNextItem(wxNOT_FOUND, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
auto selection = (int)GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
selection = 0;
|
||||
|
||||
selection = std::min(item_count - 1, selection + GetCountPerPage());
|
||||
|
||||
SetItemState(wxNOT_FOUND, 0, wxLIST_STATE_SELECTED);
|
||||
SetItemState(selection, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
EnsureVisible(selection);
|
||||
Select(selection);
|
||||
Focus(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -613,7 +612,7 @@ void wxGameList::OnContextMenu(wxContextMenuEvent& event)
|
|||
wxMenu menu;
|
||||
menu.Bind(wxEVT_COMMAND_MENU_SELECTED, &wxGameList::OnContextMenuSelected, this);
|
||||
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto title_id = (uint64)GetItemData(selection);
|
||||
|
|
@ -1632,4 +1631,4 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
|
|||
wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ wxDECLARE_EVENT(wxEVT_OPEN_GRAPHIC_PACK, wxTitleIdEvent);
|
|||
wxDECLARE_EVENT(wxEVT_GAMELIST_BEGIN_UPDATE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(wxEVT_GAMELIST_END_UPDATE, wxCommandEvent);
|
||||
|
||||
class wxGameList : public wxListCtrl
|
||||
class wxGameList : public wxListView
|
||||
{
|
||||
friend class MainWindow;
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ wxDEFINE_EVENT(wxEVT_TITLE_REMOVED, wxCommandEvent);
|
|||
wxDEFINE_EVENT(wxEVT_REMOVE_ENTRY, wxCommandEvent);
|
||||
|
||||
wxTitleManagerList::wxTitleManagerList(wxWindow* parent, wxWindowID id)
|
||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL)
|
||||
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL)
|
||||
{
|
||||
AddColumns();
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ wxTitleManagerList::~wxTitleManagerList()
|
|||
|
||||
boost::optional<const wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetSelectedTitleEntry() const
|
||||
{
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto tmp = GetTitleEntry(selection);
|
||||
|
|
@ -87,7 +87,7 @@ boost::optional<const wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetSe
|
|||
|
||||
boost::optional<wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetSelectedTitleEntry()
|
||||
{
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto tmp = GetTitleEntry(selection);
|
||||
|
|
@ -757,7 +757,7 @@ void wxTitleManagerList::OnContextMenu(wxContextMenuEvent& event)
|
|||
wxMenu menu;
|
||||
menu.Bind(wxEVT_COMMAND_MENU_SELECTED, &wxTitleManagerList::OnContextMenuSelected, this);
|
||||
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
|
|
@ -855,8 +855,8 @@ void wxTitleManagerList::OnContextMenuSelected(wxCommandEvent& event)
|
|||
// still doing work
|
||||
if (m_context_worker.valid() && !future_is_ready(m_context_worker))
|
||||
return;
|
||||
|
||||
const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
|
||||
const auto selection = GetFirstSelected();
|
||||
if (selection == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class wxTitleManagerList : public wxListCtrl
|
||||
class wxTitleManagerList : public wxListView
|
||||
{
|
||||
friend class TitleManager;
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue