dolphin/Source/Core/DolphinWX/GameListCtrl.h
Christian Widmer 4d78aea41d DolphinWX: Add items to visible columns only
Before the columns of the gamelist were filled with content regardless
of their visibility. This led to display bugs when certain columns, for
example the region column, were hidden.

The first problem was the InsertItemInReportView() function because it
refilled all columns with content on every call to update() without
checking for their visibility. While this issue would have easily been solved
by adding conditionals before each column update, the maker column would
have still caused problems for it autohides on resize and those do not
call update(). Therefore it was necessary to move the column update logic
from InsertItemInReportView() to a new one that allows for seperate
modification of an item's columns.
2015-10-11 05:01:59 +02:00

114 lines
2.9 KiB
C++

// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <cstddef>
#include <string>
#include <vector>
#include <wx/listctrl.h>
#include <wx/tipwin.h>
#include "DolphinWX/ISOFile.h"
class wxEmuStateTip : public wxTipWindow
{
public:
wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr)
: wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr)
{
Bind(wxEVT_KEY_DOWN, &wxEmuStateTip::OnKeyDown, this);
}
// wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that.
void OnKeyDown(wxKeyEvent& event) { event.StopPropagation(); Close(); }
};
class CGameListCtrl : public wxListCtrl
{
public:
CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
~CGameListCtrl();
void Update() override;
void BrowseForDirectory();
const GameListItem *GetSelectedISO();
const GameListItem *GetISO(size_t index) const;
enum
{
COLUMN_DUMMY = 0,
COLUMN_PLATFORM,
COLUMN_BANNER,
COLUMN_TITLE,
COLUMN_MAKER,
COLUMN_ID,
COLUMN_COUNTRY,
COLUMN_SIZE,
COLUMN_EMULATION_STATE,
NUMBER_OF_COLUMN
};
private:
std::vector<int> m_FlagImageIndex;
std::vector<int> m_PlatformImageIndex;
std::vector<int> m_EmuStateImageIndex;
std::vector<GameListItem*> m_ISOFiles;
void ClearIsoFiles()
{
while (!m_ISOFiles.empty()) // so lazy
{
delete m_ISOFiles.back();
m_ISOFiles.pop_back();
}
}
int last_column;
int last_sort;
wxSize lastpos;
wxEmuStateTip *toolTip;
void InitBitmaps();
void UpdateItemAtColumn(long _Index, int column);
void InsertItemInReportView(long _Index);
void SetBackgroundColor();
void ScanForISOs();
// events
void OnLeftClick(wxMouseEvent& event);
void OnRightClick(wxMouseEvent& event);
void OnMouseMotion(wxMouseEvent& event);
void OnColumnClick(wxListEvent& event);
void OnColBeginDrag(wxListEvent& event);
void OnKeyPress(wxListEvent& event);
void OnSize(wxSizeEvent& event);
void OnProperties(wxCommandEvent& event);
void OnWiki(wxCommandEvent& event);
void OnOpenContainingFolder(wxCommandEvent& event);
void OnOpenSaveFolder(wxCommandEvent& event);
void OnExportSave(wxCommandEvent& event);
void OnSetDefaultISO(wxCommandEvent& event);
void OnDeleteISO(wxCommandEvent& event);
void OnCompressISO(wxCommandEvent& event);
void OnMultiCompressISO(wxCommandEvent& event);
void OnMultiDecompressISO(wxCommandEvent& event);
void OnChangeDisc(wxCommandEvent& event);
void CompressSelection(bool _compress);
void AutomaticColumnWidth();
void ShowColumn(int column, int width);
void HideColumn(int column);
void UnselectAll();
static size_t m_currentItem;
static std::string m_currentFilename;
static size_t m_numberItem;
static bool CompressCB(const std::string& text, float percent, void* arg);
static bool MultiCompressCB(const std::string& text, float percent, void* arg);
};