annotate base/ViewManager.h @ 38:a6b2128eed56

* Continue MainWindow refactoring by making MainWindow actually use the new Document class -- still somewhat unstable * Fix crash in spectrogram layer * Rename tonalestimator to TonalEstimator and add to project file
author Chris Cannam
date Fri, 03 Mar 2006 16:56:20 +0000
parents 935a2419a77c
children b2d1a61ab916
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 #ifndef _VIEW_MANAGER_H_
Chris@0 11 #define _VIEW_MANAGER_H_
Chris@0 12
Chris@0 13 #include <QObject>
Chris@0 14 #include <QTimer>
Chris@0 15
Chris@0 16 #include <map>
Chris@8 17
Chris@8 18 #include "Selection.h"
Chris@0 19
Chris@0 20 class AudioPlaySource;
Chris@0 21 class Model;
Chris@0 22
Chris@0 23 /**
Chris@0 24 * The ViewManager manages properties that may need to be synchronised
Chris@0 25 * between separate Views. For example, it handles signals associated
Chris@0 26 * with changes to the global pan and zoom. It also handles playback
Chris@0 27 * properties and play synchronisation.
Chris@0 28 *
Chris@0 29 * Views should be implemented in such a way as to work
Chris@0 30 * correctly whether they are supplied with a ViewManager or not.
Chris@0 31 */
Chris@0 32
Chris@0 33 class ViewManager : public QObject
Chris@0 34 {
Chris@0 35 Q_OBJECT
Chris@0 36
Chris@0 37 public:
Chris@0 38 ViewManager();
Chris@0 39
Chris@0 40 void setAudioPlaySource(AudioPlaySource *source);
Chris@0 41
Chris@8 42 bool isPlaying() const;
Chris@8 43
Chris@0 44 unsigned long getGlobalCentreFrame() const;
Chris@0 45 unsigned long getGlobalZoom() const;
Chris@0 46
Chris@24 47 unsigned long getPlaybackFrame() const;
Chris@24 48 void setPlaybackFrame(unsigned long frame);
Chris@8 49
Chris@8 50 bool haveInProgressSelection() const;
Chris@8 51 const Selection &getInProgressSelection(bool &exclusive) const;
Chris@8 52 void setInProgressSelection(const Selection &selection, bool exclusive);
Chris@8 53 void clearInProgressSelection();
Chris@8 54
Chris@24 55 const MultiSelection &getSelection() const;
Chris@24 56
Chris@24 57 const MultiSelection::SelectionList &getSelections() const;
Chris@8 58 void setSelection(const Selection &selection);
Chris@8 59 void addSelection(const Selection &selection);
Chris@8 60 void removeSelection(const Selection &selection);
Chris@8 61 void clearSelections();
Chris@8 62
Chris@9 63 /**
Chris@9 64 * Return the selection that contains a given frame.
Chris@9 65 * If defaultToFollowing is true, and if the frame is not in a
Chris@9 66 * selected area, return the next selection after the given frame.
Chris@9 67 * Return the empty selection if no appropriate selection is found.
Chris@9 68 */
Chris@36 69 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const;
Chris@9 70
Chris@8 71 enum ToolMode {
Chris@8 72 NavigateMode,
Chris@8 73 SelectMode,
Chris@8 74 EditMode,
Chris@32 75 DrawMode
Chris@8 76 };
Chris@8 77 ToolMode getToolMode() const { return m_toolMode; }
Chris@8 78 void setToolMode(ToolMode mode);
Chris@8 79
Chris@9 80 bool getPlayLoopMode() const { return m_playLoopMode; }
Chris@9 81 void setPlayLoopMode(bool on);
Chris@9 82
Chris@9 83 bool getPlaySelectionMode() const { return m_playSelectionMode; }
Chris@9 84 void setPlaySelectionMode(bool on);
Chris@9 85
Chris@0 86 signals:
Chris@0 87 /** Emitted when a widget pans. The originator identifies the widget. */
Chris@0 88 void centreFrameChanged(void *originator, unsigned long frame, bool locked);
Chris@0 89
Chris@0 90 /** Emitted when a widget zooms. The originator identifies the widget. */
Chris@0 91 void zoomLevelChanged(void *originator, unsigned long zoom, bool locked);
Chris@0 92
Chris@0 93 /** Emitted when the playback frame changes. */
Chris@0 94 void playbackFrameChanged(unsigned long frame);
Chris@0 95
Chris@0 96 /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */
Chris@0 97 void outputLevelsChanged(float left, float right);
Chris@0 98
Chris@8 99 /** Emitted when the selection has changed. */
Chris@8 100 void selectionChanged();
Chris@8 101
Chris@9 102 /** Emitted when the in-progress (rubberbanding) selection has changed. */
Chris@9 103 void inProgressSelectionChanged();
Chris@9 104
Chris@8 105 /** Emitted when the tool mode has been changed. */
Chris@8 106 void toolModeChanged();
Chris@8 107
Chris@9 108 /** Emitted when the play loop mode has been changed. */
Chris@9 109 void playLoopModeChanged();
Chris@9 110
Chris@9 111 /** Emitted when the play selection mode has been changed. */
Chris@9 112 void playSelectionModeChanged();
Chris@9 113
Chris@0 114 protected slots:
Chris@0 115 void checkPlayStatus();
Chris@10 116 void playStatusChanged(bool playing);
Chris@0 117 void considerSeek(void *, unsigned long, bool);
Chris@0 118 void considerZoomChange(void *, unsigned long, bool);
Chris@0 119
Chris@0 120 protected:
Chris@0 121 AudioPlaySource *m_playSource;
Chris@0 122 unsigned long m_globalCentreFrame;
Chris@0 123 unsigned long m_globalZoom;
Chris@24 124 mutable unsigned long m_playbackFrame;
Chris@0 125
Chris@0 126 float m_lastLeft;
Chris@0 127 float m_lastRight;
Chris@0 128
Chris@24 129 MultiSelection m_selections;
Chris@8 130 Selection m_inProgressSelection;
Chris@8 131 bool m_inProgressExclusive;
Chris@8 132
Chris@8 133 ToolMode m_toolMode;
Chris@8 134
Chris@9 135 bool m_playLoopMode;
Chris@9 136 bool m_playSelectionMode;
Chris@0 137 };
Chris@0 138
Chris@0 139 #endif
Chris@0 140