comparison widgets/Pane.cpp @ 99:453f7da3534e

* Fix serious failure to reload "imported" (i.e. all non-derived non-main) models from .sv file * Give a short playback duration to notes with formal duration of 0 or 1 * Show crosshairs on spectrogram even when there is another layer on top (if it isn't opaque) * Always paste to the same time in the layer as the cut/copy was from, rather than to the playback pointer -- less flexible, but more predictable and less annoying. We probably need a way to get the old behaviour if pasting from somewhere else in the future (e.g. from a text file), but we can't do that yet anyway * Use a compound operation for dragging and resizing selections, so as to ensure a single undo operation works * Use a note model as the target for feature extraction plugins that output variable samplerate data with more than one value per feature * Avoid possible crashes in cut/paste if a layer proves to have no model
author Chris Cannam
date Thu, 11 May 2006 11:35:46 +0000
parents 803830f186ef
children 0f36cdf407a6
comparison
equal deleted inserted replaced
98:2be85befe873 99:453f7da3534e
18 #include "base/Model.h" 18 #include "base/Model.h"
19 #include "base/ZoomConstraint.h" 19 #include "base/ZoomConstraint.h"
20 #include "base/RealTime.h" 20 #include "base/RealTime.h"
21 #include "base/Profiler.h" 21 #include "base/Profiler.h"
22 #include "base/ViewManager.h" 22 #include "base/ViewManager.h"
23 #include "base/CommandHistory.h"
23 #include "layer/WaveformLayer.h" 24 #include "layer/WaveformLayer.h"
24 25
25 #include <QPaintEvent> 26 #include <QPaintEvent>
26 #include <QPainter> 27 #include <QPainter>
27 #include <iostream> 28 #include <iostream>
142 int verticalScaleWidth = 0; 143 int verticalScaleWidth = 0;
143 144
144 int fontHeight = paint.fontMetrics().height(); 145 int fontHeight = paint.fontMetrics().height();
145 int fontAscent = paint.fontMetrics().ascent(); 146 int fontAscent = paint.fontMetrics().ascent();
146 147
148 if (m_manager &&
149 !m_manager->isPlaying() &&
150 m_manager->getToolMode() == ViewManager::SelectMode) {
151
152 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
153 --vi;
154
155 std::vector<QRect> crosshairExtents;
156
157 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
158 crosshairExtents)) {
159 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
160 break;
161 } else if ((*vi)->isLayerOpaque()) {
162 break;
163 }
164 }
165 }
166
147 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { 167 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
148 --vi; 168 --vi;
149 169
150 if (dynamic_cast<WaveformLayer *>(*vi)) { 170 if (dynamic_cast<WaveformLayer *>(*vi)) {
151 waveformModel = (*vi)->getModel(); 171 waveformModel = (*vi)->getModel();
152 }
153
154 if (m_manager &&
155 !m_manager->isPlaying() &&
156 m_manager->getToolMode() == ViewManager::SelectMode) {
157
158 std::vector<QRect> crosshairExtents;
159
160 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
161 crosshairExtents)) {
162 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
163 }
164 } 172 }
165 173
166 if (!m_manager || 174 if (!m_manager ||
167 m_manager->getOverlayMode() == ViewManager::NoOverlays) { 175 m_manager->getOverlayMode() == ViewManager::NoOverlays) {
168 break; 176 break;
970 978
971 Selection newSelection(f0, f1); 979 Selection newSelection(f0, f1);
972 980
973 if (m_editingSelectionEdge == 0) { 981 if (m_editingSelectionEdge == 0) {
974 982
983 CommandHistory::getInstance()->startCompoundOperation
984 (tr("Drag Selection"), true);
985
975 layer->moveSelection(m_editingSelection, f0); 986 layer->moveSelection(m_editingSelection, f0);
976 987
977 } else { 988 } else {
978 989
990 CommandHistory::getInstance()->startCompoundOperation
991 (tr("Resize Selection"), true);
992
979 if (m_editingSelectionEdge < 0) { 993 if (m_editingSelectionEdge < 0) {
980 f1 = m_editingSelection.getEndFrame(); 994 f1 = m_editingSelection.getEndFrame();
981 } else { 995 } else {
982 f0 = m_editingSelection.getStartFrame(); 996 f0 = m_editingSelection.getStartFrame();
983 } 997 }
986 layer->resizeSelection(m_editingSelection, newSelection); 1000 layer->resizeSelection(m_editingSelection, newSelection);
987 } 1001 }
988 1002
989 m_manager->removeSelection(m_editingSelection); 1003 m_manager->removeSelection(m_editingSelection);
990 m_manager->addSelection(newSelection); 1004 m_manager->addSelection(newSelection);
1005
1006 CommandHistory::getInstance()->endCompoundOperation();
991 1007
992 m_editingSelection = Selection(); 1008 m_editingSelection = Selection();
993 return true; 1009 return true;
994 } 1010 }
995 1011