blob: d8b5c743688474792fce7262536802cb8cf6885e [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.com902ebe52012-06-29 14:21:22 +000015#include "SkDebugCanvas.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 /**
64 Cancels the command filter in the list widget.
65 */
66 void actionCancel();
67
68 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000069 Clears the breakpoint state off of all commands marked as breakpoints.
70 */
71 void actionClearBreakpoints();
72
73 /**
74 Clears the deleted state off of all commands marked as deleted.
75 */
76 void actionClearDeletes();
77
78 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000079 Applies a visible filter to all drawing commands other than the previous.
80 */
81 void actionCommandFilter();
82
83 /**
84 Closes the application.
85 */
86 void actionClose();
87
88 /**
89 Deletes the command in question.
90 */
91 void actionDelete();
92
93 /**
chudy@google.comea5488b2012-07-26 19:38:22 +000094 Toggles the visibility of the GL canvas widget.
95 */
96 void actionGLWidget(bool isToggled);
97
98 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000099 Toggles the visibility of the inspector widget.
100 */
101 void actionInspector();
102
103 /**
104 Plays from the current step to the next breakpoint if it exists, otherwise
105 executes all remaining draw commands.
106 */
107 void actionPlay();
108
109 /**
chudy@google.comea5488b2012-07-26 19:38:22 +0000110 Toggles the visibility of the raster canvas widget.
111 */
112 void actionRasterWidget(bool isToggled);
113
114 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000115 Rewinds from the current step back to the start of the commands.
116 */
117 void actionRewind();
118
119 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000120 Saves the current SKP with all modifications.
121 */
122 void actionSave();
123
124 /**
125 Saves the current SKP under a different name and/or location.
126 */
127 void actionSaveAs();
128
129 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000130 Sends the scale factor information to the settings widget.
131 */
132 void actionScale(float scaleFactor);
133
134 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000135 Toggles the settings widget visibility.
136 */
137 void actionSettings();
138
139 /**
140 Steps forward to the next draw command.
141 */
142 void actionStepBack();
143
144 /**
145 Steps backwards to the next draw command.
146 */
147 void actionStepForward();
148
149 /**
150 Loads an skpicture selected from the directory.
151 */
152 void loadFile(QListWidgetItem *item);
153
154 /**
155 Toggles a dialog with a file browser for navigating to a skpicture. Loads
156 the seleced file.
157 */
158 void openFile();
159
160 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000161 Toggles whether drawing to a new command requires a double click
162 or simple focus.
163 */
chudy@google.come504de02012-07-16 18:35:23 +0000164 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000165
166 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000167 Executes draw commands up to the selected command
168 */
169 void registerListClick(QListWidgetItem *item);
170
171 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000172 Sets the command to active in the list widget.
173 */
174 void selectCommand(int command);
175
176 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000177 Toggles the exclusive listing of commands set as deleted.
178 */
179 void showDeletes();
180
181 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000182 Toggles a breakpoint on the current step in the list widget.
183 */
184 void toggleBreakpoint();
185
186 /**
187 Toggles the visibility of the directory widget.
188 */
189 void toggleDirectory();
190
191 /**
192 Filters the list widgets command visibility based on the currently
193 active selection.
194 */
195 void toggleFilter(QString string);
196
197private:
chudy@google.com2d537a12012-07-31 12:49:52 +0000198 QWidget fCentralWidget;
199 QStatusBar fStatusBar;
200 QToolBar fToolBar;
201
chudy@google.comc432f002012-07-10 13:19:25 +0000202 QAction fActionOpen;
203 QAction fActionBreakpoint;
204 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000205 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000206 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000207 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000208 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000209 QAction fActionDelete;
210 QAction fActionDirectory;
211 QAction fActionGoToLine;
212 QAction fActionInspector;
213 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000214 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000215 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000216 QAction fActionSave;
217 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000218 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000219 QAction fActionStepBack;
220 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000221 QAction fActionZoomIn;
222 QAction fActionZoomOut;
223 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000224
chudy@google.com0ab03392012-07-28 20:16:11 +0000225 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000226 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000227
chudy@google.com2d537a12012-07-31 12:49:52 +0000228 QHBoxLayout fContainerLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000229 QVBoxLayout fLeftColumnLayout;
230 QVBoxLayout fMainAndRightColumnLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000231 QHBoxLayout fCanvasAndSettingsLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000232
chudy@google.comc432f002012-07-10 13:19:25 +0000233 QListWidget fListWidget;
234 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000235
chudy@google.comc432f002012-07-10 13:19:25 +0000236 SkCanvasWidget fCanvasWidget;
237 SkInspectorWidget fInspectorWidget;
238 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000239
chudy@google.com902ebe52012-06-29 14:21:22 +0000240 QString fPath;
241 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000242
chudy@google.comc432f002012-07-10 13:19:25 +0000243 QMenuBar fMenuBar;
244 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000245 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000246 QMenu fMenuNavigate;
247 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000248 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000249
250 bool fBreakpointsActivated;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000251 bool fDeletesActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000252 bool fPause;
chudy@google.comd3058f52012-07-19 13:41:27 +0000253 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000254 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000255
256 /**
257 Creates the entire UI.
258 */
259 void setupUi(QMainWindow *SkDebuggerGUI);
260
261 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000262 Pipes a QString in with the location of the filename, proceeds to updating
263 the listwidget, combowidget and inspectorwidget.
264 */
265 void loadPicture(QString fileName);
266
267 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000268 Creates a picture of the current canvas.
269 */
270 void saveToFile(QString filename);
271
272 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000273 Populates the list widget with the vector of strings passed in.
274 */
275 void setupListWidget(std::vector<std::string>* cv);
276
277 /**
278 Populates the combo box widget with the vector of strings passed in.
279 */
280 void setupComboBox(std::vector<std::string>* cv);
281
282 /**
283 Updates the directory widget with the latest directory path stored in
284 the global class variable fPath.
285 */
286 void setupDirectoryWidget();
287};
288
289#endif // SKDEBUGGERUI_H