Added more features to deletes and breakpoints

Review URL: https://codereview.appspot.com/6406050

git-svn-id: http://skia.googlecode.com/svn/trunk@4637 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
chudy@google.com 2012-07-17 15:40:51 +00:00
parent 2a021292f5
commit 7e4cfbf144
7 changed files with 164 additions and 149 deletions

View File

@ -94,17 +94,18 @@ public:
void loadPicture(QString filename); 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) { bool commandIsVisibleAtIndex(int index) {
fDebugCanvas->toggleCommand(index); return fDebugCanvas->getDrawCommandVisibilityAt(index);
} }
/** /**
Toggles the visibility / execution of the draw command at index i with Toggles the visibility / execution of the draw command at index i with
the value of toggle. the value of toggle.
*/ */
void toggleCommand(int index, bool toggle) { void setCommandVisibliltyAtIndex(int index, bool toggle) {
fDebugCanvas->toggleCommand(index, toggle); fDebugCanvas->toggleCommand(index, toggle);
} }

View File

@ -14,6 +14,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fActionOpen(this) , fActionOpen(this)
, fActionBreakpoint(this) , fActionBreakpoint(this)
, fActionCancel(this) , fActionCancel(this)
, fActionClearBreakpoints(this)
, fActionClearDeletes(this) , fActionClearDeletes(this)
, fActionClose(this) , fActionClose(this)
, fActionCreateBreakpoint(this) , fActionCreateBreakpoint(this)
@ -23,8 +24,8 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fActionInspector(this) , fActionInspector(this)
, fActionPlay(this) , fActionPlay(this)
, fActionPause(this) , fActionPause(this)
, fActionReload(this)
, fActionRewind(this) , fActionRewind(this)
, fActionShowDeletes(this)
, fActionStepBack(this) , fActionStepBack(this)
, fActionStepForward(this) , fActionStepForward(this)
, fCentralWidget(this) , fCentralWidget(this)
@ -40,6 +41,9 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fMenuNavigate(this) , fMenuNavigate(this)
, fMenuView(this) , fMenuView(this)
, fToolBar(this) , fToolBar(this)
, fBreakpointsActivated(false)
, fDeletesActivated(false)
, fPause(false)
{ {
setupUi(this); setupUi(this);
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
@ -52,7 +56,6 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
QListWidgetItem*)), this, QListWidgetItem*)), this,
SLOT(loadFile(QListWidgetItem *))); SLOT(loadFile(QListWidgetItem *)));
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
connect(&fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(toggleBreakpoint())); SLOT(toggleBreakpoint()));
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
@ -69,6 +72,8 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fFilter, SIGNAL(activated(QString)), this, connect(&fFilter, SIGNAL(activated(QString)), this,
SLOT(toggleFilter(QString))); SLOT(toggleFilter(QString)));
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); 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(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this,
SLOT(actionCommandFilter())); SLOT(actionCommandFilter()));
@ -82,26 +87,29 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget,
SLOT(updateHit(int))); SLOT(updateHit(int)));
connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint())); connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
fInspectorWidget.setDisabled(true);
fMenuBar.setDisabled(true);
} }
SkDebuggerGUI::~SkDebuggerGUI() { SkDebuggerGUI::~SkDebuggerGUI() {
} }
void SkDebuggerGUI::actionBreakpoints() { void SkDebuggerGUI::actionBreakpoints() {
if (!fBreakpointsActivated) { fBreakpointsActivated = !fBreakpointsActivated;
fBreakpointsActivated = true;
} else {
fBreakpointsActivated = false;
}
for (int row = 0; row < fListWidget.count(); row++) { for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row); QListWidgetItem *item = fListWidget.item(row);
item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
}
}
if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) { void SkDebuggerGUI::showDeletes() {
item->setHidden(true); fDeletesActivated = !fDeletesActivated;
} else { for (int row = 0; row < fListWidget.count(); row++) {
item->setHidden(false); QListWidgetItem *item = fListWidget.item(row);
} bool isVisible = fCanvasWidget.commandIsVisibleAtIndex(row);
item->setHidden(isVisible && fDeletesActivated);
} }
} }
@ -111,6 +119,28 @@ void SkDebuggerGUI::actionCancel() {
} }
} }
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() { void SkDebuggerGUI::actionCommandFilter() {
fCanvasWidget.toggleCurrentCommandFilter( fCanvasWidget.toggleCurrentCommandFilter(
fSettingsWidget.getVisibilityButton()->isChecked()); fSettingsWidget.getVisibilityButton()->isChecked());
@ -122,16 +152,17 @@ void SkDebuggerGUI::actionClose() {
} }
void SkDebuggerGUI::actionDelete() { void SkDebuggerGUI::actionDelete() {
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"));
} else {
item->setData(Qt::UserRole + 2, true);
item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/blank.png"));
}
int currentRow = fListWidget.currentRow(); int currentRow = fListWidget.currentRow();
fCanvasWidget.toggleCommand(currentRow); QListWidgetItem* item = fListWidget.currentItem();
if (fCanvasWidget.commandIsVisibleAtIndex(currentRow)) {
item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/delete.png"));
fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, false);
} else {
item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, true);
}
if (fPause) { if (fPause) {
fCanvasWidget.drawTo(fPausedRow); fCanvasWidget.drawTo(fPausedRow);
} else { } else {
@ -159,16 +190,6 @@ void SkDebuggerGUI::actionPlay() {
fListWidget.setCurrentRow(fListWidget.count() - 1); 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() { void SkDebuggerGUI::actionRewind() {
fListWidget.setCurrentRow(0); fListWidget.setCurrentRow(0);
} }
@ -316,7 +337,7 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
QSize(), QIcon::Normal, QIcon::Off); QSize(), QIcon::Normal, QIcon::Off);
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
fActionBreakpoint.setIcon(breakpoint); fActionBreakpoint.setIcon(breakpoint);
fActionBreakpoint.setText("Show Breakpoints"); fActionBreakpoint.setText("Breakpoints");
QIcon cancel; QIcon cancel;
cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(), cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
@ -324,6 +345,12 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionCancel.setIcon(cancel); fActionCancel.setIcon(cancel);
fActionCancel.setText("Clear Filter"); 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.setShortcuts(QKeySequence::Quit);
fActionClose.setText("Exit"); fActionClose.setText("Exit");
@ -358,8 +385,6 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionPause.setIcon(pause); fActionPause.setIcon(pause);
fActionPause.setText("Pause"); fActionPause.setText("Pause");
fActionReload.setText("Reset Picture");
QIcon rewind; QIcon rewind;
rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(), rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(),
QIcon::Normal, QIcon::Off); QIcon::Normal, QIcon::Off);
@ -367,6 +392,9 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionRewind.setIcon(rewind); fActionRewind.setIcon(rewind);
fActionRewind.setText("Rewind"); fActionRewind.setText("Rewind");
fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
fActionShowDeletes.setText("Deleted Commands");
QIcon stepBack; QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(), stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(),
QIcon::Normal, QIcon::Off); QIcon::Normal, QIcon::Off);
@ -453,7 +481,10 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fMenuEdit.setTitle("Edit"); fMenuEdit.setTitle("Edit");
fMenuEdit.addAction(&fActionDelete); fMenuEdit.addAction(&fActionDelete);
fMenuEdit.addAction(&fActionClearDeletes);
fMenuEdit.addSeparator();
fMenuEdit.addAction(&fActionCreateBreakpoint); fMenuEdit.addAction(&fActionCreateBreakpoint);
fMenuEdit.addAction(&fActionClearBreakpoints);
fMenuNavigate.setTitle("Navigate"); fMenuNavigate.setTitle("Navigate");
fMenuNavigate.addAction(&fActionRewind); fMenuNavigate.addAction(&fActionRewind);
@ -465,6 +496,7 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fMenuView.setTitle("View"); fMenuView.setTitle("View");
fMenuView.addAction(&fActionBreakpoint); fMenuView.addAction(&fActionBreakpoint);
fMenuView.addAction(&fActionShowDeletes);
fMenuWindows.setTitle("Window"); fMenuWindows.setTitle("Window");
fMenuWindows.addAction(&fActionInspector); fMenuWindows.addAction(&fActionInspector);
@ -504,7 +536,9 @@ void SkDebuggerGUI::loadPicture(QString fileName) {
fSettingsWidget.getVisibilityButton()->isChecked()); fSettingsWidget.getVisibilityButton()->isChecked());
setupListWidget(cv); setupListWidget(cv);
setupComboBox(cv); setupComboBox(cv);
fInspectorWidget.setDisabled(false);
fSettingsWidget.setDisabled(false); fSettingsWidget.setDisabled(false);
fMenuBar.setDisabled(false);
} }
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) { void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
@ -514,7 +548,6 @@ void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
QListWidgetItem *item = new QListWidgetItem(); QListWidgetItem *item = new QListWidgetItem();
item->setData(Qt::DisplayRole, (*cv)[i].c_str()); item->setData(Qt::DisplayRole, (*cv)[i].c_str());
item->setData(Qt::UserRole + 1, counter++); item->setData(Qt::UserRole + 1, counter++);
item->setData(Qt::UserRole + 2, true);
fListWidget.addItem(item); fListWidget.addItem(item);
} }
} }

