annotate base/ViewManager.h @ 8:214054a0d8b8

* Hook up tool selection buttons to switch the cursor mode * Implement simple and multi-selection, snapping to the resolution of the current layer. You can't actually do anything with a selection yet
author Chris Cannam
date Mon, 23 Jan 2006 17:02:57 +0000
parents d86891498eef
children 73d85d19919f
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 #include <set>
Chris@8 18
Chris@8 19 #include "Selection.h"
Chris@0 20
Chris@0 21 class AudioPlaySource;
Chris@0 22 class PlayParameters;
Chris@0 23 class Model;
Chris@0 24
Chris@0 25 /**
Chris@0 26 * The ViewManager manages properties that may need to be synchronised
Chris@0 27 * between separate Views. For example, it handles signals associated
Chris@0 28 * with changes to the global pan and zoom. It also handles playback
Chris@0 29 * properties and play synchronisation.
Chris@0 30 *
Chris@0 31 * Views should be implemented in such a way as to work
Chris@0 32 * correctly whether they are supplied with a ViewManager or not.
Chris@0 33 */
Chris@0 34
Chris@0 35 class ViewManager : public QObject
Chris@0 36 {
Chris@0 37 Q_OBJECT
Chris@0 38
Chris@0 39 public:
Chris@0 40 ViewManager();
Chris@0 41
Chris@0 42 void setAudioPlaySource(AudioPlaySource *source);
Chris@0 43
Chris@0 44 //!!! No way to remove a model!
Chris@0 45 PlayParameters *getPlayParameters(const Model *model);
Chris@0 46 void clearPlayParameters();
Chris@0 47
Chris@8 48 bool isPlaying() const;
Chris@8 49
Chris@0 50 unsigned long getGlobalCentreFrame() const;
Chris@0 51 unsigned long getGlobalZoom() const;
Chris@0 52
Chris@8 53 typedef std::set<Selection> SelectionList;
Chris@8 54
Chris@8 55 bool haveInProgressSelection() const;
Chris@8 56 const Selection &getInProgressSelection(bool &exclusive) const;
Chris@8 57 void setInProgressSelection(const Selection &selection, bool exclusive);
Chris@8 58 void clearInProgressSelection();
Chris@8 59
Chris@8 60 const SelectionList &getSelections() const;
Chris@8 61 void setSelection(const Selection &selection);
Chris@8 62 void addSelection(const Selection &selection);
Chris@8 63 void removeSelection(const Selection &selection);
Chris@8 64 void clearSelections();
Chris@8 65
Chris@8 66 enum ToolMode {
Chris@8 67 NavigateMode,
Chris@8 68 SelectMode,
Chris@8 69 EditMode,
Chris@8 70 DrawMode,
Chris@8 71 TextMode
Chris@8 72 };
Chris@8 73 ToolMode getToolMode() const { return m_toolMode; }
Chris@8 74 void setToolMode(ToolMode mode);
Chris@8 75
Chris@0 76 signals:
Chris@0 77 /** Emitted when a widget pans. The originator identifies the widget. */
Chris@0 78 void centreFrameChanged(void *originator, unsigned long frame, bool locked);
Chris@0 79
Chris@0 80 /** Emitted when a widget zooms. The originator identifies the widget. */
Chris@0 81 void zoomLevelChanged(void *originator, unsigned long zoom, bool locked);
Chris@0 82
Chris@0 83 /** Emitted when the playback frame changes. */
Chris@0 84 void playbackFrameChanged(unsigned long frame);
Chris@0 85
Chris@0 86 /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */
Chris@0 87 void outputLevelsChanged(float left, float right);
Chris@0 88
Chris@8 89 /** Emitted when the selection has changed. */
Chris@8 90 void selectionChanged();
Chris@8 91
Chris@8 92 /** Emitted when the tool mode has been changed. */
Chris@8 93 void toolModeChanged();
Chris@8 94
Chris@0 95 protected slots:
Chris@0 96 void checkPlayStatus();
Chris@0 97 void considerSeek(void *, unsigned long, bool);
Chris@0 98 void considerZoomChange(void *, unsigned long, bool);
Chris@0 99
Chris@0 100 protected:
Chris@0 101 AudioPlaySource *m_playSource;
Chris@0 102 unsigned long m_globalCentreFrame;
Chris@0 103 unsigned long m_globalZoom;
Chris@0 104
Chris@0 105 float m_lastLeft;
Chris@0 106 float m_lastRight;
Chris@0 107
Chris@8 108 SelectionList m_selections;
Chris@8 109 Selection m_inProgressSelection;
Chris@8 110 bool m_inProgressExclusive;
Chris@8 111
Chris@8 112 ToolMode m_toolMode;
Chris@8 113
Chris@0 114 std::map<const Model *, PlayParameters *> m_playParameters;
Chris@0 115 };
Chris@0 116
Chris@0 117 #endif
Chris@0 118