blob: aed40721fe736e6c056f2a5567892430748fc920 [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"
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000020#include "SkImageWidget.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000021#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.com8a1cdae2012-11-19 20:44:29 +000039class SkTimedPicture;
40namespace sk_tools {
41 class PictureRenderer;
42}
43
chudy@google.com902ebe52012-06-29 14:21:22 +000044/** \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
chudy@google.com7dcae672012-07-09 20:26:53 +000060signals:
61 void commandChanged(int command);
62
chudy@google.com902ebe52012-06-29 14:21:22 +000063private slots:
64 /**
65 Toggles breakpoint view in the list widget.
66 */
67 void actionBreakpoints();
68
69 /**
robertphillips@google.comd26c7062012-11-12 20:42:12 +000070 Profile the commands
71 */
72 void actionProfile();
73
74 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000075 Cancels the command filter in the list widget.
76 */
77 void actionCancel();
78
79 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000080 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.com902ebe52012-06-29 14:21:22 +000090 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.comea5488b2012-07-26 19:38:22 +0000105 Toggles the visibility of the GL canvas widget.
106 */
107 void actionGLWidget(bool isToggled);
108
109 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000110 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.comea5488b2012-07-26 19:38:22 +0000121 Toggles the visibility of the raster canvas widget.
122 */
123 void actionRasterWidget(bool isToggled);
124
125 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000126 Rewinds from the current step back to the start of the commands.
127 */
128 void actionRewind();
129
130 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000131 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.com7dcae672012-07-09 20:26:53 +0000141 Sends the scale factor information to the settings widget.
142 */
143 void actionScale(float scaleFactor);
144
145 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000146 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.coma9e937c2012-08-03 17:32:05 +0000161 Called when the canvas is done being drawn to by SkCanvasWidget.
162 */
163 void drawComplete();
164
165 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000166 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.com7dcae672012-07-09 20:26:53 +0000177 Toggles whether drawing to a new command requires a double click
178 or simple focus.
179 */
chudy@google.come504de02012-07-16 18:35:23 +0000180 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000181
182 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000183 Executes draw commands up to the selected command
184 */
185 void registerListClick(QListWidgetItem *item);
186
187 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000188 Sets the command to active in the list widget.
189 */
190 void selectCommand(int command);
191
192 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000193 Toggles the exclusive listing of commands set as deleted.
194 */
195 void showDeletes();
196
197 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000198 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
213private:
chudy@google.com2d537a12012-07-31 12:49:52 +0000214 QWidget fCentralWidget;
215 QStatusBar fStatusBar;
216 QToolBar fToolBar;
217
chudy@google.comc432f002012-07-10 13:19:25 +0000218 QAction fActionOpen;
219 QAction fActionBreakpoint;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000220 QAction fActionProfile;
chudy@google.comc432f002012-07-10 13:19:25 +0000221 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000222 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000223 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000224 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000225 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000226 QAction fActionDelete;
227 QAction fActionDirectory;
228 QAction fActionGoToLine;
229 QAction fActionInspector;
230 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000231 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000232 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000233 QAction fActionSave;
234 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000235 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000236 QAction fActionStepBack;
237 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000238 QAction fActionZoomIn;
239 QAction fActionZoomOut;
240 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000241
chudy@google.com0ab03392012-07-28 20:16:11 +0000242 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000243 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000244
chudy@google.com2d537a12012-07-31 12:49:52 +0000245 QHBoxLayout fContainerLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000246 QVBoxLayout fLeftColumnLayout;
247 QVBoxLayout fMainAndRightColumnLayout;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000248 QHBoxLayout fCanvasSettingsAndImageLayout;
249 QVBoxLayout fSettingsAndImageLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000250
chudy@google.comc432f002012-07-10 13:19:25 +0000251 QListWidget fListWidget;
252 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000253
chudy@google.com607357f2012-08-07 16:12:23 +0000254 SkDebugger fDebugger;
chudy@google.comc432f002012-07-10 13:19:25 +0000255 SkCanvasWidget fCanvasWidget;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000256 SkImageWidget fImageWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000257 SkInspectorWidget fInspectorWidget;
258 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000259
chudy@google.com902ebe52012-06-29 14:21:22 +0000260 QString fPath;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000261 SkString fFileName;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000262 SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture
chudy@google.com902ebe52012-06-29 14:21:22 +0000263 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000264
chudy@google.comc432f002012-07-10 13:19:25 +0000265 QMenuBar fMenuBar;
266 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000267 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000268 QMenu fMenuNavigate;
269 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000270 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000271
272 bool fBreakpointsActivated;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000273 bool fDeletesActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000274 bool fPause;
chudy@google.comd3058f52012-07-19 13:41:27 +0000275 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000276 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000277
278 /**
279 Creates the entire UI.
280 */
281 void setupUi(QMainWindow *SkDebuggerGUI);
282
283 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000284 Pipes a QString in with the location of the filename, proceeds to updating
285 the listwidget, combowidget and inspectorwidget.
286 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000287 void loadPicture(const SkString& fileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000288
289 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000290 Creates a picture of the current canvas.
291 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000292 void saveToFile(const SkString& filename);
chudy@google.com0ab03392012-07-28 20:16:11 +0000293
294 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000295 Populates the list widget with the vector of strings passed in.
296 */
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000297 void setupListWidget(SkTArray<SkString>* command);
chudy@google.com902ebe52012-06-29 14:21:22 +0000298
299 /**
300 Populates the combo box widget with the vector of strings passed in.
301 */
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000302 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.com902ebe52012-06-29 14:21:22 +0000308
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.com8a1cdae2012-11-19 20:44:29 +0000314
315 /**
316 Render the supplied picture several times tracking the time consumed
317 by each command.
318 */
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000319 void run(SkTimedPicture* pict,
320 sk_tools::PictureRenderer* renderer,
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000321 int repeats);
chudy@google.com902ebe52012-06-29 14:21:22 +0000322};
323
324#endif // SKDEBUGGERUI_H