blob: 11eb856fd4b952790d16b6e762d27f6444e25f4c [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.comc432f002012-07-10 13:19:25 +0000137 void pauseDrawing(bool isPaused);
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 /**
145 Toggles a breakpoint on the current step in the list widget.
146 */
147 void toggleBreakpoint();
148
149 /**
150 Toggles the visibility of the directory widget.
151 */
152 void toggleDirectory();
153
154 /**
155 Filters the list widgets command visibility based on the currently
156 active selection.
157 */
158 void toggleFilter(QString string);
159
160private:
chudy@google.comc432f002012-07-10 13:19:25 +0000161 QAction fActionOpen;
162 QAction fActionBreakpoint;
163 QAction fActionCancel;
164 QAction fActionClose;
165 QAction fActionDelete;
166 QAction fActionDirectory;
167 QAction fActionGoToLine;
168 QAction fActionInspector;
169 QAction fActionPlay;
170 QAction fActionReload;
171 QAction fActionRewind;
172 QAction fActionSettings;
173 QAction fActionStepBack;
174 QAction fActionStepForward;
175 QWidget fCentralWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000176
chudy@google.comc432f002012-07-10 13:19:25 +0000177 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000178
chudy@google.comc432f002012-07-10 13:19:25 +0000179 QVBoxLayout fLeftColumnLayout;
180 QVBoxLayout fMainAndRightColumnLayout;
181 QHBoxLayout fContainerLayout;
182 QHBoxLayout fCanvasAndSettingsLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183
chudy@google.comc432f002012-07-10 13:19:25 +0000184 QListWidget fListWidget;
185 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000186
chudy@google.comc432f002012-07-10 13:19:25 +0000187 SkCanvasWidget fCanvasWidget;
188 SkInspectorWidget fInspectorWidget;
189 SkSettingsWidget fSettingsWidget;
190 QStatusBar fStatusBar;
191
chudy@google.com902ebe52012-06-29 14:21:22 +0000192 QString fPath;
193 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000194
chudy@google.comc432f002012-07-10 13:19:25 +0000195 QMenuBar fMenuBar;
196 QMenu fMenuFile;
197 QMenu fMenuNavigate;
198 QMenu fMenuView;
199 QToolBar fToolBar;
chudy@google.com902ebe52012-06-29 14:21:22 +0000200
201 bool fBreakpointsActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000202 bool fPause;
chudy@google.com233e4b82012-07-12 14:38:49 +0000203 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000204
205 /**
206 Creates the entire UI.
207 */
208 void setupUi(QMainWindow *SkDebuggerGUI);
209
210 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000211 Pipes a QString in with the location of the filename, proceeds to updating
212 the listwidget, combowidget and inspectorwidget.
213 */
214 void loadPicture(QString fileName);
215
216 /**
217 Populates the list widget with the vector of strings passed in.
218 */
219 void setupListWidget(std::vector<std::string>* cv);
220
221 /**
222 Populates the combo box widget with the vector of strings passed in.
223 */
224 void setupComboBox(std::vector<std::string>* cv);
225
226 /**
227 Updates the directory widget with the latest directory path stored in
228 the global class variable fPath.
229 */
230 void setupDirectoryWidget();
231};
232
233#endif // SKDEBUGGERUI_H