void loadPicture(QString filename);
/**
- Toggles the visibility / execution of the draw command at index i.
+ Returns the visibility of the command at the specified index.
+ @param index The index of the draw command
*/
- void toggleCommand(int index) {
- fDebugCanvas->toggleCommand(index);
+ bool commandIsVisibleAtIndex(int index) {
+ return fDebugCanvas->getDrawCommandVisibilityAt(index);
}
/**
Toggles the visibility / execution of the draw command at index i with
the value of toggle.
*/
- void toggleCommand(int index, bool toggle) {
+ void setCommandVisibliltyAtIndex(int index, bool toggle) {
fDebugCanvas->toggleCommand(index, toggle);
}
, fActionOpen(this)
, fActionBreakpoint(this)
, fActionCancel(this)
+ , fActionClearBreakpoints(this)
, fActionClearDeletes(this)
, fActionClose(this)
, fActionCreateBreakpoint(this)
, fActionInspector(this)
, fActionPlay(this)
, fActionPause(this)
- , fActionReload(this)
, fActionRewind(this)
+ , fActionShowDeletes(this)
, fActionStepBack(this)
, fActionStepForward(this)
, fCentralWidget(this)
, fMenuNavigate(this)
, fMenuView(this)
, fToolBar(this)
+ , fBreakpointsActivated(false)
+ , fDeletesActivated(false)
+ , fPause(false)
{
setupUi(this);
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
QListWidgetItem*)), this,
SLOT(loadFile(QListWidgetItem *)));
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
- connect(&fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(toggleBreakpoint()));
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
connect(&fFilter, SIGNAL(activated(QString)), this,
SLOT(toggleFilter(QString)));
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
+ connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
+ connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this,
SLOT(actionCommandFilter()));
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget,
SLOT(updateHit(int)));
connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
+ connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
+
+ fInspectorWidget.setDisabled(true);
+ fMenuBar.setDisabled(true);
}
SkDebuggerGUI::~SkDebuggerGUI() {
}
void SkDebuggerGUI::actionBreakpoints() {
- if (!fBreakpointsActivated) {
- fBreakpointsActivated = true;
- } else {
- fBreakpointsActivated = false;
+ fBreakpointsActivated = !fBreakpointsActivated;
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem *item = fListWidget.item(row);
+ item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
}
+}
+void SkDebuggerGUI::showDeletes() {
+ fDeletesActivated = !fDeletesActivated;
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
-
- if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
- item->setHidden(true);
- } else {
- item->setHidden(false);
- }
+ bool isVisible = fCanvasWidget.commandIsVisibleAtIndex(row);
+ item->setHidden(isVisible && fDeletesActivated);
}
}
}
}
+void SkDebuggerGUI::actionClearBreakpoints() {
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem* item = fListWidget.item(row);
+ item->setCheckState(Qt::Unchecked);
+ item->setData(Qt::DecorationRole,
+ QPixmap(":/images/Icons/blank.png"));
+ }
+}
+
+void SkDebuggerGUI::actionClearDeletes() {
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem* item = fListWidget.item(row);
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(row, true);
+ }
+ if (fPause) {
+ fCanvasWidget.drawTo(fPausedRow);
+ } else {
+ fCanvasWidget.drawTo(fListWidget.currentRow());
+ }
+}
+
void SkDebuggerGUI::actionCommandFilter() {
fCanvasWidget.toggleCurrentCommandFilter(
fSettingsWidget.getVisibilityButton()->isChecked());
}
void SkDebuggerGUI::actionDelete() {
+ int currentRow = fListWidget.currentRow();
QListWidgetItem* item = fListWidget.currentItem();
- if (item->data(Qt::UserRole + 2) == true) {
- item->setData(Qt::UserRole + 2, false);
- item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/delete.png"));
+
+ if (fCanvasWidget.commandIsVisibleAtIndex(currentRow)) {
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/delete.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, false);
} else {
- item->setData(Qt::UserRole + 2, true);
- item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/blank.png"));
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, true);
}
- int currentRow = fListWidget.currentRow();
- fCanvasWidget.toggleCommand(currentRow);
+
if (fPause) {
fCanvasWidget.drawTo(fPausedRow);
} else {
fListWidget.setCurrentRow(fListWidget.count() - 1);
}
-void SkDebuggerGUI::actionReload() {
- for (int row = 0; row < fListWidget.count(); row++) {
- QListWidgetItem* item = fListWidget.item(row);
- item->setData(Qt::UserRole + 2, true);
- item->setData(Qt::DecorationRole, QPixmap(":/images/Icons/blank.png"));
- fCanvasWidget.toggleCommand(row, true);
- }
- fCanvasWidget.drawTo(fListWidget.currentRow());
-}
-
void SkDebuggerGUI::actionRewind() {
fListWidget.setCurrentRow(0);
}
QSize(), QIcon::Normal, QIcon::Off);
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
fActionBreakpoint.setIcon(breakpoint);
- fActionBreakpoint.setText("Show Breakpoints");
+ fActionBreakpoint.setText("Breakpoints");
QIcon cancel;
cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
fActionCancel.setIcon(cancel);
fActionCancel.setText("Clear Filter");
+ fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
+ fActionClearBreakpoints.setText("Clear Breakpoints");
+
+ fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
+ fActionClearDeletes.setText("Clear Deletes");
+
fActionClose.setShortcuts(QKeySequence::Quit);
fActionClose.setText("Exit");
fActionPause.setIcon(pause);
fActionPause.setText("Pause");
- fActionReload.setText("Reset Picture");
-
QIcon rewind;
rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionRewind.setIcon(rewind);
fActionRewind.setText("Rewind");
+ fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
+ fActionShowDeletes.setText("Deleted Commands");
+
QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(),
QIcon::Normal, QIcon::Off);
fMenuEdit.setTitle("Edit");
fMenuEdit.addAction(&fActionDelete);
+ fMenuEdit.addAction(&fActionClearDeletes);
+ fMenuEdit.addSeparator();
fMenuEdit.addAction(&fActionCreateBreakpoint);
+ fMenuEdit.addAction(&fActionClearBreakpoints);
fMenuNavigate.setTitle("Navigate");
fMenuNavigate.addAction(&fActionRewind);
fMenuView.setTitle("View");
fMenuView.addAction(&fActionBreakpoint);
+ fMenuView.addAction(&fActionShowDeletes);
fMenuWindows.setTitle("Window");
fMenuWindows.addAction(&fActionInspector);
fSettingsWidget.getVisibilityButton()->isChecked());
setupListWidget(cv);
setupComboBox(cv);
+ fInspectorWidget.setDisabled(false);
fSettingsWidget.setDisabled(false);
+ fMenuBar.setDisabled(false);
}
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
QListWidgetItem *item = new QListWidgetItem();
item->setData(Qt::DisplayRole, (*cv)[i].c_str());
item->setData(Qt::UserRole + 1, counter++);
- item->setData(Qt::UserRole + 2, true);
fListWidget.addItem(item);
}
}
void actionCancel();
/**
+ Clears the breakpoint state off of all commands marked as breakpoints.
+ */
+ void actionClearBreakpoints();
+
+ /**
+ Clears the deleted state off of all commands marked as deleted.
+ */
+ void actionClearDeletes();
+
+ /**
Applies a visible filter to all drawing commands other than the previous.
*/
void actionCommandFilter();
void actionPlay();
/**
- Resets all deleted commands.
- */
- void actionReload();
-
- /**
Rewinds from the current step back to the start of the commands.
*/
void actionRewind();
void selectCommand(int command);
/**
+ Toggles the exclusive listing of commands set as deleted.
+ */
+ void showDeletes();
+
+ /**
Toggles a breakpoint on the current step in the list widget.
*/
void toggleBreakpoint();
QAction fActionOpen;
QAction fActionBreakpoint;
QAction fActionCancel;
+ QAction fActionClearBreakpoints;
QAction fActionClearDeletes;
QAction fActionClose;
QAction fActionCreateBreakpoint;
QAction fActionInspector;
QAction fActionPlay;
QAction fActionPause;
- QAction fActionReload;
QAction fActionRewind;
+ QAction fActionShowDeletes;
QAction fActionStepBack;
QAction fActionStepForward;
QWidget fCentralWidget;
QToolBar fToolBar;
bool fBreakpointsActivated;
+ bool fDeletesActivated;
bool fPause;
int fPausedRow;
QIcon breakpointIcon =
QIcon(qvariant_cast<QPixmap>(index.data(Qt::DecorationRole)));
QIcon deleteIcon =
- QIcon(qvariant_cast<QPixmap>(index.data(Qt::UserRole + 3)));
+ QIcon(qvariant_cast<QPixmap>(index.data(Qt::UserRole + 2)));
QString drawCommandText = index.data(Qt::DisplayRole).toString();
QString drawCommandNumber = index.data(Qt::UserRole + 1).toString();
- QString isDeleted = index.data(Qt::UserRole + 2).toString();
/* option.rect is a struct that Qt uses as a target to draw into. Following
* the format (x1,y1,x2,y2) x1 and y1 represent where the painter can start
/****************************************************************************
** Meta object code from reading C++ file 'SkDebuggerGUI.h'
**
-** Created: Wed Jul 11 17:21:44 2012
+** Created: Mon Jul 16 16:36:08 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
4, // revision
0, // classname
0, 0, // classinfo
- 22, 14, // methods
+ 25, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
43, 14, 14, 14, 0x08,
63, 14, 14, 14, 0x08,
78, 14, 14, 14, 0x08,
- 100, 14, 14, 14, 0x08,
- 114, 14, 14, 14, 0x08,
- 129, 14, 14, 14, 0x08,
- 147, 14, 14, 14, 0x08,
+ 103, 14, 14, 14, 0x08,
+ 124, 14, 14, 14, 0x08,
+ 146, 14, 14, 14, 0x08,
160, 14, 14, 14, 0x08,
175, 14, 14, 14, 0x08,
- 202, 190, 14, 14, 0x08,
- 221, 14, 14, 14, 0x08,
- 238, 14, 14, 14, 0x08,
- 255, 14, 14, 14, 0x08,
- 280, 275, 14, 14, 0x08,
- 307, 14, 14, 14, 0x08,
- 327, 318, 14, 14, 0x08,
- 346, 275, 14, 14, 0x08,
- 382, 15, 14, 14, 0x08,
- 401, 14, 14, 14, 0x08,
- 420, 14, 14, 14, 0x08,
- 445, 438, 14, 14, 0x08,
+ 193, 14, 14, 14, 0x08,
+ 206, 14, 14, 14, 0x08,
+ 233, 221, 14, 14, 0x08,
+ 252, 14, 14, 14, 0x08,
+ 269, 14, 14, 14, 0x08,
+ 286, 14, 14, 14, 0x08,
+ 311, 306, 14, 14, 0x08,
+ 338, 14, 14, 14, 0x08,
+ 358, 349, 14, 14, 0x08,
+ 377, 14, 14, 14, 0x28,
+ 392, 306, 14, 14, 0x08,
+ 428, 15, 14, 14, 0x08,
+ 447, 14, 14, 14, 0x08,
+ 461, 14, 14, 14, 0x08,
+ 480, 14, 14, 14, 0x08,
+ 505, 498, 14, 14, 0x08,
0 // eod
};
static const char qt_meta_stringdata_SkDebuggerGUI[] = {
"SkDebuggerGUI\0\0command\0commandChanged(int)\0"
"actionBreakpoints()\0actionCancel()\0"
+ "actionClearBreakpoints()\0actionClearDeletes()\0"
"actionCommandFilter()\0actionClose()\0"
"actionDelete()\0actionInspector()\0"
- "actionPlay()\0actionReload()\0actionRewind()\0"
- "scaleFactor\0actionScale(float)\0"
- "actionSettings()\0actionStepBack()\0"
- "actionStepForward()\0item\0"
- "loadFile(QListWidgetItem*)\0openFile()\0"
- "isPaused\0pauseDrawing(bool)\0"
- "registerListClick(QListWidgetItem*)\0"
- "selectCommand(int)\0toggleBreakpoint()\0"
- "toggleDirectory()\0string\0toggleFilter(QString)\0"
+ "actionPlay()\0actionRewind()\0scaleFactor\0"
+ "actionScale(float)\0actionSettings()\0"
+ "actionStepBack()\0actionStepForward()\0"
+ "item\0loadFile(QListWidgetItem*)\0"
+ "openFile()\0isPaused\0pauseDrawing(bool)\0"
+ "pauseDrawing()\0registerListClick(QListWidgetItem*)\0"
+ "selectCommand(int)\0showDeletes()\0"
+ "toggleBreakpoint()\0toggleDirectory()\0"
+ "string\0toggleFilter(QString)\0"
};
const QMetaObject SkDebuggerGUI::staticMetaObject = {
case 0: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: actionBreakpoints(); break;
case 2: actionCancel(); break;
- case 3: actionCommandFilter(); break;
- case 4: actionClose(); break;
- case 5: actionDelete(); break;
- case 6: actionInspector(); break;
- case 7: actionPlay(); break;
- case 8: actionReload(); break;
- case 9: actionRewind(); break;
- case 10: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
- case 11: actionSettings(); break;
- case 12: actionStepBack(); break;
- case 13: actionStepForward(); break;
- case 14: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 15: openFile(); break;
- case 16: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
- case 17: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 18: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
- case 19: toggleBreakpoint(); break;
- case 20: toggleDirectory(); break;
- case 21: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 3: actionClearBreakpoints(); break;
+ case 4: actionClearDeletes(); break;
+ case 5: actionCommandFilter(); break;
+ case 6: actionClose(); break;
+ case 7: actionDelete(); break;
+ case 8: actionInspector(); break;
+ case 9: actionPlay(); break;
+ case 10: actionRewind(); break;
+ case 11: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
+ case 12: actionSettings(); break;
+ case 13: actionStepBack(); break;
+ case 14: actionStepForward(); break;
+ case 15: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 16: openFile(); break;
+ case 17: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
+ case 18: pauseDrawing(); break;
+ case 19: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 20: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
+ case 21: showDeletes(); break;
+ case 22: toggleBreakpoint(); break;
+ case 23: toggleDirectory(); break;
+ case 24: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
default: ;
}
- _id -= 22;
+ _id -= 25;
}
return _id;
}
}
SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter==index) {
- return (*it);
- }
- ++counter;
- }
- }
- return NULL;
+ SkASSERT(index < commandVector.size());
+ return commandVector[index];
}
std::vector<std::string>* SkDebugCanvas::getCommandInfoAt(int index) {
- std::string info;
-
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter==index) {
- return (*it)->Info();
- }
- ++counter;
- }
- }
+ SkASSERT(index < commandVector.size());
+ return commandVector[index]->Info();
+}
- return NULL;
+bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) {
+ SkASSERT(index < commandVector.size());
+ return commandVector[index]->getVisibility();
}
std::vector<SkDrawCommand*> SkDebugCanvas::getDrawCommands() {
return true;
}
-void SkDebugCanvas::toggleCommand(int index) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter == index) {
- if ((*it)->getVisibility()) {
- (*it)->setVisibility(false);
- } else {
- (*it)->setVisibility(true);
- }
- }
- counter++;
- }
- }
-}
-
void SkDebugCanvas::toggleCommand(int index, bool toggle) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter == index) {
- (*it)->setVisibility(toggle);
- }
- counter++;
- }
- }
+ SkASSERT(index < commandVector.size());
+ commandVector[index]->setVisibility(toggle);
}
#ifndef SKDEBUGCANVAS_H_
#define SKDEBUGCANVAS_H_
-#include <iostream>
#include "SkCanvas.h"
#include "SkDrawCommand.h"
#include "SkPicture.h"
class SkDebugCanvas : public SkCanvas {
public:
- bool fFilter;
-
SkDebugCanvas();
~SkDebugCanvas();
std::vector<std::string>* getCommandInfoAt(int index);
/**
+ Returns the visibility of the command at the given index.
+ @param index The index of the command
+ */
+ bool getDrawCommandVisibilityAt(int index);
+
+ /**
Returns the vector of draw commands
*/
std::vector<SkDrawCommand*> getDrawCommands();
void isCalculatingHits(bool isEnabled) {
fCalculateHits = isEnabled;
}
- /**
- Toggles the execution of the draw command at index i.
- */
- void toggleCommand(int index);
/**
Toggles the visibility / execution of the draw command at index i with
SkBitmap fBm;
SkHitBox fHitBox;
bool fCalculateHits;
+ bool fFilter;
/**
Adds the command to the classes vector of commands.