blob: 570ebdbf129e02ee42697fe4ad97c8420b94dbf4 [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"
chudy@google.com902ebe52012-06-29 14:21:22 +000020#include "SkSettingsWidget.h"
21#include <QtCore/QVariant>
22#include <QtGui/QAction>
23#include <QtGui/QApplication>
24#include <QtGui/QButtonGroup>
25#include <QtGui/QHBoxLayout>
26#include <QtGui/QHeaderView>
27#include <QtGui/QListView>
28#include <QtGui/QListWidget>
29#include <QtGui/QMainWindow>
30#include <QtGui/QStatusBar>
31#include <QtGui/QToolBar>
32#include <QtGui/QVBoxLayout>
33#include <QtGui/QWidget>
34#include <QtGui/QMenu>
35#include <QtGui/QMenuBar>
36#include <vector>
37
38/** \class SkDebuggerGUI
39
40 Container for the UI and it's functions.
41 */
42class SkDebuggerGUI : public QMainWindow {
43 Q_OBJECT
44
45public:
46 /**
47 Constructs the view of the application.
48 @param parent The parent container of this widget.
49 */
50 SkDebuggerGUI(QWidget *parent = 0);
51
52 ~SkDebuggerGUI();
53
chudy@google.com7dcae672012-07-09 20:26:53 +000054signals:
55 void commandChanged(int command);
56
chudy@google.com902ebe52012-06-29 14:21:22 +000057private slots:
58 /**
59 Toggles breakpoint view in the list widget.
60 */
61 void actionBreakpoints();
62
63 /**
robertphillips@google.comd26c7062012-11-12 20:42:12 +000064 Profile the commands
65 */
66 void actionProfile();
67
68 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000069 Cancels the command filter in the list widget.
70 */
71 void actionCancel();
72
73 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000074 Clears the breakpoint state off of all commands marked as breakpoints.
75 */
76 void actionClearBreakpoints();
77
78 /**
79 Clears the deleted state off of all commands marked as deleted.
80 */
81 void actionClearDeletes();
82
83 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000084 Applies a visible filter to all drawing commands other than the previous.
85 */
86 void actionCommandFilter();
87
88 /**
89 Closes the application.
90 */
91 void actionClose();
92
93 /**
94 Deletes the command in question.
95 */
96 void actionDelete();
97
98 /**
chudy@google.comea5488b2012-07-26 19:38:22 +000099 Toggles the visibility of the GL canvas widget.
100 */
101 void actionGLWidget(bool isToggled);
102
103 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000104 Toggles the visibility of the inspector widget.
105 */
106 void actionInspector();
107
108 /**
109 Plays from the current step to the next breakpoint if it exists, otherwise
110 executes all remaining draw commands.
111 */
112 void actionPlay();
113
114 /**
chudy@google.comea5488b2012-07-26 19:38:22 +0000115 Toggles the visibility of the raster canvas widget.
116 */
117 void actionRasterWidget(bool isToggled);
118
119 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000120 Rewinds from the current step back to the start of the commands.
121 */
122 void actionRewind();
123
124 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000125 Saves the current SKP with all modifications.
126 */
127 void actionSave();
128
129 /**
130 Saves the current SKP under a different name and/or location.
131 */
132 void actionSaveAs();
133
134 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000135 Sends the scale factor information to the settings widget.
136 */
137 void actionScale(float scaleFactor);
138
139 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000140 Toggles the settings widget visibility.
141 */
142 void actionSettings();
143
144 /**
145 Steps forward to the next draw command.
146 */
147 void actionStepBack();
148
149 /**
150 Steps backwards to the next draw command.
151 */
152 void actionStepForward();
153
154 /**
chudy@google.coma9e937c2012-08-03 17:32:05 +0000155 Called when the canvas is done being drawn to by SkCanvasWidget.
156 */
157 void drawComplete();
158
159 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000160 Loads an skpicture selected from the directory.
161 */
162 void loadFile(QListWidgetItem *item);
163
164 /**
165 Toggles a dialog with a file browser for navigating to a skpicture. Loads
166 the seleced file.
167 */
168 void openFile();
169
170 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000171 Toggles whether drawing to a new command requires a double click
172 or simple focus.
173 */
chudy@google.come504de02012-07-16 18:35:23 +0000174 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000175
176 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000177 Executes draw commands up to the selected command
178 */
179 void registerListClick(QListWidgetItem *item);
180
181 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000182 Sets the command to active in the list widget.
183 */
184 void selectCommand(int command);
185
186 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000187 Toggles the exclusive listing of commands set as deleted.
188 */
189 void showDeletes();
190
191 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000192 Toggles a breakpoint on the current step in the list widget.
193 */
194 void toggleBreakpoint();
195
196 /**
197 Toggles the visibility of the directory widget.
198 */
199 void toggleDirectory();
200
201 /**
202 Filters the list widgets command visibility based on the currently
203 active selection.
204 */
205 void toggleFilter(QString string);
206
207private:
chudy@google.com2d537a12012-07-31 12:49:52 +0000208 QWidget fCentralWidget;
209 QStatusBar fStatusBar;
210 QToolBar fToolBar;
211
chudy@google.comc432f002012-07-10 13:19:25 +0000212 QAction fActionOpen;
213 QAction fActionBreakpoint;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000214 QAction fActionProfile;
chudy@google.comc432f002012-07-10 13:19:25 +0000215 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000216 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000217 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000218 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000219 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000220 QAction fActionDelete;
221 QAction fActionDirectory;
222 QAction fActionGoToLine;
223 QAction fActionInspector;
224 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000225 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000226 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000227 QAction fActionSave;
228 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000229 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000230 QAction fActionStepBack;
231 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000232 QAction fActionZoomIn;
233 QAction fActionZoomOut;
234 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000235
chudy@google.com0ab03392012-07-28 20:16:11 +0000236 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000237 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000238
chudy@google.com2d537a12012-07-31 12:49:52 +0000239 QHBoxLayout fContainerLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000240 QVBoxLayout fLeftColumnLayout;
241 QVBoxLayout fMainAndRightColumnLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000242 QHBoxLayout fCanvasAndSettingsLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000243
chudy@google.comc432f002012-07-10 13:19:25 +0000244 QListWidget fListWidget;
245 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000246
chudy@google.com607357f2012-08-07 16:12:23 +0000247 SkDebugger fDebugger;
chudy@google.comc432f002012-07-10 13:19:25 +0000248 SkCanvasWidget fCanvasWidget;
249 SkInspectorWidget fInspectorWidget;
250 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000251
chudy@google.com902ebe52012-06-29 14:21:22 +0000252 QString fPath;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000253 SkString fFileName;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000254 SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture
chudy@google.com902ebe52012-06-29 14:21:22 +0000255 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000256
chudy@google.comc432f002012-07-10 13:19:25 +0000257 QMenuBar fMenuBar;
258 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000259 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000260 QMenu fMenuNavigate;
261 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000262 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000263
264 bool fBreakpointsActivated;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000265 bool fDeletesActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000266 bool fPause;
chudy@google.comd3058f52012-07-19 13:41:27 +0000267 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000268 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000269
270 /**
271 Creates the entire UI.
272 */
273 void setupUi(QMainWindow *SkDebuggerGUI);
274
275 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000276 Pipes a QString in with the location of the filename, proceeds to updating
277 the listwidget, combowidget and inspectorwidget.
278 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000279 void loadPicture(const SkString& fileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000280
281 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000282 Creates a picture of the current canvas.
283 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000284 void saveToFile(const SkString& filename);
chudy@google.com0ab03392012-07-28 20:16:11 +0000285
286 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000287 Populates the list widget with the vector of strings passed in.
288 */
chudy@google.com97cee972012-08-07 20:41:37 +0000289 void setupListWidget(SkTDArray<SkString*>* command);
chudy@google.com902ebe52012-06-29 14:21:22 +0000290
291 /**
292 Populates the combo box widget with the vector of strings passed in.
293 */
chudy@google.com97cee972012-08-07 20:41:37 +0000294 void setupComboBox(SkTDArray<SkString*>* command);
chudy@google.com902ebe52012-06-29 14:21:22 +0000295
296 /**
297 Updates the directory widget with the latest directory path stored in
298 the global class variable fPath.
299 */
300 void setupDirectoryWidget();
301};
302
303#endif // SKDEBUGGERUI_H