mirror of https://github.com/PCSX2/pcsx2.git
Make register list scrollable
This commit is contained in:
parent
80db2abe3d
commit
cbd7aed0f3
|
@ -22,7 +22,7 @@
|
||||||
#include "DisassemblyDialog.h"
|
#include "DisassemblyDialog.h"
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(CtrlRegisterList, wxWindow)
|
BEGIN_EVENT_TABLE(CtrlRegisterList, wxWindow)
|
||||||
EVT_PAINT(CtrlRegisterList::paintEvent)
|
EVT_SIZE(CtrlRegisterList::sizeEvent)
|
||||||
EVT_LEFT_DOWN(CtrlRegisterList::mouseEvent)
|
EVT_LEFT_DOWN(CtrlRegisterList::mouseEvent)
|
||||||
EVT_RIGHT_DOWN(CtrlRegisterList::mouseEvent)
|
EVT_RIGHT_DOWN(CtrlRegisterList::mouseEvent)
|
||||||
EVT_RIGHT_UP(CtrlRegisterList::mouseEvent)
|
EVT_RIGHT_UP(CtrlRegisterList::mouseEvent)
|
||||||
|
@ -42,7 +42,7 @@ enum DisassemblyMenuIdentifiers
|
||||||
|
|
||||||
|
|
||||||
CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu)
|
CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu)
|
||||||
: wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxBORDER_NONE), cpu(_cpu)
|
: wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxBORDER_NONE|wxVSCROLL), cpu(_cpu)
|
||||||
{
|
{
|
||||||
rowHeight = getDebugFontHeight()+2;
|
rowHeight = getDebugFontHeight()+2;
|
||||||
charWidth = getDebugFontWidth();
|
charWidth = getDebugFontWidth();
|
||||||
|
@ -71,6 +71,35 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu)
|
||||||
|
|
||||||
SetDoubleBuffered(true);
|
SetDoubleBuffered(true);
|
||||||
SetInitialSize(ClientToWindowSize(GetMinClientSize()));
|
SetInitialSize(ClientToWindowSize(GetMinClientSize()));
|
||||||
|
|
||||||
|
wxSize actualSize = getOptimalSize();
|
||||||
|
SetVirtualSize(actualSize);
|
||||||
|
SetScrollbars(1, rowHeight, actualSize.x, actualSize.y / rowHeight, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize CtrlRegisterList::getOptimalSize() const
|
||||||
|
{
|
||||||
|
int columnChars = 0;
|
||||||
|
int maxWidth = 0;
|
||||||
|
int maxRows = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < cpu->getRegisterCategoryCount(); i++)
|
||||||
|
{
|
||||||
|
int bits = std::min<u32>(maxBits, cpu->getRegisterSize(i));
|
||||||
|
int start = startPositions[i];
|
||||||
|
|
||||||
|
int w = start + (bits / 4) * charWidth;
|
||||||
|
if (bits > 32)
|
||||||
|
w += (bits / 32) * 2 - 2;
|
||||||
|
|
||||||
|
maxWidth = std::max<int>(maxWidth, w);
|
||||||
|
columnChars += strlen(cpu->getRegisterCategoryName(i)) + 1;
|
||||||
|
maxRows = std::max<int>(maxRows, cpu->getRegisterCount(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
maxWidth = std::max<int>(columnChars*charWidth, maxWidth + 4);
|
||||||
|
|
||||||
|
return wxSize(maxWidth, (maxRows + 1)*rowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlRegisterList::postEvent(wxEventType type, wxString text)
|
void CtrlRegisterList::postEvent(wxEventType type, wxString text)
|
||||||
|
@ -136,16 +165,15 @@ void CtrlRegisterList::refreshChangedRegs()
|
||||||
lastPc = cpu->getPC();
|
lastPc = cpu->getPC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlRegisterList::paintEvent(wxPaintEvent & evt)
|
|
||||||
{
|
|
||||||
wxPaintDC dc(this);
|
|
||||||
render(dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlRegisterList::redraw()
|
void CtrlRegisterList::redraw()
|
||||||
{
|
{
|
||||||
wxClientDC dc(this);
|
Update();
|
||||||
render(dc);
|
}
|
||||||
|
|
||||||
|
void CtrlRegisterList::sizeEvent(wxSizeEvent& evt)
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawU32Text(wxDC& dc, u32 value, int x, int y)
|
void drawU32Text(wxDC& dc, u32 value, int x, int y)
|
||||||
|
@ -155,7 +183,7 @@ void drawU32Text(wxDC& dc, u32 value, int x, int y)
|
||||||
dc.DrawText(wxString(str,wxConvUTF8),x,y);
|
dc.DrawText(wxString(str,wxConvUTF8),x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlRegisterList::render(wxDC& dc)
|
void CtrlRegisterList::OnDraw(wxDC& dc)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console");
|
wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console");
|
||||||
|
@ -171,7 +199,7 @@ void CtrlRegisterList::render(wxDC& dc)
|
||||||
dc.SetBrush(wxBrush(white));
|
dc.SetBrush(wxBrush(white));
|
||||||
dc.SetPen(wxPen(white));
|
dc.SetPen(wxPen(white));
|
||||||
|
|
||||||
wxSize size = GetSize();
|
wxSize size = GetClientSize();
|
||||||
dc.DrawRectangle(0,0,size.x,size.y);
|
dc.DrawRectangle(0,0,size.x,size.y);
|
||||||
|
|
||||||
refreshChangedRegs();
|
refreshChangedRegs();
|
||||||
|
@ -442,10 +470,16 @@ void CtrlRegisterList::setCurrentRow(int row)
|
||||||
|
|
||||||
void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
|
void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
|
int xOffset, yOffset;
|
||||||
|
((wxScrolledWindow*) this)->GetViewStart(&xOffset, &yOffset);
|
||||||
|
|
||||||
|
wxClientDC dc(this);
|
||||||
|
wxPoint pos = evt.GetPosition();
|
||||||
|
int x = dc.DeviceToLogicalX(pos.x) + xOffset;
|
||||||
|
int y = dc.DeviceToLogicalY(pos.y) + yOffset;
|
||||||
|
|
||||||
if (evt.GetEventType() == wxEVT_RIGHT_UP)
|
if (evt.GetEventType() == wxEVT_RIGHT_UP)
|
||||||
{
|
{
|
||||||
int y = evt.GetPosition().y;
|
|
||||||
|
|
||||||
if (y >= rowHeight)
|
if (y >= rowHeight)
|
||||||
{
|
{
|
||||||
int row = (y-rowHeight)/rowHeight;
|
int row = (y-rowHeight)/rowHeight;
|
||||||
|
@ -489,9 +523,6 @@ void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
|
||||||
|
|
||||||
if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
|
if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
|
||||||
{
|
{
|
||||||
int x = evt.GetPosition().x;
|
|
||||||
int y = evt.GetPosition().y;
|
|
||||||
|
|
||||||
if (y < rowHeight)
|
if (y < rowHeight)
|
||||||
{
|
{
|
||||||
int piece = GetSize().x/cpu->getRegisterCategoryCount();
|
int piece = GetSize().x/cpu->getRegisterCategoryCount();
|
||||||
|
@ -521,7 +552,7 @@ void CtrlRegisterList::keydownEvent(wxKeyEvent& evt)
|
||||||
setCurrentRow(std::max<int>(currentRows[category]-1,0));
|
setCurrentRow(std::max<int>(currentRows[category]-1,0));
|
||||||
break;
|
break;
|
||||||
case WXK_DOWN:
|
case WXK_DOWN:
|
||||||
setCurrentRow(std::min<int>(currentRows[category]+1,cpu->getRegisterCount(category)));
|
setCurrentRow(std::min<int>(currentRows[category]+1,cpu->getRegisterCount(category)-1));
|
||||||
break;
|
break;
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
category = (category+1) % cpu->getRegisterCategoryCount();
|
category = (category+1) % cpu->getRegisterCategoryCount();
|
||||||
|
|
|
@ -19,41 +19,25 @@
|
||||||
#include "DebugTools/DebugInterface.h"
|
#include "DebugTools/DebugInterface.h"
|
||||||
#include "DebugTools/DisassemblyManager.h"
|
#include "DebugTools/DisassemblyManager.h"
|
||||||
|
|
||||||
class CtrlRegisterList: public wxWindow
|
class CtrlRegisterList: public wxScrolledWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu);
|
CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu);
|
||||||
|
|
||||||
void paintEvent(wxPaintEvent & evt);
|
|
||||||
void mouseEvent(wxMouseEvent& evt);
|
void mouseEvent(wxMouseEvent& evt);
|
||||||
void keydownEvent(wxKeyEvent& evt);
|
void keydownEvent(wxKeyEvent& evt);
|
||||||
void onPopupClick(wxCommandEvent& evt);
|
void onPopupClick(wxCommandEvent& evt);
|
||||||
|
void sizeEvent(wxSizeEvent& evt);
|
||||||
void redraw();
|
void redraw();
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
virtual wxSize GetMinClientSize() const
|
virtual wxSize GetMinClientSize() const
|
||||||
{
|
{
|
||||||
int columnChars = 0;
|
wxSize optimalSize = getOptimalSize();
|
||||||
int maxWidth = 0;
|
if (GetWindowStyle() & wxVSCROLL)
|
||||||
int maxRows = 0;
|
optimalSize.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||||
|
|
||||||
for (int i = 0; i < cpu->getRegisterCategoryCount(); i++)
|
return wxSize(optimalSize.x,0);
|
||||||
{
|
|
||||||
int bits = std::min<u32>(maxBits,cpu->getRegisterSize(i));
|
|
||||||
int start = startPositions[i];
|
|
||||||
|
|
||||||
int w = start+(bits/4) * charWidth;
|
|
||||||
if (bits > 32)
|
|
||||||
w += (bits/32)*2-2;
|
|
||||||
|
|
||||||
maxWidth = std::max<int>(maxWidth,w);
|
|
||||||
columnChars += strlen(cpu->getRegisterCategoryName(i))+1;
|
|
||||||
maxRows = std::max<int>(maxRows,cpu->getRegisterCount(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
maxWidth = std::max<int>(columnChars*charWidth,maxWidth+4);
|
|
||||||
|
|
||||||
return wxSize(maxWidth,(maxRows+1)*rowHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual wxSize DoGetBestClientSize() const
|
virtual wxSize DoGetBestClientSize() const
|
||||||
|
@ -63,10 +47,11 @@ public:
|
||||||
private:
|
private:
|
||||||
enum RegisterChangeMode { LOWER64, UPPER64, CHANGE32 };
|
enum RegisterChangeMode { LOWER64, UPPER64, CHANGE32 };
|
||||||
|
|
||||||
void render(wxDC& dc);
|
void OnDraw(wxDC& dc);
|
||||||
void refreshChangedRegs();
|
void refreshChangedRegs();
|
||||||
void setCurrentRow(int row);
|
void setCurrentRow(int row);
|
||||||
void changeValue(RegisterChangeMode mode);
|
void changeValue(RegisterChangeMode mode);
|
||||||
|
wxSize getOptimalSize() const;
|
||||||
|
|
||||||
void postEvent(wxEventType type, wxString text);
|
void postEvent(wxEventType type, wxString text);
|
||||||
void postEvent(wxEventType type, int value);
|
void postEvent(wxEventType type, int value);
|
||||||
|
|
Loading…
Reference in New Issue