View File

@ -63,6 +63,16 @@ private slots:
*/ */
void actionCancel(); 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. Applies a visible filter to all drawing commands other than the previous.
*/ */
@ -89,11 +99,6 @@ private slots:
*/ */
void actionPlay(); void actionPlay();
/**
Resets all deleted commands.
*/
void actionReload();
/** /**
Rewinds from the current step back to the start of the commands. Rewinds from the current step back to the start of the commands.
*/ */
@ -146,6 +151,11 @@ private slots:
*/ */
void selectCommand(int command); 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. Toggles a breakpoint on the current step in the list widget.
*/ */
@ -166,6 +176,7 @@ private:
QAction fActionOpen; QAction fActionOpen;
QAction fActionBreakpoint; QAction fActionBreakpoint;
QAction fActionCancel; QAction fActionCancel;
QAction fActionClearBreakpoints;
QAction fActionClearDeletes; QAction fActionClearDeletes;
QAction fActionClose; QAction fActionClose;
QAction fActionCreateBreakpoint; QAction fActionCreateBreakpoint;
@ -175,8 +186,8 @@ private:
QAction fActionInspector; QAction fActionInspector;
QAction fActionPlay; QAction fActionPlay;
QAction fActionPause; QAction fActionPause;
QAction fActionReload;
QAction fActionRewind; QAction fActionRewind;
QAction fActionShowDeletes;
QAction fActionStepBack; QAction fActionStepBack;
QAction fActionStepForward; QAction fActionStepForward;
QWidget fCentralWidget; QWidget fCentralWidget;
@ -208,6 +219,7 @@ private:
QToolBar fToolBar; QToolBar fToolBar;
bool fBreakpointsActivated; bool fBreakpointsActivated;
bool fDeletesActivated;
bool fPause; bool fPause;
int fPausedRow; int fPausedRow;

