annotate base/Selection.cpp @ 16:cc98d496d52b

* Add command history class, and basic undo/redo menus. No actual commands to undo/redo yet. Selecting the placeholders sometimes seems to cause a crash, so this looks a little uncertain so far. * Add Rename Layer * Remove models from playback when their layers are removed (and ref counts hit zero) * Don't hang around waiting so much when there's work to be done in the audio buffer fill thread * Put more sensible names on layers generated from transforms * Add basic editing to time-value layer like existing editing in time-instants layer, and make both of them snap to the appropriate resolution during drag
author Chris Cannam
date Mon, 30 Jan 2006 17:51:56 +0000
parents 73d85d19919f
children bb9291d84810
rev   line source
Chris@8 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@8 2
Chris@8 3 /*
Chris@8 4 A waveform viewer and audio annotation editor.
Chris@8 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@8 6
Chris@8 7 This is experimental software. Not for distribution.
Chris@8 8 */
Chris@8 9
Chris@8 10 #include "Selection.h"
Chris@8 11
Chris@8 12 Selection::Selection() :
Chris@8 13 m_startFrame(0),
Chris@8 14 m_endFrame(0)
Chris@8 15 {
Chris@8 16 }
Chris@8 17
Chris@8 18 Selection::Selection(size_t startFrame, size_t endFrame) :
Chris@8 19 m_startFrame(startFrame),
Chris@8 20 m_endFrame(endFrame)
Chris@8 21 {
Chris@8 22 if (m_startFrame > m_endFrame) {
Chris@8 23 size_t tmp = m_endFrame;
Chris@8 24 m_endFrame = m_startFrame;
Chris@8 25 m_startFrame = tmp;
Chris@8 26 }
Chris@8 27 }
Chris@8 28
Chris@8 29 Selection::Selection(const Selection &s) :
Chris@8 30 m_startFrame(s.m_startFrame),
Chris@8 31 m_endFrame(s.m_endFrame)
Chris@8 32 {
Chris@8 33 }
Chris@8 34
Chris@8 35 Selection &
Chris@8 36 Selection::operator=(const Selection &s)
Chris@8 37 {
Chris@8 38 if (this != &s) {
Chris@8 39 m_startFrame = s.m_startFrame;
Chris@8 40 m_endFrame = s.m_endFrame;
Chris@8 41 }
Chris@8 42 return *this;
Chris@8 43 }
Chris@8 44
Chris@8 45 Selection::~Selection()
Chris@8 46 {
Chris@8 47 }
Chris@8 48
Chris@8 49 bool
Chris@8 50 Selection::isEmpty() const
Chris@8 51 {
Chris@8 52 return m_startFrame == m_endFrame;
Chris@8 53 }
Chris@8 54
Chris@8 55 size_t
Chris@8 56 Selection::getStartFrame() const
Chris@8 57 {
Chris@8 58 return m_startFrame;
Chris@8 59 }
Chris@8 60
Chris@8 61 size_t
Chris@8 62 Selection::getEndFrame() const
Chris@8 63 {
Chris@8 64 return m_endFrame;
Chris@8 65 }
Chris@8 66
Chris@8 67 bool
Chris@9 68 Selection::contains(size_t frame) const
Chris@9 69 {
Chris@9 70 return (frame >= m_startFrame) && (frame < m_endFrame);
Chris@9 71 }
Chris@9 72
Chris@9 73 bool
Chris@8 74 Selection::operator<(const Selection &s) const
Chris@8 75 {
Chris@9 76 if (isEmpty()) {
Chris@9 77 if (s.isEmpty()) return false;
Chris@9 78 else return true;
Chris@9 79 } else {
Chris@9 80 if (s.isEmpty()) return false;
Chris@9 81 else return (m_startFrame < s.m_startFrame);
Chris@9 82 }
Chris@8 83 }
Chris@8 84
Chris@8 85 bool
Chris@8 86 Selection::operator==(const Selection &s) const
Chris@8 87 {
Chris@9 88 if (isEmpty()) return s.isEmpty();
Chris@9 89
Chris@8 90 return (m_startFrame == s.m_startFrame &&
Chris@8 91 m_endFrame == s.m_endFrame);
Chris@8 92 }
Chris@8 93