annotate base/ViewManager.h @ 121:7c3e1bc51080

* RFE 1497743: Adjust layer text file format to allow copy/paste into Excel Use \t as the default separator for text file export, and remove the leading space from RealTime::toString values
author Chris Cannam
date Thu, 08 Jun 2006 11:12:47 +0000
parents f277a171749d
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _VIEW_MANAGER_H_
Chris@0 17 #define _VIEW_MANAGER_H_
Chris@0 18
Chris@0 19 #include <QObject>
Chris@0 20 #include <QTimer>
Chris@0 21
Chris@0 22 #include <map>
Chris@8 23
Chris@8 24 #include "Selection.h"
Chris@45 25 #include "Command.h"
Chris@74 26 #include "Clipboard.h"
Chris@0 27
Chris@0 28 class AudioPlaySource;
Chris@0 29 class Model;
Chris@0 30
Chris@0 31 /**
Chris@0 32 * The ViewManager manages properties that may need to be synchronised
Chris@0 33 * between separate Views. For example, it handles signals associated
Chris@48 34 * with changes to the global pan and zoom, and it handles selections.
Chris@0 35 *
Chris@0 36 * Views should be implemented in such a way as to work
Chris@0 37 * correctly whether they are supplied with a ViewManager or not.
Chris@0 38 */
Chris@0 39
Chris@0 40 class ViewManager : public QObject
Chris@0 41 {
Chris@0 42 Q_OBJECT
Chris@0 43
Chris@0 44 public:
Chris@0 45 ViewManager();
Chris@75 46 virtual ~ViewManager();
Chris@0 47
Chris@0 48 void setAudioPlaySource(AudioPlaySource *source);
Chris@0 49
Chris@8 50 bool isPlaying() const;
Chris@8 51
Chris@0 52 unsigned long getGlobalCentreFrame() const;
Chris@0 53 unsigned long getGlobalZoom() const;
Chris@0 54
Chris@24 55 unsigned long getPlaybackFrame() const;
Chris@24 56 void setPlaybackFrame(unsigned long frame);
Chris@8 57
Chris@8 58 bool haveInProgressSelection() const;
Chris@8 59 const Selection &getInProgressSelection(bool &exclusive) const;
Chris@8 60 void setInProgressSelection(const Selection &selection, bool exclusive);
Chris@8 61 void clearInProgressSelection();
Chris@8 62
Chris@24 63 const MultiSelection &getSelection() const;
Chris@24 64
Chris@24 65 const MultiSelection::SelectionList &getSelections() const;
Chris@8 66 void setSelection(const Selection &selection);
Chris@8 67 void addSelection(const Selection &selection);
Chris@8 68 void removeSelection(const Selection &selection);
Chris@8 69 void clearSelections();
Chris@8 70
Chris@9 71 /**
Chris@9 72 * Return the selection that contains a given frame.
Chris@9 73 * If defaultToFollowing is true, and if the frame is not in a
Chris@9 74 * selected area, return the next selection after the given frame.
Chris@9 75 * Return the empty selection if no appropriate selection is found.
Chris@9 76 */
Chris@36 77 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const;
Chris@9 78
Chris@74 79 Clipboard &getClipboard() { return m_clipboard; }
Chris@74 80
Chris@8 81 enum ToolMode {
Chris@8 82 NavigateMode,
Chris@8 83 SelectMode,
Chris@8 84 EditMode,
Chris@32 85 DrawMode
Chris@8 86 };
Chris@8 87 ToolMode getToolMode() const { return m_toolMode; }
Chris@8 88 void setToolMode(ToolMode mode);
Chris@8 89
Chris@9 90 bool getPlayLoopMode() const { return m_playLoopMode; }
Chris@9 91 void setPlayLoopMode(bool on);
Chris@9 92
Chris@9 93 bool getPlaySelectionMode() const { return m_playSelectionMode; }
Chris@9 94 void setPlaySelectionMode(bool on);
Chris@9 95
Chris@40 96 size_t getPlaybackSampleRate() const;
Chris@42 97 size_t getMainModelSampleRate() const { return m_mainModelSampleRate; }
Chris@42 98 void setMainModelSampleRate(size_t sr) { m_mainModelSampleRate = sr; }
Chris@40 99
Chris@65 100 enum OverlayMode {
Chris@65 101 NoOverlays,
Chris@65 102 BasicOverlays,
Chris@65 103 AllOverlays
Chris@65 104 };
Chris@65 105 void setOverlayMode(OverlayMode mode);
Chris@65 106 OverlayMode getOverlayMode() const { return m_overlayMode; }
Chris@65 107
Chris@0 108 signals:
Chris@0 109 /** Emitted when a widget pans. The originator identifies the widget. */
Chris@0 110 void centreFrameChanged(void *originator, unsigned long frame, bool locked);
Chris@0 111
Chris@0 112 /** Emitted when a widget zooms. The originator identifies the widget. */
Chris@0 113 void zoomLevelChanged(void *originator, unsigned long zoom, bool locked);
Chris@0 114
Chris@0 115 /** Emitted when the playback frame changes. */
Chris@0 116 void playbackFrameChanged(unsigned long frame);
Chris@0 117
Chris@0 118 /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */
Chris@0 119 void outputLevelsChanged(float left, float right);
Chris@0 120
Chris@8 121 /** Emitted when the selection has changed. */
Chris@8 122 void selectionChanged();
Chris@8 123
Chris@9 124 /** Emitted when the in-progress (rubberbanding) selection has changed. */
Chris@9 125 void inProgressSelectionChanged();
Chris@9 126
Chris@8 127 /** Emitted when the tool mode has been changed. */
Chris@8 128 void toolModeChanged();
Chris@8 129
Chris@9 130 /** Emitted when the play loop mode has been changed. */
Chris@9 131 void playLoopModeChanged();
Chris@9 132
Chris@9 133 /** Emitted when the play selection mode has been changed. */
Chris@9 134 void playSelectionModeChanged();
Chris@9 135
Chris@65 136 /** Emitted when the overlay mode has been changed. */
Chris@65 137 void overlayModeChanged();
Chris@65 138
Chris@0 139 protected slots:
Chris@0 140 void checkPlayStatus();
Chris@10 141 void playStatusChanged(bool playing);
Chris@0 142 void considerSeek(void *, unsigned long, bool);
Chris@0 143 void considerZoomChange(void *, unsigned long, bool);
Chris@0 144
Chris@0 145 protected:
Chris@0 146 AudioPlaySource *m_playSource;
Chris@0 147 unsigned long m_globalCentreFrame;
Chris@0 148 unsigned long m_globalZoom;
Chris@24 149 mutable unsigned long m_playbackFrame;
Chris@42 150 size_t m_mainModelSampleRate;
Chris@0 151
Chris@0 152 float m_lastLeft;
Chris@0 153 float m_lastRight;
Chris@0 154
Chris@24 155 MultiSelection m_selections;
Chris@8 156 Selection m_inProgressSelection;
Chris@8 157 bool m_inProgressExclusive;
Chris@8 158
Chris@74 159 Clipboard m_clipboard;
Chris@74 160
Chris@8 161 ToolMode m_toolMode;
Chris@8 162
Chris@9 163 bool m_playLoopMode;
Chris@9 164 bool m_playSelectionMode;
Chris@45 165
Chris@45 166 void setSelections(const MultiSelection &ms);
Chris@45 167 void signalSelectionChange();
Chris@45 168
Chris@45 169 class SetSelectionCommand : public Command
Chris@45 170 {
Chris@45 171 public:
Chris@45 172 SetSelectionCommand(ViewManager *vm, const MultiSelection &ms);
Chris@45 173 virtual ~SetSelectionCommand();
Chris@45 174 virtual void execute();
Chris@45 175 virtual void unexecute();
Chris@45 176 virtual QString getName() const;
Chris@45 177
Chris@45 178 protected:
Chris@45 179 ViewManager *m_vm;
Chris@45 180 MultiSelection m_oldSelection;
Chris@45 181 MultiSelection m_newSelection;
Chris@45 182 };
Chris@65 183
Chris@65 184 OverlayMode m_overlayMode;
Chris@0 185 };
Chris@0 186
Chris@0 187 #endif
Chris@0 188