View File

@ -60,11 +60,10 @@ void SkListWidget::paint (QPainter *painter,
QIcon breakpointIcon = QIcon breakpointIcon =
QIcon(qvariant_cast<QPixmap>(index.data(Qt::DecorationRole))); QIcon(qvariant_cast<QPixmap>(index.data(Qt::DecorationRole)));
QIcon deleteIcon = 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 drawCommandText = index.data(Qt::DisplayRole).toString();
QString drawCommandNumber = index.data(Qt::UserRole + 1).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 /* 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 * the format (x1,y1,x2,y2) x1 and y1 represent where the painter can start

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
** Meta object code from reading C++ file 'SkDebuggerGUI.h' ** 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) ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
** **
** WARNING! All changes made in this file will be lost! ** WARNING! All changes made in this file will be lost!
@ -23,7 +23,7 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
4, // revision 4, // revision
0, // classname 0, // classname
0, 0, // classinfo 0, 0, // classinfo
22, 14, // methods 25, 14, // methods
0, 0, // properties 0, 0, // properties
0, 0, // enums/sets 0, 0, // enums/sets
0, 0, // constructors 0, 0, // constructors
@ -37,24 +37,27 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
43, 14, 14, 14, 0x08, 43, 14, 14, 14, 0x08,
63, 14, 14, 14, 0x08, 63, 14, 14, 14, 0x08,
78, 14, 14, 14, 0x08, 78, 14, 14, 14, 0x08,
100, 14, 14, 14, 0x08, 103, 14, 14, 14, 0x08,
114, 14, 14, 14, 0x08, 124, 14, 14, 14, 0x08,
129, 14, 14, 14, 0x08, 146, 14, 14, 14, 0x08,
147, 14, 14, 14, 0x08,
160, 14, 14, 14, 0x08, 160, 14, 14, 14, 0x08,
175, 14, 14, 14, 0x08, 175, 14, 14, 14, 0x08,
202, 190, 14, 14, 0x08, 193, 14, 14, 14, 0x08,
221, 14, 14, 14, 0x08, 206, 14, 14, 14, 0x08,
238, 14, 14, 14, 0x08, 233, 221, 14, 14, 0x08,
255, 14, 14, 14, 0x08, 252, 14, 14, 14, 0x08,
280, 275, 14, 14, 0x08, 269, 14, 14, 14, 0x08,
307, 14, 14, 14, 0x08, 286, 14, 14, 14, 0x08,
327, 318, 14, 14, 0x08, 311, 306, 14, 14, 0x08,
346, 275, 14, 14, 0x08, 338, 14, 14, 14, 0x08,
382, 15, 14, 14, 0x08, 358, 349, 14, 14, 0x08,
401, 14, 14, 14, 0x08, 377, 14, 14, 14, 0x28,
420, 14, 14, 14, 0x08, 392, 306, 14, 14, 0x08,
445, 438, 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 0 // eod
}; };
@ -62,17 +65,18 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
static const char qt_meta_stringdata_SkDebuggerGUI[] = { static const char qt_meta_stringdata_SkDebuggerGUI[] = {
"SkDebuggerGUI\0\0command\0commandChanged(int)\0" "SkDebuggerGUI\0\0command\0commandChanged(int)\0"
"actionBreakpoints()\0actionCancel()\0" "actionBreakpoints()\0actionCancel()\0"
"actionClearBreakpoints()\0actionClearDeletes()\0"
"actionCommandFilter()\0actionClose()\0" "actionCommandFilter()\0actionClose()\0"
"actionDelete()\0actionInspector()\0" "actionDelete()\0actionInspector()\0"
"actionPlay()\0actionReload()\0actionRewind()\0" "actionPlay()\0actionRewind()\0scaleFactor\0"
"scaleFactor\0actionScale(float)\0" "actionScale(float)\0actionSettings()\0"
"actionSettings()\0actionStepBack()\0" "actionStepBack()\0actionStepForward()\0"
"actionStepForward()\0item\0" "item\0loadFile(QListWidgetItem*)\0"
"loadFile(QListWidgetItem*)\0openFile()\0" "openFile()\0isPaused\0pauseDrawing(bool)\0"
"isPaused\0pauseDrawing(bool)\0" "pauseDrawing()\0registerListClick(QListWidgetItem*)\0"
"registerListClick(QListWidgetItem*)\0" "selectCommand(int)\0showDeletes()\0"
"selectCommand(int)\0toggleBreakpoint()\0" "toggleBreakpoint()\0toggleDirectory()\0"
"toggleDirectory()\0string\0toggleFilter(QString)\0" "string\0toggleFilter(QString)\0"
}; };
const QMetaObject SkDebuggerGUI::staticMetaObject = { const QMetaObject SkDebuggerGUI::staticMetaObject = {
@ -107,28 +111,31 @@ int SkDebuggerGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
case 0: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 0: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: actionBreakpoints(); break; case 1: actionBreakpoints(); break;
case 2: actionCancel(); break; case 2: actionCancel(); break;
case 3: actionCommandFilter(); break; case 3: actionClearBreakpoints(); break;
case 4: actionClose(); break; case 4: actionClearDeletes(); break;
case 5: actionDelete(); break; case 5: actionCommandFilter(); break;
case 6: actionInspector(); break; case 6: actionClose(); break;
case 7: actionPlay(); break; case 7: actionDelete(); break;
case 8: actionReload(); break; case 8: actionInspector(); break;
case 9: actionRewind(); break; case 9: actionPlay(); break;
case 10: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break; case 10: actionRewind(); break;
case 11: actionSettings(); break; case 11: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
case 12: actionStepBack(); break; case 12: actionSettings(); break;
case 13: actionStepForward(); break; case 13: actionStepBack(); break;
case 14: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 14: actionStepForward(); break;
case 15: openFile(); break; case 15: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 16: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break; case 16: openFile(); break;
case 17: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 17: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 18: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break; case 18: pauseDrawing(); break;
case 19: toggleBreakpoint(); break; case 19: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 20: toggleDirectory(); break; case 20: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
case 21: toggleFilter((*reinterpret_cast< QString(*)>(_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: ; default: ;
} }
_id -= 22; _id -= 25;
} }
return _id; return _id;
} }

View File

@ -73,32 +73,18 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index, SkBitmap* bitmap) {
} }
SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) { SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
int counter = 0; SkASSERT(index < commandVector.size());
if(!commandVector.empty()) { return commandVector[index];
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
if (counter==index) {
return (*it);
}
++counter;
}
}
return NULL;
} }
std::vector<std::string>* SkDebugCanvas::getCommandInfoAt(int index) { std::vector<std::string>* SkDebugCanvas::getCommandInfoAt(int index) {
std::string info; SkASSERT(index < commandVector.size());
return commandVector[index]->Info();
}
int counter = 0; bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) {
if(!commandVector.empty()) { SkASSERT(index < commandVector.size());
for(it = commandVector.begin(); it != commandVector.end(); ++it) { return commandVector[index]->getVisibility();
if (counter==index) {
return (*it)->Info();
}
++counter;
}
}
return NULL;
} }
std::vector<SkDrawCommand*> SkDebugCanvas::getDrawCommands() { std::vector<SkDrawCommand*> SkDebugCanvas::getDrawCommands() {
@ -262,30 +248,7 @@ bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) {
return true; 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) { void SkDebugCanvas::toggleCommand(int index, bool toggle) {
int counter = 0; SkASSERT(index < commandVector.size());
if(!commandVector.empty()) { commandVector[index]->setVisibility(toggle);
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
if (counter == index) {
(*it)->setVisibility(toggle);
}
counter++;
}
}
} }

View File

@ -10,7 +10,6 @@
#ifndef SKDEBUGCANVAS_H_ #ifndef SKDEBUGCANVAS_H_
#define SKDEBUGCANVAS_H_ #define SKDEBUGCANVAS_H_
#include <iostream>
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkDrawCommand.h" #include "SkDrawCommand.h"
#include "SkPicture.h" #include "SkPicture.h"
@ -19,8 +18,6 @@
class SkDebugCanvas : public SkCanvas { class SkDebugCanvas : public SkCanvas {
public: public:
bool fFilter;
SkDebugCanvas(); SkDebugCanvas();
~SkDebugCanvas(); ~SkDebugCanvas();
@ -60,6 +57,12 @@ public:
*/ */
std::vector<std::string>* getCommandInfoAt(int index); 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 Returns the vector of draw commands
*/ */
@ -95,10 +98,6 @@ public:
void isCalculatingHits(bool isEnabled) { void isCalculatingHits(bool isEnabled) {
fCalculateHits = 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 Toggles the visibility / execution of the draw command at index i with
@ -197,6 +196,7 @@ private:
SkBitmap fBm; SkBitmap fBm;
SkHitBox fHitBox; SkHitBox fHitBox;
bool fCalculateHits; bool fCalculateHits;
bool fFilter;
/** /**
Adds the command to the classes vector of commands. Adds the command to the classes vector of commands.