MT 05527 [Andrew Gardner]

The Qt debugger now behaves more like the Windows one, with horizontal 
scrollbars where the core views expect them.
This commit is contained in:
Andrew Gardner 2014-10-18 17:23:45 +00:00
parent d7eddbc1d3
commit bebe879e85
8 changed files with 53 additions and 48 deletions

View File

@ -38,8 +38,8 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
// The main disasm window
m_dasmView = new DebuggerView(DVT_DISASSEMBLY,
m_machine,
this);
m_machine,
this);
// Force a recompute of the disassembly region
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
@ -136,8 +136,8 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address
INT32 bpindex = -1;
for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
bp != NULL;
bp = bp->next())
bp != NULL;
bp = bp->next())
{
if (address == bp->address())
{

View File

@ -25,8 +25,8 @@ LogWindow::LogWindow(running_machine* machine, QWidget* parent) :
// The main log view
m_logView = new DebuggerView(DVT_LOG,
m_machine,
this);
m_machine,
this);
// Layout
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);

View File

@ -27,8 +27,8 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// The log view
m_consoleView = new DebuggerView(DVT_CONSOLE,
m_machine,
mainWindowFrame);
m_machine,
mainWindowFrame);
m_consoleView->setFocusPolicy(Qt::NoFocus);
m_consoleView->setPreferBottom(true);
@ -211,8 +211,8 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address
INT32 bpindex = -1;
for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
bp != NULL;
bp = bp->next())
bp != NULL;
bp = bp->next())
{
if (address == bp->address())
{
@ -285,20 +285,10 @@ void MainWindow::executeCommand(bool withClear)
return;
}
// If the user asked for help on a specific command, enhance the call
if (command.trimmed().startsWith("help", Qt::CaseInsensitive))
{
if (command.split(" ", QString::SkipEmptyParts).length() == 2)
{
const int width = m_consoleView->view()->visible_size().x;
command.append(QString(", %1").arg(width, 1, 16));
}
}
// Send along the command
debug_console_execute_command(*m_machine,
command.toLocal8Bit().data(),
true);
command.toLocal8Bit().data(),
true);
// Add history & set the index to be the top of the stack
addToHistory(command);

View File

@ -78,8 +78,8 @@ public:
m_machine(machine)
{
m_dasmView = new DebuggerView(DVT_DISASSEMBLY,
m_machine,
this);
m_machine,
this);
// Force a recompute of the disassembly region
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
@ -130,8 +130,8 @@ public:
m_machine(machine)
{
m_processorView = new DebuggerView(DVT_STATE,
m_machine,
this);
m_machine,
this);
m_processorView->setFocusPolicy(Qt::NoFocus);
QVBoxLayout* cvLayout = new QVBoxLayout(this);

View File

@ -234,8 +234,8 @@ void MemoryWindow::populateComboBox()
m_memoryComboBox->clear();
for (const debug_view_source* source = m_memTable->view()->first_source();
source != NULL;
source = source->next())
source != NULL;
source = source->next())
{
m_memoryComboBox->addItem(source->name());
}
@ -300,12 +300,12 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event)
address_space* addressSpace = source->space();
const int nativeDataWidth = addressSpace->data_width() / 8;
const UINT64 memValue = debug_read_memory(*addressSpace,
addressSpace->address_to_byte(address),
nativeDataWidth,
true);
addressSpace->address_to_byte(address),
nativeDataWidth,
true);
const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(),
address,
memValue);
address,
memValue);
if (pc != (offs_t)(-1))
{
// TODO: You can specify a box that the tooltip stays alive within - might be good?

View File

@ -3,8 +3,8 @@
#include "debugqtview.h"
DebuggerView::DebuggerView(const debug_view_type& type,
running_machine* machine,
QWidget* parent) :
running_machine* machine,
QWidget* parent) :
QAbstractScrollArea(parent),
m_preferBottom(false),
m_view(NULL),
@ -45,17 +45,24 @@ void DebuggerView::paintEvent(QPaintEvent* event)
// Handle the scroll bars
const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x;
const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff;
horizontalScrollBar()->setRange(0, horizontalScrollSize);
// If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly
const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0;
const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
const int scrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff;
const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust;
bool atEnd = false;
if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
{
atEnd = true;
}
verticalScrollBar()->setRange(0, scrollSize);
verticalScrollBar()->setRange(0, verticalScrollSize);
if (m_preferBottom && atEnd)
{
verticalScrollBar()->setValue(scrollSize);
verticalScrollBar()->setValue(verticalScrollSize);
}
@ -115,8 +122,8 @@ void DebuggerView::paintEvent(QPaintEvent* event)
if(textAttr & DCA_DISABLED)
{
fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1,
(fgColor.green() + bgColor.green()) >> 1,
(fgColor.blue() + bgColor.blue()) >> 1);
(fgColor.green() + bgColor.green()) >> 1,
(fgColor.blue() + bgColor.blue()) >> 1);
}
if(textAttr & DCA_COMMENT)
{
@ -134,8 +141,8 @@ void DebuggerView::paintEvent(QPaintEvent* event)
// There is a touchy interplay between font height, drawing difference, visible position, etc
// Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed.
painter.drawText(x*fontWidth,
(y*fontHeight + (fontHeight*0.80)),
QString(m_view->viewdata()[viewDataOffset].byte));
(y*fontHeight + (fontHeight*0.80)),
QString(m_view->viewdata()[viewDataOffset].byte));
viewDataOffset++;
}
}
@ -151,17 +158,24 @@ void DebuggerView::paintEvent(QPaintEvent* event)
// Handle the scroll bars
const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x;
const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff;
horizontalScrollBar()->setRange(0, horizontalScrollSize);
// If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly
const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0;
const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
const int scrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff;
const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust;
bool atEnd = false;
if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
{
atEnd = true;
}
verticalScrollBar()->setRange(0, scrollSize);
verticalScrollBar()->setRange(0, verticalScrollSize);
if (m_preferBottom && atEnd)
{
verticalScrollBar()->setValue(scrollSize);
verticalScrollBar()->setValue(verticalScrollSize);
}
@ -360,6 +374,7 @@ void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate)
// Get a handle to the DebuggerView being updated & redraw
DebuggerView* dView = (DebuggerView*)osdPrivate;
dView->verticalScrollBar()->setValue(dView->view()->visible_position().y);
dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x);
dView->viewport()->update();
dView->update();
}

View File

@ -12,8 +12,8 @@ class DebuggerView : public QAbstractScrollArea
public:
DebuggerView(const debug_view_type& type,
running_machine* machine,
QWidget* parent=NULL);
running_machine* machine,
QWidget* parent=NULL);
virtual ~DebuggerView();
void paintEvent(QPaintEvent* event);

View File

@ -69,7 +69,7 @@ public:
WIN_TYPE_DASM = 0x04,
WIN_TYPE_LOG = 0x08,
WIN_TYPE_BREAK_POINTS = 0x10,
WIN_TYPE_UNKNOWN = 0x20,
WIN_TYPE_UNKNOWN = 0x20
};
public: