annotate base/Selection.cpp @ 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
children 73d85d19919f
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@8 68 Selection::operator<(const Selection &s) const
Chris@8 69 {
Chris@8 70 return (m_startFrame < s.m_startFrame);
Chris@8 71 }
Chris@8 72
Chris@8 73 bool
Chris@8 74 Selection::operator==(const Selection &s) const
Chris@8 75 {
Chris@8 76 return (m_startFrame == s.m_startFrame &&
Chris@8 77 m_endFrame == s.m_endFrame);
Chris@8 78 }
Chris@8 79