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