Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@2: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #ifndef _VIEW_MANAGER_H_ Chris@0: #define _VIEW_MANAGER_H_ Chris@0: Chris@0: #include Chris@0: #include Chris@0: Chris@0: #include Chris@8: #include Chris@8: Chris@8: #include "Selection.h" Chris@0: Chris@0: class AudioPlaySource; Chris@0: class PlayParameters; Chris@0: class Model; Chris@0: Chris@0: /** Chris@0: * The ViewManager manages properties that may need to be synchronised Chris@0: * between separate Views. For example, it handles signals associated Chris@0: * with changes to the global pan and zoom. It also handles playback Chris@0: * properties and play synchronisation. Chris@0: * Chris@0: * Views should be implemented in such a way as to work Chris@0: * correctly whether they are supplied with a ViewManager or not. Chris@0: */ Chris@0: Chris@0: class ViewManager : public QObject Chris@0: { Chris@0: Q_OBJECT Chris@0: Chris@0: public: Chris@0: ViewManager(); Chris@0: Chris@0: void setAudioPlaySource(AudioPlaySource *source); Chris@0: Chris@0: //!!! No way to remove a model! Chris@0: PlayParameters *getPlayParameters(const Model *model); Chris@0: void clearPlayParameters(); Chris@0: Chris@8: bool isPlaying() const; Chris@8: Chris@0: unsigned long getGlobalCentreFrame() const; Chris@0: unsigned long getGlobalZoom() const; Chris@0: Chris@8: typedef std::set SelectionList; Chris@8: Chris@8: bool haveInProgressSelection() const; Chris@8: const Selection &getInProgressSelection(bool &exclusive) const; Chris@8: void setInProgressSelection(const Selection &selection, bool exclusive); Chris@8: void clearInProgressSelection(); Chris@8: Chris@8: const SelectionList &getSelections() const; Chris@8: void setSelection(const Selection &selection); Chris@8: void addSelection(const Selection &selection); Chris@8: void removeSelection(const Selection &selection); Chris@8: void clearSelections(); Chris@8: Chris@9: /** Chris@9: * Return the selection that contains a given frame. Chris@9: * If defaultToFollowing is true, and if the frame is not in a Chris@9: * selected area, return the next selection after the given frame. Chris@9: * Return the empty selection if no appropriate selection is found. Chris@9: */ Chris@9: Selection getContainingSelection(size_t frame, bool defaultToFollowing); Chris@9: Chris@8: enum ToolMode { Chris@8: NavigateMode, Chris@8: SelectMode, Chris@8: EditMode, Chris@8: DrawMode, Chris@8: TextMode Chris@8: }; Chris@8: ToolMode getToolMode() const { return m_toolMode; } Chris@8: void setToolMode(ToolMode mode); Chris@8: Chris@9: bool getPlayLoopMode() const { return m_playLoopMode; } Chris@9: void setPlayLoopMode(bool on); Chris@9: Chris@9: bool getPlaySelectionMode() const { return m_playSelectionMode; } Chris@9: void setPlaySelectionMode(bool on); Chris@9: Chris@0: signals: Chris@0: /** Emitted when a widget pans. The originator identifies the widget. */ Chris@0: void centreFrameChanged(void *originator, unsigned long frame, bool locked); Chris@0: Chris@0: /** Emitted when a widget zooms. The originator identifies the widget. */ Chris@0: void zoomLevelChanged(void *originator, unsigned long zoom, bool locked); Chris@0: Chris@0: /** Emitted when the playback frame changes. */ Chris@0: void playbackFrameChanged(unsigned long frame); Chris@0: Chris@0: /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */ Chris@0: void outputLevelsChanged(float left, float right); Chris@0: Chris@8: /** Emitted when the selection has changed. */ Chris@8: void selectionChanged(); Chris@8: Chris@9: /** Emitted when the in-progress (rubberbanding) selection has changed. */ Chris@9: void inProgressSelectionChanged(); Chris@9: Chris@8: /** Emitted when the tool mode has been changed. */ Chris@8: void toolModeChanged(); Chris@8: Chris@9: /** Emitted when the play loop mode has been changed. */ Chris@9: void playLoopModeChanged(); Chris@9: Chris@9: /** Emitted when the play selection mode has been changed. */ Chris@9: void playSelectionModeChanged(); Chris@9: Chris@0: protected slots: Chris@0: void checkPlayStatus(); Chris@10: void playStatusChanged(bool playing); Chris@0: void considerSeek(void *, unsigned long, bool); Chris@0: void considerZoomChange(void *, unsigned long, bool); Chris@0: Chris@0: protected: Chris@0: AudioPlaySource *m_playSource; Chris@0: unsigned long m_globalCentreFrame; Chris@0: unsigned long m_globalZoom; Chris@0: Chris@0: float m_lastLeft; Chris@0: float m_lastRight; Chris@0: Chris@8: SelectionList m_selections; Chris@8: Selection m_inProgressSelection; Chris@8: bool m_inProgressExclusive; Chris@8: Chris@8: ToolMode m_toolMode; Chris@8: Chris@9: bool m_playLoopMode; Chris@9: bool m_playSelectionMode; Chris@9: Chris@0: std::map m_playParameters; Chris@0: }; Chris@0: Chris@0: #endif Chris@0: