DolphinWX: Move the CodeView debugger view over to wxGraphicsContext
This is a more advanced drawing 'backend' over the previous one and allows us to control things like transparency and anti-aliasing, etc.
This commit is contained in:
parent
b749a74d33
commit
c3e41809d9
|
@ -6,6 +6,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/brush.h>
|
#include <wx/brush.h>
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/graphics.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/menuitem.h>
|
#include <wx/menuitem.h>
|
||||||
#include <wx/pen.h>
|
#include <wx/pen.h>
|
||||||
|
@ -393,21 +395,21 @@ void CCodeView::OnErase(wxEraseEvent& event)
|
||||||
|
|
||||||
void CCodeView::OnPaint(wxPaintEvent& event)
|
void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------
|
// -------------------------
|
||||||
// General settings
|
// General settings
|
||||||
// -------------------------
|
// -------------------------
|
||||||
wxPaintDC dc(this);
|
std::unique_ptr<wxGraphicsContext> ctx(wxGraphicsContext::Create(wxPaintDC(this)));
|
||||||
wxRect rc = GetClientRect();
|
wxRect rc = GetClientRect();
|
||||||
|
|
||||||
dc.SetFont(DebuggerFont);
|
ctx->SetFont(DebuggerFont, *wxBLACK);
|
||||||
|
|
||||||
wxCoord w,h;
|
wxDouble w,h;
|
||||||
dc.GetTextExtent("0WJyq", &w, &h);
|
ctx->GetTextExtent("0WJyq", &w, &h);
|
||||||
|
|
||||||
if (h > m_rowHeight)
|
if (h > m_rowHeight)
|
||||||
m_rowHeight = h;
|
m_rowHeight = h;
|
||||||
|
|
||||||
dc.GetTextExtent("W", &w, &h);
|
ctx->GetTextExtent("W", &w, &h);
|
||||||
int charWidth = w;
|
int charWidth = w;
|
||||||
|
|
||||||
struct branch
|
struct branch
|
||||||
|
@ -422,10 +424,10 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
int numRows = (rc.height / m_rowHeight) / 2 + 2;
|
int numRows = (rc.height / m_rowHeight) / 2 + 2;
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// -------------------------
|
||||||
// Colors and brushes
|
// Colors and brushes
|
||||||
// -------------------------
|
// -------------------------
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT); // the text background
|
|
||||||
const wxColour bgColor = *wxWHITE;
|
const wxColour bgColor = *wxWHITE;
|
||||||
wxPen nullPen(bgColor);
|
wxPen nullPen(bgColor);
|
||||||
wxPen currentPen(*wxBLACK_PEN);
|
wxPen currentPen(*wxBLACK_PEN);
|
||||||
|
@ -440,15 +442,15 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
wxBrush nullBrush(bgColor);
|
wxBrush nullBrush(bgColor);
|
||||||
nullBrush.SetStyle(wxTRANSPARENT);
|
nullBrush.SetStyle(wxTRANSPARENT);
|
||||||
|
|
||||||
dc.SetPen(nullPen);
|
ctx->SetPen(nullPen);
|
||||||
dc.SetBrush(bgBrush);
|
ctx->SetBrush(bgBrush);
|
||||||
dc.DrawRectangle(0, 0, 16, rc.height);
|
ctx->DrawRectangle(0, 0, 16, rc.height);
|
||||||
dc.DrawRectangle(0, 0, rc.width, 5);
|
ctx->DrawRectangle(0, 0, rc.width, 5);
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// -----------------------------
|
||||||
// Walk through all visible rows
|
// Walk through all visible rows
|
||||||
// -------------------------
|
// -----------------------------
|
||||||
for (int i = -numRows; i <= numRows; i++)
|
for (int i = -numRows; i <= numRows; i++)
|
||||||
{
|
{
|
||||||
unsigned int address = m_curAddress + i * m_align;
|
unsigned int address = m_curAddress + i * m_align;
|
||||||
|
@ -459,27 +461,28 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
wxString temp = wxString::Format("%08x", address);
|
wxString temp = wxString::Format("%08x", address);
|
||||||
u32 col = m_debugger->GetColor(address);
|
u32 col = m_debugger->GetColor(address);
|
||||||
wxBrush rowBrush(wxColour(col >> 16, col >> 8, col));
|
wxBrush rowBrush(wxColour(col >> 16, col >> 8, col));
|
||||||
dc.SetBrush(nullBrush);
|
ctx->SetBrush(nullBrush);
|
||||||
dc.SetPen(nullPen);
|
ctx->SetPen(nullPen);
|
||||||
dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);
|
ctx->DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);
|
||||||
|
|
||||||
if (m_selecting && (address == m_selection))
|
if (m_selecting && (address == m_selection))
|
||||||
dc.SetPen(selPen);
|
ctx->SetPen(selPen);
|
||||||
else
|
else
|
||||||
dc.SetPen(i == 0 ? currentPen : nullPen);
|
ctx->SetPen(i == 0 ? currentPen : nullPen);
|
||||||
|
|
||||||
if (address == m_debugger->GetPC())
|
if (address == m_debugger->GetPC())
|
||||||
dc.SetBrush(pcBrush);
|
ctx->SetBrush(pcBrush);
|
||||||
else
|
else
|
||||||
dc.SetBrush(rowBrush);
|
ctx->SetBrush(rowBrush);
|
||||||
|
|
||||||
dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
|
ctx->DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
|
||||||
dc.SetBrush(currentBrush);
|
ctx->SetBrush(currentBrush);
|
||||||
if (!m_plain)
|
if (!m_plain)
|
||||||
{
|
{
|
||||||
dc.SetTextForeground("#600000"); // the address text is dark red
|
// the address text is dark red
|
||||||
dc.DrawText(temp, 17, rowY1);
|
ctx->SetFont(DebuggerFont, wxColour("#600000"));
|
||||||
dc.SetTextForeground(*wxBLACK);
|
ctx->DrawText(temp, 17, rowY1);
|
||||||
|
ctx->SetFont(DebuggerFont, *wxBLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If running
|
// If running
|
||||||
|
@ -510,23 +513,23 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
branches[numBranches].srcAddr = address / m_align;
|
branches[numBranches].srcAddr = address / m_align;
|
||||||
branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * m_rowHeight / m_align + m_rowHeight / 2);
|
branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * m_rowHeight / m_align + m_rowHeight / 2);
|
||||||
desc = StringFromFormat("-->%s", m_debugger->GetDescription(offs).c_str());
|
desc = StringFromFormat("-->%s", m_debugger->GetDescription(offs).c_str());
|
||||||
dc.SetTextForeground(wxTheColourDatabase->Find("PURPLE")); // the -> arrow illustrations are purple
|
ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("PURPLE")); // the -> arrow illustrations are purple
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dc.SetTextForeground(*wxBLACK);
|
ctx->SetFont(DebuggerFont, *wxBLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.DrawText(StrToWxStr(operands), 17 + 17*charWidth, rowY1);
|
ctx->DrawText(StrToWxStr(operands), 17 + 17*charWidth, rowY1);
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
// Show blr as its' own color
|
// Show blr as its' own color
|
||||||
if (opcode == "blr")
|
if (opcode == "blr")
|
||||||
dc.SetTextForeground(wxTheColourDatabase->Find("DARK GREEN"));
|
ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("DARK GREEN"));
|
||||||
else
|
else
|
||||||
dc.SetTextForeground(wxTheColourDatabase->Find("VIOLET"));
|
ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("VIOLET"));
|
||||||
|
|
||||||
dc.DrawText(StrToWxStr(opcode), 17 + (m_plain ? 1*charWidth : 9*charWidth), rowY1);
|
ctx->DrawText(StrToWxStr(opcode), 17 + (m_plain ? 1*charWidth : 9*charWidth), rowY1);
|
||||||
|
|
||||||
if (desc.empty())
|
if (desc.empty())
|
||||||
{
|
{
|
||||||
|
@ -535,30 +538,30 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
|
|
||||||
if (!m_plain)
|
if (!m_plain)
|
||||||
{
|
{
|
||||||
dc.SetTextForeground(*wxBLUE);
|
ctx->SetFont(DebuggerFont, *wxBLUE);
|
||||||
|
|
||||||
//char temp[256];
|
//char temp[256];
|
||||||
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
|
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
|
||||||
if (!desc.empty())
|
if (!desc.empty())
|
||||||
{
|
{
|
||||||
dc.DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1);
|
ctx->DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show red breakpoint dot
|
// Show red breakpoint dot
|
||||||
if (m_debugger->IsBreakpoint(address))
|
if (m_debugger->IsBreakpoint(address))
|
||||||
{
|
{
|
||||||
dc.SetBrush(bpBrush);
|
ctx->SetBrush(bpBrush);
|
||||||
dc.DrawRectangle(2, rowY1 + 1, 11, 11);
|
ctx->DrawRectangle(2, rowY1 + 1, 11, 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end of for
|
} // end of for
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// -------------------------
|
||||||
// Colors and brushes
|
// Colors and brushes
|
||||||
// -------------------------
|
// -------------------------
|
||||||
dc.SetPen(currentPen);
|
ctx->SetPen(currentPen);
|
||||||
|
|
||||||
for (int i = 0; i < numBranches; i++)
|
for (int i = 0; i < numBranches; i++)
|
||||||
{
|
{
|
||||||
|
@ -567,34 +570,36 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
||||||
|
|
||||||
if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
|
if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
|
||||||
{
|
{
|
||||||
LineTo(dc, x+2, branches[i].src);
|
LineTo(ctx, x+2, branches[i].src);
|
||||||
LineTo(dc, x+2, branches[i].dst);
|
LineTo(ctx, x+2, branches[i].dst);
|
||||||
LineTo(dc, x-4, branches[i].dst);
|
LineTo(ctx, x-4, branches[i].dst);
|
||||||
|
|
||||||
MoveTo(x, branches[i].dst - 4);
|
MoveTo(x, branches[i].dst - 4);
|
||||||
LineTo(dc, x-4, branches[i].dst);
|
LineTo(ctx, x-4, branches[i].dst);
|
||||||
LineTo(dc, x+1, branches[i].dst+5);
|
LineTo(ctx, x+1, branches[i].dst+5);
|
||||||
}
|
}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
// This can be re-enabled when there is a scrollbar or
|
// This can be re-enabled when there is a scrollbar or
|
||||||
// something on the codeview (the lines are too long)
|
// something on the codeview (the lines are too long)
|
||||||
|
|
||||||
//LineTo(dc, x+4, branches[i].src);
|
//LineTo(ctx, x+4, branches[i].src);
|
||||||
//MoveTo(x+2, branches[i].dst-4);
|
//MoveTo(x+2, branches[i].dst-4);
|
||||||
//LineTo(dc, x+6, branches[i].dst);
|
//LineTo(ctx, x+6, branches[i].dst);
|
||||||
//LineTo(dc, x+1, branches[i].dst+5);
|
//LineTo(ctx, x+1, branches[i].dst+5);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//LineTo(dc, x, branches[i].dst+4);
|
//LineTo(ctx, x, branches[i].dst+4);
|
||||||
//LineTo(dc, x-2, branches[i].dst);
|
//LineTo(ctx, x-2, branches[i].dst);
|
||||||
}
|
}
|
||||||
// ------------
|
// ------------
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCodeView::LineTo(wxPaintDC &dc, int x, int y)
|
void CCodeView::LineTo(std::unique_ptr<wxGraphicsContext>& ctx, int x, int y)
|
||||||
{
|
{
|
||||||
dc.DrawLine(m_lx, m_ly, x, y);
|
std::vector<wxPoint2DDouble> points { wxPoint2DDouble(m_lx, m_ly), wxPoint2DDouble(x, y) };
|
||||||
|
|
||||||
|
ctx->DrawLines(points.size(), points.data());
|
||||||
m_lx = x;
|
m_lx = x;
|
||||||
m_ly = y;
|
m_ly = y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
#define wxUSE_XPM_IN_MSW 1
|
#define wxUSE_XPM_IN_MSW 1
|
||||||
#define USE_XPM_BITMAPS 1
|
#define USE_XPM_BITMAPS 1
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/control.h>
|
#include <wx/control.h>
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
|
#include <wx/graphics.h>
|
||||||
#include <wx/windowid.h>
|
#include <wx/windowid.h>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
@ -70,7 +72,7 @@ private:
|
||||||
m_ly = y;
|
m_ly = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineTo(wxPaintDC &dc, int x, int y);
|
void LineTo(std::unique_ptr<wxGraphicsContext>& dc, int x, int y);
|
||||||
|
|
||||||
struct BlrStruct // for IDM_INSERTBLR
|
struct BlrStruct // for IDM_INSERTBLR
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue