blob: 871f7974b29aca295df563a423ff5c28e8104896 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
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.comea5488b2012-07-26 19:38:22 +000014#include "SkCanvasWidget.h"
chudy@google.com607357f2012-08-07 16:12:23 +000015#include "SkDebugger.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000016#include "SkGLWidget.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000017#include "SkListWidget.h"
18#include "SkInspectorWidget.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000019#include "SkRasterWidget.h"
kkinnunen63a47022014-12-30 23:03:56 -080020#include "SkDrawCommandGeometryWidget.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000021#include "SkSettingsWidget.h"
djsollena7451862015-11-18 13:00:21 -080022#include <QtCore/QFileSystemWatcher>
kkinnunencfdc0e32015-01-13 22:49:02 -080023#include <QtCore/QSignalMapper>
chudy@google.com902ebe52012-06-29 14:21:22 +000024#include <QtCore/QVariant>
25#include <QtGui/QAction>
26#include <QtGui/QApplication>
27#include <QtGui/QButtonGroup>
28#include <QtGui/QHBoxLayout>
29#include <QtGui/QHeaderView>
30#include <QtGui/QListView>
31#include <QtGui/QListWidget>
32#include <QtGui/QMainWindow>
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +000033#include <QtGui/QSplitter>
chudy@google.com902ebe52012-06-29 14:21:22 +000034#include <QtGui/QStatusBar>
35#include <QtGui/QToolBar>
36#include <QtGui/QVBoxLayout>
37#include <QtGui/QWidget>
38#include <QtGui/QMenu>
39#include <QtGui/QMenuBar>
40#include <vector>
41
42/** \class SkDebuggerGUI
43
44 Container for the UI and it's functions.
45 */
46class SkDebuggerGUI : public QMainWindow {
47 Q_OBJECT
48
49public:
50 /**
51 Constructs the view of the application.
52 @param parent The parent container of this widget.
53 */
54 SkDebuggerGUI(QWidget *parent = 0);
55
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000056 /**
57 Updates the directory widget with the latest directory path stored in
58 the global class variable fPath.
59 */
60 void setupDirectoryWidget(const QString& path);
61
62 /**
63 Loads the specified file.
64 */
65 void openFile(const QString& filename);
66
robertphillips9ea8acd2016-03-01 09:34:38 -080067Q_SIGNALS:
chudy@google.com7dcae672012-07-09 20:26:53 +000068 void commandChanged(int command);
69
robertphillips9ea8acd2016-03-01 09:34:38 -080070private Q_SLOTS:
chudy@google.com902ebe52012-06-29 14:21:22 +000071 /**
72 Toggles breakpoint view in the list widget.
73 */
74 void actionBreakpoints();
75
76 /**
77 Cancels the command filter in the list widget.
78 */
79 void actionCancel();
80
81 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000082 Clears the breakpoint state off of all commands marked as breakpoints.
83 */
84 void actionClearBreakpoints();
85
86 /**
87 Clears the deleted state off of all commands marked as deleted.
88 */
89 void actionClearDeletes();
90
91 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000092 Closes the application.
93 */
94 void actionClose();
95
96 /**
97 Deletes the command in question.
98 */
99 void actionDelete();
100
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000101#if SK_SUPPORT_GPU
chudy@google.com902ebe52012-06-29 14:21:22 +0000102 /**
commit-bot@chromium.orgfde1e7c2013-08-02 13:59:50 +0000103 Updates the visibility of the GL canvas widget and sample count of the GL surface.
chudy@google.comea5488b2012-07-26 19:38:22 +0000104 */
kkinnunen41c79cc2014-12-30 22:49:58 -0800105 void actionGLSettingsChanged();
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000106#endif
chudy@google.comea5488b2012-07-26 19:38:22 +0000107
108 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000109 Toggles the visibility of the inspector widget.
110 */
111 void actionInspector();
112
113 /**
114 Plays from the current step to the next breakpoint if it exists, otherwise
115 executes all remaining draw commands.
116 */
117 void actionPlay();
118
119 /**
kkinnunen41c79cc2014-12-30 22:49:58 -0800120 Sets the visibility of the raster canvas widget according to the settings widget.
chudy@google.comea5488b2012-07-26 19:38:22 +0000121 */
kkinnunen41c79cc2014-12-30 22:49:58 -0800122 void actionRasterSettingsChanged();
chudy@google.comea5488b2012-07-26 19:38:22 +0000123
124 /**
kkinnunen41c79cc2014-12-30 22:49:58 -0800125 Sets the visualization settings according to the settings widget.
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000126 */
kkinnunen41c79cc2014-12-30 22:49:58 -0800127 void actionVisualizationsChanged();
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000128
129 /**
robertphillips@google.com32bbcf82013-10-17 17:56:10 +0000130 Applies the new texture filter override
131 */
132 void actionTextureFilter();
133
134 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000135 Rewinds from the current step back to the start of the commands.
136 */
137 void actionRewind();
138
139 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000140 Saves the current SKP with all modifications.
141 */
142 void actionSave();
143
144 /**
145 Saves the current SKP under a different name and/or location.
146 */
147 void actionSaveAs();
148
149 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000150 Sends the scale factor information to the settings widget.
151 */
152 void actionScale(float scaleFactor);
153
154 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000155 Toggles the settings widget visibility.
156 */
157 void actionSettings();
158
159 /**
160 Steps forward to the next draw command.
161 */
162 void actionStepBack();
163
164 /**
165 Steps backwards to the next draw command.
166 */
167 void actionStepForward();
168
169 /**
chudy@google.coma9e937c2012-08-03 17:32:05 +0000170 Called when the canvas is done being drawn to by SkCanvasWidget.
171 */
172 void drawComplete();
173
174 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000175 Loads an skpicture selected from the directory.
176 */
177 void loadFile(QListWidgetItem *item);
178
179 /**
180 Toggles a dialog with a file browser for navigating to a skpicture. Loads
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000181 the selected file.
chudy@google.com902ebe52012-06-29 14:21:22 +0000182 */
183 void openFile();
184
185 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000186 Toggles whether drawing to a new command requires a double click
187 or simple focus.
188 */
chudy@google.come504de02012-07-16 18:35:23 +0000189 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000190
191 /**
kkinnunen0cfeaf32015-01-07 07:33:46 -0800192 Updates the UI based on the selected command.
chudy@google.com902ebe52012-06-29 14:21:22 +0000193 */
kkinnunen0cfeaf32015-01-07 07:33:46 -0800194 void updateDrawCommandInfo();
chudy@google.com902ebe52012-06-29 14:21:22 +0000195
196 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000197 Sets the command to active in the list widget.
198 */
199 void selectCommand(int command);
200
201 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000202 Toggles the exclusive listing of commands set as deleted.
203 */
204 void showDeletes();
205
206 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000207 Toggles a breakpoint on the current step in the list widget.
208 */
209 void toggleBreakpoint();
210
211 /**
212 Toggles the visibility of the directory widget.
213 */
214 void toggleDirectory();
215
216 /**
djsollena7451862015-11-18 13:00:21 -0800217 Populates the contents of the directory widget with the skp files in the
218 current directory pointed to by fFile.
219 */
220 void populateDirectoryWidget();
221
222 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000223 Filters the list widgets command visibility based on the currently
224 active selection.
225 */
226 void toggleFilter(QString string);
227
kkinnunen41c79cc2014-12-30 22:49:58 -0800228 void updateHit(int newHit);
kkinnunencfdc0e32015-01-13 22:49:02 -0800229
230 void updateImage();
chudy@google.com902ebe52012-06-29 14:21:22 +0000231private:
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +0000232 QSplitter fCentralSplitter;
chudy@google.com2d537a12012-07-31 12:49:52 +0000233 QStatusBar fStatusBar;
234 QToolBar fToolBar;
235
chudy@google.comc432f002012-07-10 13:19:25 +0000236 QAction fActionOpen;
237 QAction fActionBreakpoint;
238 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000239 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000240 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000241 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000242 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000243 QAction fActionDelete;
244 QAction fActionDirectory;
245 QAction fActionGoToLine;
246 QAction fActionInspector;
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +0000247 QAction fActionSettings;
chudy@google.comc432f002012-07-10 13:19:25 +0000248 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000249 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000250 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000251 QAction fActionSave;
252 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000253 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000254 QAction fActionStepBack;
255 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000256 QAction fActionZoomIn;
257 QAction fActionZoomOut;
258 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000259
chudy@google.com0ab03392012-07-28 20:16:11 +0000260 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000261 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000262
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +0000263 QSplitter fLeftColumnSplitter;
264 QWidget fMainAndRightColumnWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000265 QVBoxLayout fMainAndRightColumnLayout;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000266 QHBoxLayout fCanvasSettingsAndImageLayout;
267 QVBoxLayout fSettingsAndImageLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000268
chudy@google.comc432f002012-07-10 13:19:25 +0000269 QListWidget fListWidget;
270 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000271
djsollena7451862015-11-18 13:00:21 -0800272 QFileSystemWatcher fDirectoryWatcher;
273
chudy@google.com607357f2012-08-07 16:12:23 +0000274 SkDebugger fDebugger;
chudy@google.comc432f002012-07-10 13:19:25 +0000275 SkCanvasWidget fCanvasWidget;
kkinnunen63a47022014-12-30 23:03:56 -0800276
chudy@google.comc432f002012-07-10 13:19:25 +0000277 SkInspectorWidget fInspectorWidget;
278 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000279
kkinnunen41c79cc2014-12-30 22:49:58 -0800280 QFrame fViewStateFrame;
281 QVBoxLayout fViewStateFrameLayout;
282 QGroupBox fViewStateGroup;
283 QFormLayout fViewStateLayout;
284 QLineEdit fCurrentCommandBox;
285 QLineEdit fCommandHitBox;
286 QLineEdit fZoomBox;
kkinnunen63a47022014-12-30 23:03:56 -0800287 SkDrawCommandGeometryWidget fDrawCommandGeometryWidget;
kkinnunen41c79cc2014-12-30 22:49:58 -0800288
chudy@google.com902ebe52012-06-29 14:21:22 +0000289 QString fPath;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000290 SkString fFileName;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000291 SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
chudy@google.com902ebe52012-06-29 14:21:22 +0000292
chudy@google.comc432f002012-07-10 13:19:25 +0000293 QMenuBar fMenuBar;
294 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000295 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000296 QMenu fMenuNavigate;
297 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000298 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000299
chudy@google.comd3058f52012-07-19 13:41:27 +0000300 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000301 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000302
303 /**
304 Creates the entire UI.
305 */
306 void setupUi(QMainWindow *SkDebuggerGUI);
307
308 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000309 Pipes a QString in with the location of the filename, proceeds to updating
310 the listwidget, combowidget and inspectorwidget.
311 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000312 void loadPicture(const SkString& fileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000313
314 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000315 Creates a picture of the current canvas.
316 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000317 void saveToFile(const SkString& filename);
chudy@google.com0ab03392012-07-28 20:16:11 +0000318
319 /**
kkinnunen5037e9d2014-12-30 07:22:58 -0800320 Populates the list widget with the debugger draw command info.
chudy@google.com902ebe52012-06-29 14:21:22 +0000321 */
kkinnunen5037e9d2014-12-30 07:22:58 -0800322 void setupListWidget();
chudy@google.com902ebe52012-06-29 14:21:22 +0000323
324 /**
kkinnunen5037e9d2014-12-30 07:22:58 -0800325 Populates the combo box widget with with the debugger draw command info.
chudy@google.com902ebe52012-06-29 14:21:22 +0000326 */
kkinnunen5037e9d2014-12-30 07:22:58 -0800327 void setupComboBox();
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000328
329 /**
330 Fills in the overview pane with text
331 */
robertphillips@google.com20beb482013-03-07 19:32:45 +0000332 void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
chudy@google.com902ebe52012-06-29 14:21:22 +0000333
kkinnunenf3a9e992015-01-05 01:14:11 -0800334 bool isPaused() const {
335 return fActionPause.isChecked();
336 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000337};
338
339#endif // SKDEBUGGERUI_H