blob: 937476ab9acefdc17b8c61c791cf0e444699b8fc [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"
14#include "SkDebugCanvas.h"
15#include "SkListWidget.h"
16#include "SkInspectorWidget.h"
17#include "SkCanvasWidget.h"
18#include "SkSettingsWidget.h"
19#include <QtCore/QVariant>
20#include <QtGui/QAction>
21#include <QtGui/QApplication>
22#include <QtGui/QButtonGroup>
23#include <QtGui/QHBoxLayout>
24#include <QtGui/QHeaderView>
25#include <QtGui/QListView>
26#include <QtGui/QListWidget>
27#include <QtGui/QMainWindow>
28#include <QtGui/QStatusBar>
29#include <QtGui/QToolBar>
30#include <QtGui/QVBoxLayout>
31#include <QtGui/QWidget>
32#include <QtGui/QMenu>
33#include <QtGui/QMenuBar>
34#include <vector>
35
36/** \class SkDebuggerGUI
37
38 Container for the UI and it's functions.
39 */
40class SkDebuggerGUI : public QMainWindow {
41 Q_OBJECT
42
43public:
44 /**
45 Constructs the view of the application.
46 @param parent The parent container of this widget.
47 */
48 SkDebuggerGUI(QWidget *parent = 0);
49
50 ~SkDebuggerGUI();
51
chudy@google.com7dcae672012-07-09 20:26:53 +000052signals:
53 void commandChanged(int command);
54
chudy@google.com902ebe52012-06-29 14:21:22 +000055private slots:
56 /**
57 Toggles breakpoint view in the list widget.
58 */
59 void actionBreakpoints();
60
61 /**
62 Cancels the command filter in the list widget.
63 */
64 void actionCancel();
65
66 /**
67 Applies a visible filter to all drawing commands other than the previous.
68 */
69 void actionCommandFilter();
70
71 /**
72 Closes the application.
73 */
74 void actionClose();
75
76 /**
77 Deletes the command in question.
78 */
79 void actionDelete();
80
81 /**
82 Toggles the visibility of the inspector widget.
83 */
84 void actionInspector();
85
86 /**
87 Plays from the current step to the next breakpoint if it exists, otherwise
88 executes all remaining draw commands.
89 */
90 void actionPlay();
91
92 /**
93 Resets all deleted commands.
94 */
95 void actionReload();
96
97 /**
98 Rewinds from the current step back to the start of the commands.
99 */
100 void actionRewind();
101
102 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000103 Sends the scale factor information to the settings widget.
104 */
105 void actionScale(float scaleFactor);
106
107 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000108 Toggles the settings widget visibility.
109 */
110 void actionSettings();
111
112 /**
113 Steps forward to the next draw command.
114 */
115 void actionStepBack();
116
117 /**
118 Steps backwards to the next draw command.
119 */
120 void actionStepForward();
121
122 /**
123 Loads an skpicture selected from the directory.
124 */
125 void loadFile(QListWidgetItem *item);
126
127 /**
128 Toggles a dialog with a file browser for navigating to a skpicture. Loads
129 the seleced file.
130 */
131 void openFile();
132
133 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000134 Toggles whether drawing to a new command requires a double click
135 or simple focus.
136 */
chudy@google.come504de02012-07-16 18:35:23 +0000137 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000138
139 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000140 Executes draw commands up to the selected command
141 */
142 void registerListClick(QListWidgetItem *item);
143
144 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000145 Sets the command to active in the list widget.
146 */
147 void selectCommand(int command);
148
149 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000150 Toggles a breakpoint on the current step in the list widget.
151 */
152 void toggleBreakpoint();
153
154 /**
155 Toggles the visibility of the directory widget.
156 */
157 void toggleDirectory();
158
159 /**
160 Filters the list widgets command visibility based on the currently
161 active selection.
162 */
163 void toggleFilter(QString string);
164
165private:
chudy@google.comc432f002012-07-10 13:19:25 +0000166 QAction fActionOpen;
167 QAction fActionBreakpoint;
168 QAction fActionCancel;
chudy@google.come504de02012-07-16 18:35:23 +0000169 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000170 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000171 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000172 QAction fActionDelete;
173 QAction fActionDirectory;
174 QAction fActionGoToLine;
175 QAction fActionInspector;
176 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000177 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000178 QAction fActionReload;
179 QAction fActionRewind;
chudy@google.comc432f002012-07-10 13:19:25 +0000180 QAction fActionStepBack;
181 QAction fActionStepForward;
182 QWidget fCentralWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183
chudy@google.comc432f002012-07-10 13:19:25 +0000184 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000185
chudy@google.comc432f002012-07-10 13:19:25 +0000186 QVBoxLayout fLeftColumnLayout;
187 QVBoxLayout fMainAndRightColumnLayout;
188 QHBoxLayout fContainerLayout;
189 QHBoxLayout fCanvasAndSettingsLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000190
chudy@google.comc432f002012-07-10 13:19:25 +0000191 QListWidget fListWidget;
192 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000193
chudy@google.comc432f002012-07-10 13:19:25 +0000194 SkCanvasWidget fCanvasWidget;
195 SkInspectorWidget fInspectorWidget;
196 SkSettingsWidget fSettingsWidget;
197 QStatusBar fStatusBar;
198
chudy@google.com902ebe52012-06-29 14:21:22 +0000199 QString fPath;
200 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000201
chudy@google.comc432f002012-07-10 13:19:25 +0000202 QMenuBar fMenuBar;
203 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000204 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000205 QMenu fMenuNavigate;
206 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000207 QMenu fMenuWindows;
chudy@google.comc432f002012-07-10 13:19:25 +0000208 QToolBar fToolBar;
chudy@google.com902ebe52012-06-29 14:21:22 +0000209
210 bool fBreakpointsActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000211 bool fPause;
chudy@google.com233e4b82012-07-12 14:38:49 +0000212 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000213
214 /**
215 Creates the entire UI.
216 */
217 void setupUi(QMainWindow *SkDebuggerGUI);
218
219 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000220 Pipes a QString in with the location of the filename, proceeds to updating
221 the listwidget, combowidget and inspectorwidget.
222 */
223 void loadPicture(QString fileName);
224
225 /**
226 Populates the list widget with the vector of strings passed in.
227 */
228 void setupListWidget(std::vector<std::string>* cv);
229
230 /**
231 Populates the combo box widget with the vector of strings passed in.
232 */
233 void setupComboBox(std::vector<std::string>* cv);
234
235 /**
236 Updates the directory widget with the latest directory path stored in
237 the global class variable fPath.
238 */
239 void setupDirectoryWidget();
240};
241
242#endif // SKDEBUGGERUI_H