comparison 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
comparison
equal deleted inserted replaced
7:49a95b174050 8:214054a0d8b8
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 A waveform viewer and audio annotation editor.
5 Chris Cannam, Queen Mary University of London, 2005-2006
6
7 This is experimental software. Not for distribution.
8 */
9
10 #include "Selection.h"
11
12 Selection::Selection() :
13 m_startFrame(0),
14 m_endFrame(0)
15 {
16 }
17
18 Selection::Selection(size_t startFrame, size_t endFrame) :
19 m_startFrame(startFrame),
20 m_endFrame(endFrame)
21 {
22 if (m_startFrame > m_endFrame) {
23 size_t tmp = m_endFrame;
24 m_endFrame = m_startFrame;
25 m_startFrame = tmp;
26 }
27 }
28
29 Selection::Selection(const Selection &s) :
30 m_startFrame(s.m_startFrame),
31 m_endFrame(s.m_endFrame)
32 {
33 }
34
35 Selection &
36 Selection::operator=(const Selection &s)
37 {
38 if (this != &s) {
39 m_startFrame = s.m_startFrame;
40 m_endFrame = s.m_endFrame;
41 }
42 return *this;
43 }
44
45 Selection::~Selection()
46 {
47 }
48
49 bool
50 Selection::isEmpty() const
51 {
52 return m_startFrame == m_endFrame;
53 }
54
55 size_t
56 Selection::getStartFrame() const
57 {
58 return m_startFrame;
59 }
60
61 size_t
62 Selection::getEndFrame() const
63 {
64 return m_endFrame;
65 }
66
67 bool
68 Selection::operator<(const Selection &s) const
69 {
70 return (m_startFrame < s.m_startFrame);
71 }
72
73 bool
74 Selection::operator==(const Selection &s) const
75 {
76 return (m_startFrame == s.m_startFrame &&
77 m_endFrame == s.m_endFrame);
78 }
79