Mercurial > hg > sonic-visualiser
comparison main/MainWindow.h @ 0:cd5d7ff8ef38
* Reorganising code base. This revision will not compile.
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 12:03:45 +0000 |
parents | |
children | 40116f709d3b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cd5d7ff8ef38 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _MAIN_WINDOW_H_ | |
17 #define _MAIN_WINDOW_H_ | |
18 | |
19 #include <QFrame> | |
20 #include <QString> | |
21 #include <QMainWindow> | |
22 #include <QPointer> | |
23 | |
24 #include "base/Command.h" | |
25 #include "base/ViewManager.h" | |
26 #include "base/PropertyContainer.h" | |
27 #include "layer/LayerFactory.h" | |
28 #include "transform/Transform.h" | |
29 #include "fileio/SVFileReader.h" | |
30 #include <map> | |
31 | |
32 class Document; | |
33 class PaneStack; | |
34 class Pane; | |
35 class View; | |
36 class Fader; | |
37 class Panner; | |
38 class Layer; | |
39 class WaveformLayer; | |
40 class WaveFileModel; | |
41 class AudioCallbackPlaySource; | |
42 class AudioCallbackPlayTarget; | |
43 class CommandHistory; | |
44 class QMenu; | |
45 class AudioDial; | |
46 class QLabel; | |
47 class PreferencesDialog; | |
48 | |
49 | |
50 class MainWindow : public QMainWindow | |
51 { | |
52 Q_OBJECT | |
53 | |
54 public: | |
55 MainWindow(); | |
56 virtual ~MainWindow(); | |
57 | |
58 enum AudioFileOpenMode { | |
59 ReplaceMainModel, | |
60 CreateAdditionalModel, | |
61 AskUser | |
62 }; | |
63 | |
64 bool openSomeFile(QString path); | |
65 bool openAudioFile(QString path, AudioFileOpenMode = AskUser); | |
66 bool openLayerFile(QString path); | |
67 bool openSessionFile(QString path); | |
68 bool saveSessionFile(QString path); | |
69 | |
70 signals: | |
71 // Used to toggle the availability of menu actions | |
72 void canAddPane(bool); | |
73 void canDeleteCurrentPane(bool); | |
74 void canAddLayer(bool); | |
75 void canImportMoreAudio(bool); | |
76 void canImportLayer(bool); | |
77 void canExportAudio(bool); | |
78 void canExportLayer(bool); | |
79 void canRenameLayer(bool); | |
80 void canEditLayer(bool); | |
81 void canSelect(bool); | |
82 void canClearSelection(bool); | |
83 void canEditSelection(bool); | |
84 void canPaste(bool); | |
85 void canInsertInstant(bool); | |
86 void canDeleteCurrentLayer(bool); | |
87 void canZoom(bool); | |
88 void canScroll(bool); | |
89 void canPlay(bool); | |
90 void canFfwd(bool); | |
91 void canRewind(bool); | |
92 void canPlaySelection(bool); | |
93 void canSave(bool); | |
94 | |
95 protected slots: | |
96 void openSession(); | |
97 void importAudio(); | |
98 void importMoreAudio(); | |
99 void openSomething(); | |
100 void openRecentFile(); | |
101 void exportAudio(); | |
102 void importLayer(); | |
103 void exportLayer(); | |
104 void saveSession(); | |
105 void saveSessionAs(); | |
106 void newSession(); | |
107 void closeSession(); | |
108 void preferences(); | |
109 | |
110 void zoomIn(); | |
111 void zoomOut(); | |
112 void zoomToFit(); | |
113 void zoomDefault(); | |
114 void scrollLeft(); | |
115 void scrollRight(); | |
116 void jumpLeft(); | |
117 void jumpRight(); | |
118 | |
119 void showNoOverlays(); | |
120 void showBasicOverlays(); | |
121 void showAllOverlays(); | |
122 | |
123 void play(); | |
124 void ffwd(); | |
125 void ffwdEnd(); | |
126 void rewind(); | |
127 void rewindStart(); | |
128 void stop(); | |
129 | |
130 void addPane(); | |
131 void addLayer(); | |
132 void deleteCurrentPane(); | |
133 void renameCurrentLayer(); | |
134 void deleteCurrentLayer(); | |
135 | |
136 void playLoopToggled(); | |
137 void playSelectionToggled(); | |
138 void playSpeedChanged(int); | |
139 void sampleRateMismatch(size_t, size_t, bool); | |
140 | |
141 void outputLevelsChanged(float, float); | |
142 | |
143 void currentPaneChanged(Pane *); | |
144 void currentLayerChanged(Pane *, Layer *); | |
145 | |
146 void toolNavigateSelected(); | |
147 void toolSelectSelected(); | |
148 void toolEditSelected(); | |
149 void toolDrawSelected(); | |
150 | |
151 void selectAll(); | |
152 void selectToStart(); | |
153 void selectToEnd(); | |
154 void selectVisible(); | |
155 void clearSelection(); | |
156 void cut(); | |
157 void copy(); | |
158 void paste(); | |
159 void deleteSelected(); | |
160 void insertInstant(); | |
161 | |
162 void documentModified(); | |
163 void documentRestored(); | |
164 | |
165 void updateMenuStates(); | |
166 void updateDescriptionLabel(); | |
167 | |
168 void layerAdded(Layer *); | |
169 void layerRemoved(Layer *); | |
170 void layerAboutToBeDeleted(Layer *); | |
171 void layerInAView(Layer *, bool); | |
172 | |
173 void mainModelChanged(WaveFileModel *); | |
174 void modelAdded(Model *); | |
175 void modelAboutToBeDeleted(Model *); | |
176 | |
177 void modelGenerationFailed(QString); | |
178 void modelRegenerationFailed(QString, QString); | |
179 | |
180 void rightButtonMenuRequested(Pane *, QPoint point); | |
181 | |
182 void preferenceChanged(PropertyContainer::PropertyName); | |
183 | |
184 void setupRecentFilesMenu(); | |
185 | |
186 void showLayerTree(); | |
187 | |
188 void website(); | |
189 void help(); | |
190 void about(); | |
191 | |
192 protected: | |
193 QString m_sessionFile; | |
194 QString m_audioFile; | |
195 Document *m_document; | |
196 | |
197 QLabel *m_descriptionLabel; | |
198 PaneStack *m_paneStack; | |
199 ViewManager *m_viewManager; | |
200 Panner *m_panner; | |
201 Fader *m_fader; | |
202 AudioDial *m_playSpeed; | |
203 WaveformLayer *m_panLayer; | |
204 Layer *m_timeRulerLayer; | |
205 | |
206 AudioCallbackPlaySource *m_playSource; | |
207 AudioCallbackPlayTarget *m_playTarget; | |
208 | |
209 bool m_mainMenusCreated; | |
210 QMenu *m_paneMenu; | |
211 QMenu *m_layerMenu; | |
212 QMenu *m_existingLayersMenu; | |
213 QMenu *m_recentFilesMenu; | |
214 QMenu *m_rightButtonMenu; | |
215 QMenu *m_rightButtonLayerMenu; | |
216 | |
217 bool m_documentModified; | |
218 | |
219 QPointer<PreferencesDialog> m_preferencesDialog; | |
220 | |
221 WaveFileModel *getMainModel(); | |
222 void createDocument(); | |
223 | |
224 struct PaneConfiguration { | |
225 PaneConfiguration(LayerFactory::LayerType _layer | |
226 = LayerFactory::TimeRuler, | |
227 int _channel = -1) : | |
228 layer(_layer), channel(_channel) { } | |
229 LayerFactory::LayerType layer; | |
230 int channel; | |
231 }; | |
232 | |
233 typedef std::map<QAction *, PaneConfiguration> PaneActionMap; | |
234 PaneActionMap m_paneActions; | |
235 | |
236 typedef std::map<QAction *, TransformName> TransformActionMap; | |
237 TransformActionMap m_layerTransformActions; | |
238 | |
239 typedef std::map<QAction *, LayerFactory::LayerType> LayerActionMap; | |
240 LayerActionMap m_layerActions; | |
241 | |
242 typedef std::map<QAction *, Layer *> ExistingLayerActionMap; | |
243 ExistingLayerActionMap m_existingLayerActions; | |
244 | |
245 typedef std::map<ViewManager::ToolMode, QAction *> ToolActionMap; | |
246 ToolActionMap m_toolActions; | |
247 | |
248 void setupMenus(); | |
249 void setupExistingLayersMenu(); | |
250 void setupToolbars(); | |
251 Pane *addPaneToStack(); | |
252 | |
253 class PaneCallback : public SVFileReaderPaneCallback | |
254 { | |
255 public: | |
256 PaneCallback(MainWindow *mw) : m_mw(mw) { } | |
257 virtual Pane *addPane() { return m_mw->addPaneToStack(); } | |
258 virtual void setWindowSize(int width, int height) { | |
259 m_mw->resize(width, height); | |
260 } | |
261 virtual void addSelection(int start, int end) { | |
262 m_mw->m_viewManager->addSelection(Selection(start, end)); | |
263 } | |
264 protected: | |
265 MainWindow *m_mw; | |
266 }; | |
267 | |
268 class AddPaneCommand : public Command | |
269 { | |
270 public: | |
271 AddPaneCommand(MainWindow *mw); | |
272 virtual ~AddPaneCommand(); | |
273 | |
274 virtual void execute(); | |
275 virtual void unexecute(); | |
276 virtual QString getName() const; | |
277 | |
278 Pane *getPane() { return m_pane; } | |
279 | |
280 protected: | |
281 MainWindow *m_mw; | |
282 Pane *m_pane; // Main window owns this, but I determine its lifespan | |
283 Pane *m_prevCurrentPane; // I don't own this | |
284 bool m_added; | |
285 }; | |
286 | |
287 class RemovePaneCommand : public Command | |
288 { | |
289 public: | |
290 RemovePaneCommand(MainWindow *mw, Pane *pane); | |
291 virtual ~RemovePaneCommand(); | |
292 | |
293 virtual void execute(); | |
294 virtual void unexecute(); | |
295 virtual QString getName() const; | |
296 | |
297 protected: | |
298 MainWindow *m_mw; | |
299 Pane *m_pane; // Main window owns this, but I determine its lifespan | |
300 Pane *m_prevCurrentPane; // I don't own this | |
301 bool m_added; | |
302 }; | |
303 | |
304 virtual void closeEvent(QCloseEvent *e); | |
305 bool checkSaveModified(); | |
306 | |
307 void createPlayTarget(); | |
308 | |
309 void openHelpUrl(QString url); | |
310 | |
311 void toXml(QTextStream &stream); | |
312 }; | |
313 | |
314 | |
315 #endif |