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