• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
14 #include "SkCanvasWidget.h"
15 #include "SkDebugger.h"
16 #include "SkGLWidget.h"
17 #include "SkListWidget.h"
18 #include "SkInspectorWidget.h"
19 #include "SkRasterWidget.h"
20 #include "SkDrawCommandGeometryWidget.h"
21 #include "SkSettingsWidget.h"
22 #include <QtCore/QFileSystemWatcher>
23 #include <QtCore/QSignalMapper>
24 #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>
33 #include <QtGui/QSplitter>
34 #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  */
46 class SkDebuggerGUI : public QMainWindow {
47     Q_OBJECT
48 
49 public:
50     /**
51         Constructs the view of the application.
52         @param parent  The parent container of this widget.
53      */
54     SkDebuggerGUI(QWidget *parent = 0);
55 
56     /**
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 
67 Q_SIGNALS:
68     void commandChanged(int command);
69 
70 private Q_SLOTS:
71     /**
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     /**
82         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     /**
92         Closes the application.
93      */
94     void actionClose();
95 
96     /**
97         Deletes the command in question.
98      */
99     void actionDelete();
100 
101 #if SK_SUPPORT_GPU
102     /**
103         Updates the visibility of the GL canvas widget and sample count of the GL surface.
104      */
105     void actionGLSettingsChanged();
106 #endif
107 
108     /**
109         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     /**
120         Sets the visibility of the raster canvas widget according to the settings widget.
121      */
122     void actionRasterSettingsChanged();
123 
124     /**
125         Sets the visualization settings according to the settings widget.
126      */
127     void actionVisualizationsChanged();
128 
129     /**
130         Applies the new texture filter override
131      */
132     void actionTextureFilter();
133 
134     /**
135         Rewinds from the current step back to the start of the commands.
136      */
137     void actionRewind();
138 
139     /**
140         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     /**
150         Sends the scale factor information to the settings widget.
151      */
152     void actionScale(float scaleFactor);
153 
154     /**
155         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     /**
170         Called when the canvas is done being drawn to by SkCanvasWidget.
171      */
172     void drawComplete();
173 
174     /**
175         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
181         the selected file.
182      */
183     void openFile();
184 
185     /**
186         Toggles whether drawing to a new command requires a double click
187         or simple focus.
188      */
189     void pauseDrawing(bool isPaused = true);
190 
191     /**
192         Updates the UI based on the selected command.
193      */
194     void updateDrawCommandInfo();
195 
196     /**
197         Sets the command to active in the list widget.
198      */
199     void selectCommand(int command);
200 
201     /**
202         Toggles the exclusive listing of commands set as deleted.
203      */
204     void showDeletes();
205 
206     /**
207         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     /**
217         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     /**
223         Filters the list widgets command visibility based on the currently
224         active selection.
225      */
226     void toggleFilter(QString string);
227 
228     void updateHit(int newHit);
229 
230     void updateImage();
231 private:
232     QSplitter fCentralSplitter;
233     QStatusBar fStatusBar;
234     QToolBar fToolBar;
235 
236     QAction fActionOpen;
237     QAction fActionBreakpoint;
238     QAction fActionCancel;
239     QAction fActionClearBreakpoints;
240     QAction fActionClearDeletes;
241     QAction fActionClose;
242     QAction fActionCreateBreakpoint;
243     QAction fActionDelete;
244     QAction fActionDirectory;
245     QAction fActionGoToLine;
246     QAction fActionInspector;
247     QAction fActionSettings;
248     QAction fActionPlay;
249     QAction fActionPause;
250     QAction fActionRewind;
251     QAction fActionSave;
252     QAction fActionSaveAs;
253     QAction fActionShowDeletes;
254     QAction fActionStepBack;
255     QAction fActionStepForward;
256     QAction fActionZoomIn;
257     QAction fActionZoomOut;
258     QSignalMapper fMapper;
259 
260     QWidget fSpacer;
261     QComboBox fFilter;
262 
263     QSplitter fLeftColumnSplitter;
264     QWidget fMainAndRightColumnWidget;
265     QVBoxLayout fMainAndRightColumnLayout;
266     QHBoxLayout fCanvasSettingsAndImageLayout;
267     QVBoxLayout fSettingsAndImageLayout;
268 
269     QListWidget fListWidget;
270     QListWidget fDirectoryWidget;
271 
272     QFileSystemWatcher fDirectoryWatcher;
273 
274     SkDebugger fDebugger;
275     SkCanvasWidget fCanvasWidget;
276 
277     SkInspectorWidget fInspectorWidget;
278     SkSettingsWidget fSettingsWidget;
279 
280     QFrame fViewStateFrame;
281     QVBoxLayout fViewStateFrameLayout;
282     QGroupBox fViewStateGroup;
283     QFormLayout fViewStateLayout;
284     QLineEdit fCurrentCommandBox;
285     QLineEdit fCommandHitBox;
286     QLineEdit fZoomBox;
287     SkDrawCommandGeometryWidget fDrawCommandGeometryWidget;
288 
289     QString fPath;
290     SkString fFileName;
291     SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
292 
293     QMenuBar fMenuBar;
294     QMenu fMenuFile;
295     QMenu fMenuEdit;
296     QMenu fMenuNavigate;
297     QMenu fMenuView;
298     QMenu fMenuWindows;
299 
300     bool fLoading;
301     int fPausedRow;
302 
303     /**
304         Creates the entire UI.
305      */
306     void setupUi(QMainWindow *SkDebuggerGUI);
307 
308     /**
309         Pipes a QString in with the location of the filename, proceeds to updating
310         the listwidget, combowidget and inspectorwidget.
311      */
312     void loadPicture(const SkString& fileName);
313 
314     /**
315         Creates a picture of the current canvas.
316      */
317     void saveToFile(const SkString& filename);
318 
319     /**
320         Populates the list widget with the debugger draw command info.
321      */
322     void setupListWidget();
323 
324     /**
325         Populates the combo box widget with with the debugger draw command info.
326      */
327     void setupComboBox();
328 
329     /**
330         Fills in the overview pane with text
331      */
332     void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
333 
isPaused()334     bool isPaused() const {
335         return fActionPause.isChecked();
336     }
337 };
338 
339 #endif // SKDEBUGGERUI_H
340