Mercurial > hg > svgui
comparison view/ViewManager.h @ 127:89c625dda204
* Reorganising code base. This revision will not compile.
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 11:44:37 +0000 |
parents | |
children | 33929e0c3c6b |
comparison
equal
deleted
inserted
replaced
126:0e95c127bb53 | 127:89c625dda204 |
---|---|
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 _VIEW_MANAGER_H_ | |
17 #define _VIEW_MANAGER_H_ | |
18 | |
19 #include <QObject> | |
20 #include <QTimer> | |
21 | |
22 #include <map> | |
23 | |
24 #include "Selection.h" | |
25 #include "Command.h" | |
26 #include "Clipboard.h" | |
27 | |
28 class AudioPlaySource; | |
29 class Model; | |
30 | |
31 /** | |
32 * The ViewManager manages properties that may need to be synchronised | |
33 * between separate Views. For example, it handles signals associated | |
34 * with changes to the global pan and zoom, and it handles selections. | |
35 * | |
36 * Views should be implemented in such a way as to work | |
37 * correctly whether they are supplied with a ViewManager or not. | |
38 */ | |
39 | |
40 class ViewManager : public QObject | |
41 { | |
42 Q_OBJECT | |
43 | |
44 public: | |
45 ViewManager(); | |
46 virtual ~ViewManager(); | |
47 | |
48 void setAudioPlaySource(AudioPlaySource *source); | |
49 | |
50 bool isPlaying() const; | |
51 | |
52 unsigned long getGlobalCentreFrame() const; | |
53 unsigned long getGlobalZoom() const; | |
54 | |
55 unsigned long getPlaybackFrame() const; | |
56 void setPlaybackFrame(unsigned long frame); | |
57 | |
58 bool haveInProgressSelection() const; | |
59 const Selection &getInProgressSelection(bool &exclusive) const; | |
60 void setInProgressSelection(const Selection &selection, bool exclusive); | |
61 void clearInProgressSelection(); | |
62 | |
63 const MultiSelection &getSelection() const; | |
64 | |
65 const MultiSelection::SelectionList &getSelections() const; | |
66 void setSelection(const Selection &selection); | |
67 void addSelection(const Selection &selection); | |
68 void removeSelection(const Selection &selection); | |
69 void clearSelections(); | |
70 | |
71 /** | |
72 * Return the selection that contains a given frame. | |
73 * If defaultToFollowing is true, and if the frame is not in a | |
74 * selected area, return the next selection after the given frame. | |
75 * Return the empty selection if no appropriate selection is found. | |
76 */ | |
77 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const; | |
78 | |
79 Clipboard &getClipboard() { return m_clipboard; } | |
80 | |
81 enum ToolMode { | |
82 NavigateMode, | |
83 SelectMode, | |
84 EditMode, | |
85 DrawMode | |
86 }; | |
87 ToolMode getToolMode() const { return m_toolMode; } | |
88 void setToolMode(ToolMode mode); | |
89 | |
90 bool getPlayLoopMode() const { return m_playLoopMode; } | |
91 void setPlayLoopMode(bool on); | |
92 | |
93 bool getPlaySelectionMode() const { return m_playSelectionMode; } | |
94 void setPlaySelectionMode(bool on); | |
95 | |
96 size_t getPlaybackSampleRate() const; | |
97 size_t getMainModelSampleRate() const { return m_mainModelSampleRate; } | |
98 void setMainModelSampleRate(size_t sr) { m_mainModelSampleRate = sr; } | |
99 | |
100 enum OverlayMode { | |
101 NoOverlays, | |
102 BasicOverlays, | |
103 AllOverlays | |
104 }; | |
105 void setOverlayMode(OverlayMode mode); | |
106 OverlayMode getOverlayMode() const { return m_overlayMode; } | |
107 | |
108 signals: | |
109 /** Emitted when a widget pans. The originator identifies the widget. */ | |
110 void centreFrameChanged(void *originator, unsigned long frame, bool locked); | |
111 | |
112 /** Emitted when a widget zooms. The originator identifies the widget. */ | |
113 void zoomLevelChanged(void *originator, unsigned long zoom, bool locked); | |
114 | |
115 /** Emitted when the playback frame changes. */ | |
116 void playbackFrameChanged(unsigned long frame); | |
117 | |
118 /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */ | |
119 void outputLevelsChanged(float left, float right); | |
120 | |
121 /** Emitted when the selection has changed. */ | |
122 void selectionChanged(); | |
123 | |
124 /** Emitted when the in-progress (rubberbanding) selection has changed. */ | |
125 void inProgressSelectionChanged(); | |
126 | |
127 /** Emitted when the tool mode has been changed. */ | |
128 void toolModeChanged(); | |
129 | |
130 /** Emitted when the play loop mode has been changed. */ | |
131 void playLoopModeChanged(); | |
132 | |
133 /** Emitted when the play selection mode has been changed. */ | |
134 void playSelectionModeChanged(); | |
135 | |
136 /** Emitted when the overlay mode has been changed. */ | |
137 void overlayModeChanged(); | |
138 | |
139 protected slots: | |
140 void checkPlayStatus(); | |
141 void playStatusChanged(bool playing); | |
142 void considerSeek(void *, unsigned long, bool); | |
143 void considerZoomChange(void *, unsigned long, bool); | |
144 | |
145 protected: | |
146 AudioPlaySource *m_playSource; | |
147 unsigned long m_globalCentreFrame; | |
148 unsigned long m_globalZoom; | |
149 mutable unsigned long m_playbackFrame; | |
150 size_t m_mainModelSampleRate; | |
151 | |
152 float m_lastLeft; | |
153 float m_lastRight; | |
154 | |
155 MultiSelection m_selections; | |
156 Selection m_inProgressSelection; | |
157 bool m_inProgressExclusive; | |
158 | |
159 Clipboard m_clipboard; | |
160 | |
161 ToolMode m_toolMode; | |
162 | |
163 bool m_playLoopMode; | |
164 bool m_playSelectionMode; | |
165 | |
166 void setSelections(const MultiSelection &ms); | |
167 void signalSelectionChange(); | |
168 | |
169 class SetSelectionCommand : public Command | |
170 { | |
171 public: | |
172 SetSelectionCommand(ViewManager *vm, const MultiSelection &ms); | |
173 virtual ~SetSelectionCommand(); | |
174 virtual void execute(); | |
175 virtual void unexecute(); | |
176 virtual QString getName() const; | |
177 | |
178 protected: | |
179 ViewManager *m_vm; | |
180 MultiSelection m_oldSelection; | |
181 MultiSelection m_newSelection; | |
182 }; | |
183 | |
184 OverlayMode m_overlayMode; | |
185 }; | |
186 | |
187 #endif | |
188 |