blob: 465786e661307b1479589ea022ba4c0ffe0e5e9f [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 /**
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;
169 QAction fActionClose;
170 QAction fActionDelete;
171 QAction fActionDirectory;
172 QAction fActionGoToLine;
173 QAction fActionInspector;
174 QAction fActionPlay;
175 QAction fActionReload;
176 QAction fActionRewind;
177 QAction fActionSettings;
178 QAction fActionStepBack;
179 QAction fActionStepForward;
180 QWidget fCentralWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000181
chudy@google.comc432f002012-07-10 13:19:25 +0000182 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183
chudy@google.comc432f002012-07-10 13:19:25 +0000184 QVBoxLayout fLeftColumnLayout;
185 QVBoxLayout fMainAndRightColumnLayout;
186 QHBoxLayout fContainerLayout;
187 QHBoxLayout fCanvasAndSettingsLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000188
chudy@google.comc432f002012-07-10 13:19:25 +0000189 QListWidget fListWidget;
190 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000191
chudy@google.comc432f002012-07-10 13:19:25 +0000192 SkCanvasWidget fCanvasWidget;
193 SkInspectorWidget fInspectorWidget;
194 SkSettingsWidget fSettingsWidget;
195 QStatusBar fStatusBar;
196
chudy@google.com902ebe52012-06-29 14:21:22 +0000197 QString fPath;
198 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000199
chudy@google.comc432f002012-07-10 13:19:25 +0000200 QMenuBar fMenuBar;
201 QMenu fMenuFile;
202 QMenu fMenuNavigate;
203 QMenu fMenuView;
204 QToolBar fToolBar;
chudy@google.com902ebe52012-06-29 14:21:22 +0000205
206 bool fBreakpointsActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000207 bool fPause;
chudy@google.com233e4b82012-07-12 14:38:49 +0000208 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000209
210 /**
211 Creates the entire UI.
212 */
213 void setupUi(QMainWindow *SkDebuggerGUI);
214
215 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000216 Pipes a QString in with the location of the filename, proceeds to updating
217 the listwidget, combowidget and inspectorwidget.
218 */
219 void loadPicture(QString fileName);
220
221 /**
222 Populates the list widget with the vector of strings passed in.
223 */
224 void setupListWidget(std::vector<std::string>* cv);
225
226 /**
227 Populates the combo box widget with the vector of strings passed in.
228 */
229 void setupComboBox(std::vector<std::string>* cv);
230
231 /**
232 Updates the directory widget with the latest directory path stored in
233 the global class variable fPath.
234 */
235 void setupDirectoryWidget();
236};
237
238#endif // SKDEBUGGERUI_H