Mercurial > hg > svcore
comparison base/ViewManager.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 | d86891498eef |
children | 73d85d19919f |
comparison
equal
deleted
inserted
replaced
7:49a95b174050 | 8:214054a0d8b8 |
---|---|
19 ViewManager::ViewManager() : | 19 ViewManager::ViewManager() : |
20 m_playSource(0), | 20 m_playSource(0), |
21 m_globalCentreFrame(0), | 21 m_globalCentreFrame(0), |
22 m_globalZoom(1024), | 22 m_globalZoom(1024), |
23 m_lastLeft(0), | 23 m_lastLeft(0), |
24 m_lastRight(0) | 24 m_lastRight(0), |
25 m_inProgressExclusive(true), | |
26 m_toolMode(NavigateMode) | |
25 { | 27 { |
26 connect(this, | 28 connect(this, |
27 SIGNAL(centreFrameChanged(void *, unsigned long, bool)), | 29 SIGNAL(centreFrameChanged(void *, unsigned long, bool)), |
28 SLOT(considerSeek(void *, unsigned long, bool))); | 30 SLOT(considerSeek(void *, unsigned long, bool))); |
29 | 31 |
46 { | 48 { |
47 #ifdef DEBUG_VIEW_MANAGER | 49 #ifdef DEBUG_VIEW_MANAGER |
48 std::cout << "ViewManager::getGlobalZoom: returning " << m_globalZoom << std::endl; | 50 std::cout << "ViewManager::getGlobalZoom: returning " << m_globalZoom << std::endl; |
49 #endif | 51 #endif |
50 return m_globalZoom; | 52 return m_globalZoom; |
53 } | |
54 | |
55 bool | |
56 ViewManager::haveInProgressSelection() const | |
57 { | |
58 return !m_inProgressSelection.isEmpty(); | |
59 } | |
60 | |
61 const Selection & | |
62 ViewManager::getInProgressSelection(bool &exclusive) const | |
63 { | |
64 exclusive = m_inProgressExclusive; | |
65 return m_inProgressSelection; | |
66 } | |
67 | |
68 void | |
69 ViewManager::setInProgressSelection(const Selection &selection, bool exclusive) | |
70 { | |
71 m_inProgressExclusive = exclusive; | |
72 m_inProgressSelection = selection; | |
73 if (exclusive) clearSelections(); | |
74 emit selectionChanged(); | |
75 } | |
76 | |
77 void | |
78 ViewManager::clearInProgressSelection() | |
79 { | |
80 m_inProgressSelection = Selection(); | |
81 emit selectionChanged(); | |
82 } | |
83 | |
84 const ViewManager::SelectionList & | |
85 ViewManager::getSelections() const | |
86 { | |
87 return m_selections; | |
88 } | |
89 | |
90 void | |
91 ViewManager::setSelection(const Selection &selection) | |
92 { | |
93 clearSelections(); | |
94 addSelection(selection); | |
95 } | |
96 | |
97 void | |
98 ViewManager::addSelection(const Selection &selection) | |
99 { | |
100 m_selections.insert(selection); | |
101 | |
102 // Cope with a sitation where the new selection overlaps one or | |
103 // more existing ones. This is a terribly inefficient way to do | |
104 // this, but that probably isn't significant in real life. | |
105 | |
106 for (SelectionList::iterator i = m_selections.begin(); | |
107 i != m_selections.end(); ) { | |
108 | |
109 SelectionList::iterator j = i; | |
110 if (++j == m_selections.end()) break; | |
111 | |
112 if (i->getEndFrame() >= j->getStartFrame()) { | |
113 Selection merged(i->getStartFrame(), | |
114 std::max(i->getEndFrame(), j->getEndFrame())); | |
115 m_selections.erase(i); | |
116 m_selections.erase(j); | |
117 m_selections.insert(merged); | |
118 i = m_selections.begin(); | |
119 } else { | |
120 ++i; | |
121 } | |
122 } | |
123 | |
124 emit selectionChanged(); | |
125 } | |
126 | |
127 void | |
128 ViewManager::removeSelection(const Selection &selection) | |
129 { | |
130 //!!! Likewise this needs to cope correctly with the situation | |
131 //where selection is not one of the original selection set but | |
132 //simply overlaps one of them (cutting down the original selection | |
133 //appropriately) | |
134 | |
135 m_selections.erase(selection); | |
136 | |
137 emit selectionChanged(); | |
138 } | |
139 | |
140 void | |
141 ViewManager::clearSelections() | |
142 { | |
143 m_selections.clear(); | |
144 | |
145 emit selectionChanged(); | |
146 } | |
147 | |
148 void | |
149 ViewManager::setToolMode(ToolMode mode) | |
150 { | |
151 m_toolMode = mode; | |
152 | |
153 emit toolModeChanged(); | |
51 } | 154 } |
52 | 155 |
53 void | 156 void |
54 ViewManager::setAudioPlaySource(AudioPlaySource *source) | 157 ViewManager::setAudioPlaySource(AudioPlaySource *source) |
55 { | 158 { |
117 // std::cout << "ViewManager::checkPlayStatus: Not playing" << std::endl; | 220 // std::cout << "ViewManager::checkPlayStatus: Not playing" << std::endl; |
118 #endif | 221 #endif |
119 } | 222 } |
120 } | 223 } |
121 | 224 |
225 bool | |
226 ViewManager::isPlaying() const | |
227 { | |
228 return m_playSource && m_playSource->isPlaying(); | |
229 } | |
230 | |
122 void | 231 void |
123 ViewManager::considerSeek(void *p, unsigned long f, bool locked) | 232 ViewManager::considerSeek(void *p, unsigned long f, bool locked) |
124 { | 233 { |
125 if (locked) { | 234 if (locked) { |
126 m_globalCentreFrame = f; | 235 m_globalCentreFrame = f; |