SkDebuggerGUI.h revision 97cee9735350cb472249ce1a827ba1aa6b2a5f59
1 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 "SkCanvasWidget.h" 15#include "SkDebugger.h" 16#include "SkGLWidget.h" 17#include "SkListWidget.h" 18#include "SkInspectorWidget.h" 19#include "SkRasterWidget.h" 20#include "SkSettingsWidget.h" 21#include <QtCore/QVariant> 22#include <QtGui/QAction> 23#include <QtGui/QApplication> 24#include <QtGui/QButtonGroup> 25#include <QtGui/QHBoxLayout> 26#include <QtGui/QHeaderView> 27#include <QtGui/QListView> 28#include <QtGui/QListWidget> 29#include <QtGui/QMainWindow> 30#include <QtGui/QStatusBar> 31#include <QtGui/QToolBar> 32#include <QtGui/QVBoxLayout> 33#include <QtGui/QWidget> 34#include <QtGui/QMenu> 35#include <QtGui/QMenuBar> 36#include <vector> 37 38/** \class SkDebuggerGUI 39 40 Container for the UI and it's functions. 41 */ 42class SkDebuggerGUI : public QMainWindow { 43 Q_OBJECT 44 45public: 46 /** 47 Constructs the view of the application. 48 @param parent The parent container of this widget. 49 */ 50 SkDebuggerGUI(QWidget *parent = 0); 51 52 ~SkDebuggerGUI(); 53 54signals: 55 void commandChanged(int command); 56 57private slots: 58 /** 59 Toggles breakpoint view in the list widget. 60 */ 61 void actionBreakpoints(); 62 63 /** 64 Cancels the command filter in the list widget. 65 */ 66 void actionCancel(); 67 68 /** 69 Clears the breakpoint state off of all commands marked as breakpoints. 70 */ 71 void actionClearBreakpoints(); 72 73 /** 74 Clears the deleted state off of all commands marked as deleted. 75 */ 76 void actionClearDeletes(); 77 78 /** 79 Applies a visible filter to all drawing commands other than the previous. 80 */ 81 void actionCommandFilter(); 82 83 /** 84 Closes the application. 85 */ 86 void actionClose(); 87 88 /** 89 Deletes the command in question. 90 */ 91 void actionDelete(); 92 93 /** 94 Toggles the visibility of the GL canvas widget. 95 */ 96 void actionGLWidget(bool isToggled); 97 98 /** 99 Toggles the visibility of the inspector widget. 100 */ 101 void actionInspector(); 102 103 /** 104 Plays from the current step to the next breakpoint if it exists, otherwise 105 executes all remaining draw commands. 106 */ 107 void actionPlay(); 108 109 /** 110 Toggles the visibility of the raster canvas widget. 111 */ 112 void actionRasterWidget(bool isToggled); 113 114 /** 115 Rewinds from the current step back to the start of the commands. 116 */ 117 void actionRewind(); 118 119 /** 120 Saves the current SKP with all modifications. 121 */ 122 void actionSave(); 123 124 /** 125 Saves the current SKP under a different name and/or location. 126 */ 127 void actionSaveAs(); 128 129 /** 130 Sends the scale factor information to the settings widget. 131 */ 132 void actionScale(float scaleFactor); 133 134 /** 135 Toggles the settings widget visibility. 136 */ 137 void actionSettings(); 138 139 /** 140 Steps forward to the next draw command. 141 */ 142 void actionStepBack(); 143 144 /** 145 Steps backwards to the next draw command. 146 */ 147 void actionStepForward(); 148 149 /** 150 Called when the canvas is done being drawn to by SkCanvasWidget. 151 */ 152 void drawComplete(); 153 154 /** 155 Loads an skpicture selected from the directory. 156 */ 157 void loadFile(QListWidgetItem *item); 158 159 /** 160 Toggles a dialog with a file browser for navigating to a skpicture. Loads 161 the seleced file. 162 */ 163 void openFile(); 164 165 /** 166 Toggles whether drawing to a new command requires a double click 167 or simple focus. 168 */ 169 void pauseDrawing(bool isPaused = true); 170 171 /** 172 Executes draw commands up to the selected command 173 */ 174 void registerListClick(QListWidgetItem *item); 175 176 /** 177 Sets the command to active in the list widget. 178 */ 179 void selectCommand(int command); 180 181 /** 182 Toggles the exclusive listing of commands set as deleted. 183 */ 184 void showDeletes(); 185 186 /** 187 Toggles a breakpoint on the current step in the list widget. 188 */ 189 void toggleBreakpoint(); 190 191 /** 192 Toggles the visibility of the directory widget. 193 */ 194 void toggleDirectory(); 195 196 /** 197 Filters the list widgets command visibility based on the currently 198 active selection. 199 */ 200 void toggleFilter(QString string); 201 202private: 203 QWidget fCentralWidget; 204 QStatusBar fStatusBar; 205 QToolBar fToolBar; 206 207 QAction fActionOpen; 208 QAction fActionBreakpoint; 209 QAction fActionCancel; 210 QAction fActionClearBreakpoints; 211 QAction fActionClearDeletes; 212 QAction fActionClose; 213 QAction fActionCreateBreakpoint; 214 QAction fActionDelete; 215 QAction fActionDirectory; 216 QAction fActionGoToLine; 217 QAction fActionInspector; 218 QAction fActionPlay; 219 QAction fActionPause; 220 QAction fActionRewind; 221 QAction fActionSave; 222 QAction fActionSaveAs; 223 QAction fActionShowDeletes; 224 QAction fActionStepBack; 225 QAction fActionStepForward; 226 QAction fActionZoomIn; 227 QAction fActionZoomOut; 228 QSignalMapper fMapper; 229 230 QWidget fSpacer; 231 QComboBox fFilter; 232 233 QHBoxLayout fContainerLayout; 234 QVBoxLayout fLeftColumnLayout; 235 QVBoxLayout fMainAndRightColumnLayout; 236 QHBoxLayout fCanvasAndSettingsLayout; 237 238 QListWidget fListWidget; 239 QListWidget fDirectoryWidget; 240 241 SkDebugger fDebugger; 242 SkCanvasWidget fCanvasWidget; 243 SkInspectorWidget fInspectorWidget; 244 SkSettingsWidget fSettingsWidget; 245 246 QString fPath; 247 bool fDirectoryWidgetActive; 248 249 QMenuBar fMenuBar; 250 QMenu fMenuFile; 251 QMenu fMenuEdit; 252 QMenu fMenuNavigate; 253 QMenu fMenuView; 254 QMenu fMenuWindows; 255 256 bool fBreakpointsActivated; 257 bool fDeletesActivated; 258 bool fPause; 259 bool fLoading; 260 int fPausedRow; 261 262 /** 263 Creates the entire UI. 264 */ 265 void setupUi(QMainWindow *SkDebuggerGUI); 266 267 /** 268 Pipes a QString in with the location of the filename, proceeds to updating 269 the listwidget, combowidget and inspectorwidget. 270 */ 271 void loadPicture(QString fileName); 272 273 /** 274 Creates a picture of the current canvas. 275 */ 276 void saveToFile(QString filename); 277 278 /** 279 Populates the list widget with the vector of strings passed in. 280 */ 281 void setupListWidget(SkTDArray<SkString*>* command); 282 283 /** 284 Populates the combo box widget with the vector of strings passed in. 285 */ 286 void setupComboBox(SkTDArray<SkString*>* command); 287 288 /** 289 Updates the directory widget with the latest directory path stored in 290 the global class variable fPath. 291 */ 292 void setupDirectoryWidget(); 293}; 294 295#endif // SKDEBUGGERUI_H 296