SkDebuggerGUI.h revision 768ac85655017d4106444bf3ad044680a575ccaa
1 2/* 3 * Copyright 2012 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#ifndef SKDEBUGGERUI_H 10#define SKDEBUGGERUI_H 11 12 13#include "SkCanvas.h" 14#include "SkCanvasWidget.h" 15#include "SkDebugger.h" 16#include "SkGLWidget.h" 17#include "SkListWidget.h" 18#include "SkInspectorWidget.h" 19#include "SkRasterWidget.h" 20#include "SkImageWidget.h" 21#include "SkSettingsWidget.h" 22#include <QtCore/QVariant> 23#include <QtGui/QAction> 24#include <QtGui/QApplication> 25#include <QtGui/QButtonGroup> 26#include <QtGui/QHBoxLayout> 27#include <QtGui/QHeaderView> 28#include <QtGui/QListView> 29#include <QtGui/QListWidget> 30#include <QtGui/QMainWindow> 31#include <QtGui/QSplitter> 32#include <QtGui/QStatusBar> 33#include <QtGui/QToolBar> 34#include <QtGui/QVBoxLayout> 35#include <QtGui/QWidget> 36#include <QtGui/QMenu> 37#include <QtGui/QMenuBar> 38#include <vector> 39 40class SkTimedPicture; 41namespace sk_tools { 42 class PictureRenderer; 43} 44 45/** \class SkDebuggerGUI 46 47 Container for the UI and it's functions. 48 */ 49class SkDebuggerGUI : public QMainWindow { 50 Q_OBJECT 51 52public: 53 /** 54 Constructs the view of the application. 55 @param parent The parent container of this widget. 56 */ 57 SkDebuggerGUI(QWidget *parent = 0); 58 59 ~SkDebuggerGUI(); 60 61 /** 62 Updates the directory widget with the latest directory path stored in 63 the global class variable fPath. 64 */ 65 void setupDirectoryWidget(const QString& path); 66 67 /** 68 Loads the specified file. 69 */ 70 void openFile(const QString& filename); 71 72signals: 73 void commandChanged(int command); 74 75private slots: 76 /** 77 Toggles breakpoint view in the list widget. 78 */ 79 void actionBreakpoints(); 80 81 /** 82 Profile the commands 83 */ 84 void actionProfile(); 85 86 /** 87 Cancels the command filter in the list widget. 88 */ 89 void actionCancel(); 90 91 /** 92 Clears the breakpoint state off of all commands marked as breakpoints. 93 */ 94 void actionClearBreakpoints(); 95 96 /** 97 Clears the deleted state off of all commands marked as deleted. 98 */ 99 void actionClearDeletes(); 100 101 /** 102 Applies a visible filter to all drawing commands other than the previous. 103 */ 104 void actionCommandFilter(); 105 106 /** 107 Closes the application. 108 */ 109 void actionClose(); 110 111 /** 112 Deletes the command in question. 113 */ 114 void actionDelete(); 115 116#if SK_SUPPORT_GPU 117 /** 118 Updates the visibility of the GL canvas widget and sample count of the GL surface. 119 */ 120 void actionGLWidget(); 121#endif 122 123 /** 124 Toggles the visibility of the inspector widget. 125 */ 126 void actionInspector(); 127 128 /** 129 Plays from the current step to the next breakpoint if it exists, otherwise 130 executes all remaining draw commands. 131 */ 132 void actionPlay(); 133 134 /** 135 Toggles the visibility of the raster canvas widget. 136 */ 137 void actionRasterWidget(bool isToggled); 138 139 /** 140 Toggles the the overdraw visualization on and off 141 */ 142 void actionOverdrawVizWidget(bool isToggled); 143 144 /** 145 Toggles the the mega visualization on and off 146 */ 147 void actionMegaVizWidget(bool isToggled); 148 149 /** 150 Applies the new texture filter override 151 */ 152 void actionTextureFilter(); 153 154 /** 155 Rewinds from the current step back to the start of the commands. 156 */ 157 void actionRewind(); 158 159 /** 160 Saves the current SKP with all modifications. 161 */ 162 void actionSave(); 163 164 /** 165 Saves the current SKP under a different name and/or location. 166 */ 167 void actionSaveAs(); 168 169 /** 170 Sends the scale factor information to the settings widget. 171 */ 172 void actionScale(float scaleFactor); 173 174 /** 175 Toggles the settings widget visibility. 176 */ 177 void actionSettings(); 178 179 /** 180 Steps forward to the next draw command. 181 */ 182 void actionStepBack(); 183 184 /** 185 Steps backwards to the next draw command. 186 */ 187 void actionStepForward(); 188 189 /** 190 Called when the canvas is done being drawn to by SkCanvasWidget. 191 */ 192 void drawComplete(); 193 194 /** 195 Loads an skpicture selected from the directory. 196 */ 197 void loadFile(QListWidgetItem *item); 198 199 /** 200 Toggles a dialog with a file browser for navigating to a skpicture. Loads 201 the selected file. 202 */ 203 void openFile(); 204 205 /** 206 Toggles whether drawing to a new command requires a double click 207 or simple focus. 208 */ 209 void pauseDrawing(bool isPaused = true); 210 211 /** 212 Executes draw commands up to the selected command 213 */ 214 void registerListClick(QListWidgetItem *item); 215 216 /** 217 Sets the command to active in the list widget. 218 */ 219 void selectCommand(int command); 220 221 /** 222 Toggles the exclusive listing of commands set as deleted. 223 */ 224 void showDeletes(); 225 226 /** 227 Toggles a breakpoint on the current step in the list widget. 228 */ 229 void toggleBreakpoint(); 230 231 /** 232 Toggles the visibility of the directory widget. 233 */ 234 void toggleDirectory(); 235 236 /** 237 Filters the list widgets command visibility based on the currently 238 active selection. 239 */ 240 void toggleFilter(QString string); 241 242private: 243 QSplitter fCentralSplitter; 244 QStatusBar fStatusBar; 245 QToolBar fToolBar; 246 247 QAction fActionOpen; 248 QAction fActionBreakpoint; 249 QAction fActionProfile; 250 QAction fActionCancel; 251 QAction fActionClearBreakpoints; 252 QAction fActionClearDeletes; 253 QAction fActionClose; 254 QAction fActionCreateBreakpoint; 255 QAction fActionDelete; 256 QAction fActionDirectory; 257 QAction fActionGoToLine; 258 QAction fActionInspector; 259 QAction fActionSettings; 260 QAction fActionPlay; 261 QAction fActionPause; 262 QAction fActionRewind; 263 QAction fActionSave; 264 QAction fActionSaveAs; 265 QAction fActionShowDeletes; 266 QAction fActionStepBack; 267 QAction fActionStepForward; 268 QAction fActionZoomIn; 269 QAction fActionZoomOut; 270 QSignalMapper fMapper; 271 272 QWidget fSpacer; 273 QComboBox fFilter; 274 275 QSplitter fLeftColumnSplitter; 276 QWidget fMainAndRightColumnWidget; 277 QVBoxLayout fMainAndRightColumnLayout; 278 QHBoxLayout fCanvasSettingsAndImageLayout; 279 QVBoxLayout fSettingsAndImageLayout; 280 281 QListWidget fListWidget; 282 QListWidget fDirectoryWidget; 283 284 SkDebugger fDebugger; 285 SkCanvasWidget fCanvasWidget; 286 SkImageWidget fImageWidget; 287 SkInspectorWidget fInspectorWidget; 288 SkSettingsWidget fSettingsWidget; 289 290 QString fPath; 291 SkString fFileName; 292 SkTDArray<bool> fSkipCommands; // has a specific command been deleted? 293 bool fDirectoryWidgetActive; 294 295 QMenuBar fMenuBar; 296 QMenu fMenuFile; 297 QMenu fMenuEdit; 298 QMenu fMenuNavigate; 299 QMenu fMenuView; 300 QMenu fMenuWindows; 301 302 bool fBreakpointsActivated; 303 bool fDeletesActivated; 304 bool fPause; 305 bool fLoading; 306 int fPausedRow; 307 308 /** 309 Creates the entire UI. 310 */ 311 void setupUi(QMainWindow *SkDebuggerGUI); 312 313 /** 314 Pipes a QString in with the location of the filename, proceeds to updating 315 the listwidget, combowidget and inspectorwidget. 316 */ 317 void loadPicture(const SkString& fileName); 318 319 /** 320 Creates a picture of the current canvas. 321 */ 322 void saveToFile(const SkString& filename); 323 324 /** 325 Populates the list widget with the vector of strings passed in. 326 */ 327 void setupListWidget(SkTArray<SkString>* command); 328 329 /** 330 Populates the combo box widget with the vector of strings passed in. 331 */ 332 void setupComboBox(SkTArray<SkString>* command); 333 334 /** 335 Fills in the overview pane with text 336 */ 337 void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns); 338 339 /** 340 Render the supplied picture several times tracking the time consumed 341 by each command. 342 */ 343 void run(SkTimedPicture* pict, 344 sk_tools::PictureRenderer* renderer, 345 int repeats); 346}; 347 348#endif // SKDEBUGGERUI_H 349