blob: 4b8a151d3e54a4c89c9b8fc16bc791fc86086d88 [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 */
137 void pauseDrawing(int state);
138
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:
161 QAction* fActionOpen;
162 QAction* fActionDirectory;
163 QAction* fActionRewind;
164 QAction* fActionStepBack;
165 QAction* fActionStepForward;
166 QAction* fActionPlay;
167 QAction* fActionBreakpoint;
168 QAction* fActionInspector;
169 QAction* fActionDelete;
170 QAction* fActionReload;
171 QAction* fActionClose;
172 QAction* fActionSettings;
173
174 QComboBox* fFilter;
175 QAction* fActionCancel;
176
177 QWidget* fCentralWidget;
178 QHBoxLayout* fHorizontalLayout;
179 QHBoxLayout* fHorizontalLayout_2;
180 QVBoxLayout* fVerticalLayout;
181 QVBoxLayout* fVerticalLayout_2;
182 QListWidget* fListWidget;
183 QListWidget* fDirectoryWidget;
184 QListView* fListView;
185 QStatusBar* fStatusBar;
186 QToolBar* fToolBar;
187
188 SkCanvasWidget* fCanvasWidget;
189 SkInspectorWidget* fInspectorWidget;
190 SkSettingsWidget* fSettingsWidget;
191
192 QDir* fDir;
193 QString fPath;
194 bool fDirectoryWidgetActive;
195 QMenuBar* fMenuBar;
196
197 QMenu* fMenuFile;
198 QAction* fActionQuit;
199 QAction* fActionTemp;
200
chudy@google.com902ebe52012-06-29 14:21:22 +0000201 QMenu* fMenuNavigate;
202 QAction *fActionGoToLine;
203
204 bool fBreakpointsActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000205 bool fPause;
chudy@google.com902ebe52012-06-29 14:21:22 +0000206
207 /**
208 Creates the entire UI.
209 */
210 void setupUi(QMainWindow *SkDebuggerGUI);
211
212 /**
213 Placeholder function for executing new commands on window translate
214 and resize.
215 */
216 void retranslateUi(QMainWindow *SkDebuggerGUI);
217
218 /**
219 Pipes a QString in with the location of the filename, proceeds to updating
220 the listwidget, combowidget and inspectorwidget.
221 */
222 void loadPicture(QString fileName);
223
224 /**
225 Populates the list widget with the vector of strings passed in.
226 */
227 void setupListWidget(std::vector<std::string>* cv);
228
229 /**
230 Populates the combo box widget with the vector of strings passed in.
231 */
232 void setupComboBox(std::vector<std::string>* cv);
233
234 /**
235 Updates the directory widget with the latest directory path stored in
236 the global class variable fPath.
237 */
238 void setupDirectoryWidget();
239};
240
241#endif // SKDEBUGGERUI_H