aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/QT/SkDebuggerGUI.h
blob: f9960a32d961007788b36446b91bd79315c03677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SKDEBUGGERUI_H
#define SKDEBUGGERUI_H


#include "SkCanvas.h"
#include "SkCanvasWidget.h"
#include "SkDebugger.h"
#include "SkGLWidget.h"
#include "SkListWidget.h"
#include "SkInspectorWidget.h"
#include "SkRasterWidget.h"
#include "SkImageWidget.h"
#include "SkSettingsWidget.h"
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QListView>
#include <QtGui/QListWidget>
#include <QtGui/QMainWindow>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <vector>

class SkTimedPicture;
namespace sk_tools {
    class PictureRenderer;
}

/** \class SkDebuggerGUI

    Container for the UI and it's functions.
 */
class SkDebuggerGUI : public QMainWindow {
    Q_OBJECT

public:
    /**
        Constructs the view of the application.
        @param parent  The parent container of this widget.
     */
    SkDebuggerGUI(QWidget *parent = 0);

    ~SkDebuggerGUI();

    /**
        Updates the directory widget with the latest directory path stored in
        the global class variable fPath.
     */
    void setupDirectoryWidget(const QString& path);

    /**
        Loads the specified file.
    */
    void openFile(const QString& filename);

signals:
    void commandChanged(int command);

private slots:
    /**
        Toggles breakpoint view in the list widget.
     */
    void actionBreakpoints();

    /**
        Profile the commands
     */
    void actionProfile();

    /**
        Cancels the command filter in the list widget.
     */
    void actionCancel();

    /**
        Clears the breakpoint state off of all commands marked as breakpoints.
     */
    void actionClearBreakpoints();

    /**
        Clears the deleted state off of all commands marked as deleted.
     */
    void actionClearDeletes();

    /**
        Applies a visible filter to all drawing commands other than the previous.
     */
    void actionCommandFilter();

    /**
        Closes the application.
     */
    void actionClose();

    /**
        Deletes the command in question.
     */
    void actionDelete();

#if SK_SUPPORT_GPU
    /**
        Toggles the visibility of the GL canvas widget.
     */
    void actionGLWidget(bool isToggled);
#endif

    /**
        Toggles the visibility of the inspector widget.
     */
    void actionInspector();

    /**
        Plays from the current step to the next breakpoint if it exists, otherwise
        executes all remaining draw commands.
     */
    void actionPlay();

    /**
        Toggles the visibility of the raster canvas widget.
     */
    void actionRasterWidget(bool isToggled);

    /**
        Toggles the the overdraw visualization on and off
     */
    void actionOverdrawVizWidget(bool isToggled);

    /**
        Rewinds from the current step back to the start of the commands.
     */
    void actionRewind();

    /**
        Saves the current SKP with all modifications.
     */
    void actionSave();

    /**
        Saves the current SKP under a different name and/or location.
     */
    void actionSaveAs();

    /**
        Sends the scale factor information to the settings widget.
     */
    void actionScale(float scaleFactor);

    /**
        Toggles the settings widget visibility.
     */
    void actionSettings();

    /**
        Steps forward to the next draw command.
     */
    void actionStepBack();

    /**
        Steps backwards to the next draw command.
     */
    void actionStepForward();

    /**
        Called when the canvas is done being drawn to by SkCanvasWidget.
     */
    void drawComplete();

    /**
        Loads an skpicture selected from the directory.
     */
    void loadFile(QListWidgetItem *item);

    /**
        Toggles a dialog with a file browser for navigating to a skpicture. Loads
        the selected file.
     */
    void openFile();

    /**
        Toggles whether drawing to a new command requires a double click
        or simple focus.
     */
    void pauseDrawing(bool isPaused = true);

    /**
        Executes draw commands up to the selected command
     */
    void registerListClick(QListWidgetItem *item);

    /**
        Sets the command to active in the list widget.
     */
    void selectCommand(int command);

    /**
        Toggles the exclusive listing of commands set as deleted.
     */
    void showDeletes();

    /**
        Toggles a breakpoint on the current step in the list widget.
     */
    void toggleBreakpoint();

    /**
        Toggles the visibility of the directory widget.
     */
    void toggleDirectory();

    /**
        Filters the list widgets command visibility based on the currently
        active selection.
     */
    void toggleFilter(QString string);

private:
    QWidget fCentralWidget;
    QStatusBar fStatusBar;
    QToolBar fToolBar;

    QAction fActionOpen;
    QAction fActionBreakpoint;
    QAction fActionProfile;
    QAction fActionCancel;
    QAction fActionClearBreakpoints;
    QAction fActionClearDeletes;
    QAction fActionClose;
    QAction fActionCreateBreakpoint;
    QAction fActionDelete;
    QAction fActionDirectory;
    QAction fActionGoToLine;
    QAction fActionInspector;
    QAction fActionPlay;
    QAction fActionPause;
    QAction fActionRewind;
    QAction fActionSave;
    QAction fActionSaveAs;
    QAction fActionShowDeletes;
    QAction fActionStepBack;
    QAction fActionStepForward;
    QAction fActionZoomIn;
    QAction fActionZoomOut;
    QSignalMapper fMapper;

    QWidget fSpacer;
    QComboBox fFilter;

    QHBoxLayout fContainerLayout;
    QVBoxLayout fLeftColumnLayout;
    QVBoxLayout fMainAndRightColumnLayout;
    QHBoxLayout fCanvasSettingsAndImageLayout;
    QVBoxLayout fSettingsAndImageLayout;

    QListWidget fListWidget;
    QListWidget fDirectoryWidget;

    SkDebugger fDebugger;
    SkCanvasWidget fCanvasWidget;
    SkImageWidget fImageWidget;
    SkInspectorWidget fInspectorWidget;
    SkSettingsWidget fSettingsWidget;

    QString fPath;
    SkString fFileName;
    SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture
    SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
    bool fDirectoryWidgetActive;

    QMenuBar fMenuBar;
    QMenu fMenuFile;
    QMenu fMenuEdit;
    QMenu fMenuNavigate;
    QMenu fMenuView;
    QMenu fMenuWindows;

    bool fBreakpointsActivated;
    bool fDeletesActivated;
    bool fPause;
    bool fLoading;
    int fPausedRow;

    /**
        Creates the entire UI.
     */
    void setupUi(QMainWindow *SkDebuggerGUI);

    /**
        Pipes a QString in with the location of the filename, proceeds to updating
        the listwidget, combowidget and inspectorwidget.
     */
    void loadPicture(const SkString& fileName);

    /**
        Creates a picture of the current canvas.
     */
    void saveToFile(const SkString& filename);

    /**
        Populates the list widget with the vector of strings passed in.
     */
    void setupListWidget(SkTArray<SkString>* command);

    /**
        Populates the combo box widget with the vector of strings passed in.
     */
    void setupComboBox(SkTArray<SkString>* command);

    /**
        Fills in the overview pane with text
     */
    void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);

    /**
        Render the supplied picture several times tracking the time consumed
        by each command.
     */
    void run(SkTimedPicture* pict,
             sk_tools::PictureRenderer* renderer,
             int repeats);
};

#endif // SKDEBUGGERUI_H