comparison framework/MainWindowBase.cpp @ 450:d9d132c0e240 alignment_view

Merge from default branch
author Chris Cannam
date Mon, 20 Apr 2015 09:21:32 +0100
parents a9141963b580 ba789baf642b
children 74d575708e06
comparison
equal deleted inserted replaced
430:adfb2948fabf 450:d9d132c0e240
52 #include "audioio/AudioTargetFactory.h" 52 #include "audioio/AudioTargetFactory.h"
53 #include "audioio/PlaySpeedRangeMapper.h" 53 #include "audioio/PlaySpeedRangeMapper.h"
54 #include "data/fileio/DataFileReaderFactory.h" 54 #include "data/fileio/DataFileReaderFactory.h"
55 #include "data/fileio/PlaylistFileReader.h" 55 #include "data/fileio/PlaylistFileReader.h"
56 #include "data/fileio/WavFileWriter.h" 56 #include "data/fileio/WavFileWriter.h"
57 #include "data/fileio/CSVFileWriter.h"
58 #include "data/fileio/MIDIFileWriter.h" 57 #include "data/fileio/MIDIFileWriter.h"
59 #include "data/fileio/BZipFileDevice.h" 58 #include "data/fileio/BZipFileDevice.h"
60 #include "data/fileio/FileSource.h" 59 #include "data/fileio/FileSource.h"
61 #include "data/fileio/AudioFileReaderFactory.h" 60 #include "data/fileio/AudioFileReaderFactory.h"
62 #include "rdf/RDFImporter.h" 61 #include "rdf/RDFImporter.h"
88 #include <QTreeView> 87 #include <QTreeView>
89 #include <QFile> 88 #include <QFile>
90 #include <QFileInfo> 89 #include <QFileInfo>
91 #include <QDir> 90 #include <QDir>
92 #include <QTextStream> 91 #include <QTextStream>
92 #include <QTextCodec>
93 #include <QProcess> 93 #include <QProcess>
94 #include <QShortcut> 94 #include <QShortcut>
95 #include <QSettings> 95 #include <QSettings>
96 #include <QDateTime> 96 #include <QDateTime>
97 #include <QProcess> 97 #include <QProcess>
102 #include <QSignalMapper> 102 #include <QSignalMapper>
103 103
104 #include <iostream> 104 #include <iostream>
105 #include <cstdio> 105 #include <cstdio>
106 #include <errno.h> 106 #include <errno.h>
107
108
109
110 107
111 using std::vector; 108 using std::vector;
112 using std::map; 109 using std::map;
113 using std::set; 110 using std::set;
114 111
159 m_iconsVisibleInMenus(true), 156 m_iconsVisibleInMenus(true),
160 m_menuShortcutMapper(0) 157 m_menuShortcutMapper(0)
161 { 158 {
162 Profiler profiler("MainWindowBase::MainWindowBase"); 159 Profiler profiler("MainWindowBase::MainWindowBase");
163 160
161 qRegisterMetaType<sv_frame_t>("sv_frame_t");
162 qRegisterMetaType<sv_samplerate_t>("sv_samplerate_t");
163
164 #ifdef Q_WS_X11 164 #ifdef Q_WS_X11
165 XSetErrorHandler(handle_x11_error); 165 XSetErrorHandler(handle_x11_error);
166 #endif 166 #endif
167 167
168 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()), 168 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
176 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), 176 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()),
177 this, SLOT(inProgressSelectionChanged())); 177 this, SLOT(inProgressSelectionChanged()));
178 178
179 // set a sensible default font size for views -- cannot do this 179 // set a sensible default font size for views -- cannot do this
180 // in Preferences, which is in base and not supposed to use QtGui 180 // in Preferences, which is in base and not supposed to use QtGui
181 int viewFontSize = QApplication::font().pointSize() * 0.9; 181 int viewFontSize = int(QApplication::font().pointSize() * 0.9);
182 QSettings settings; 182 QSettings settings;
183 settings.beginGroup("Preferences"); 183 settings.beginGroup("Preferences");
184 viewFontSize = settings.value("view-font-size", viewFontSize).toInt(); 184 viewFontSize = settings.value("view-font-size", viewFontSize).toInt();
185 settings.setValue("view-font-size", viewFontSize); 185 settings.setValue("view-font-size", viewFontSize);
186 settings.endGroup(); 186 settings.endGroup();
216 this, SLOT(paneDeleteButtonClicked(Pane *))); 216 this, SLOT(paneDeleteButtonClicked(Pane *)));
217 217
218 m_playSource = new AudioCallbackPlaySource(m_viewManager, 218 m_playSource = new AudioCallbackPlaySource(m_viewManager,
219 QApplication::applicationName()); 219 QApplication::applicationName());
220 220
221 connect(m_playSource, SIGNAL(sampleRateMismatch(int, int, bool)), 221 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)),
222 this, SLOT(sampleRateMismatch(int, int, bool))); 222 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)));
223 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), 223 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()),
224 this, SLOT(audioOverloadPluginDisabled())); 224 this, SLOT(audioOverloadPluginDisabled()));
225 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), 225 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()),
226 this, SLOT(audioTimeStretchMultiChannelDisabled())); 226 this, SLOT(audioTimeStretchMultiChannelDisabled()));
227 227
228 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)), 228 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)),
229 this, SLOT(outputLevelsChanged(float, float))); 229 this, SLOT(outputLevelsChanged(float, float)));
230 230
231 connect(m_viewManager, SIGNAL(playbackFrameChanged(int)), 231 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)),
232 this, SLOT(playbackFrameChanged(int))); 232 this, SLOT(playbackFrameChanged(sv_frame_t)));
233 233
234 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(int)), 234 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)),
235 this, SLOT(globalCentreFrameChanged(int))); 235 this, SLOT(globalCentreFrameChanged(sv_frame_t)));
236 236
237 connect(m_viewManager, SIGNAL(viewCentreFrameChanged(View *, int)), 237 connect(m_viewManager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)),
238 this, SLOT(viewCentreFrameChanged(View *, int))); 238 this, SLOT(viewCentreFrameChanged(View *, sv_frame_t)));
239 239
240 connect(m_viewManager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), 240 connect(m_viewManager, SIGNAL(viewZoomLevelChanged(View *, int, bool)),
241 this, SLOT(viewZoomLevelChanged(View *, int, bool))); 241 this, SLOT(viewZoomLevelChanged(View *, int, bool)));
242 242
243 connect(Preferences::getInstance(), 243 connect(Preferences::getInstance(),
343 // i.e. that will not otherwise work. The downside is that if this 343 // i.e. that will not otherwise work. The downside is that if this
344 // bug is fixed in a future Qt release, we will start getting 344 // bug is fixed in a future Qt release, we will start getting
345 // "ambiguous shortcut" errors from the menu entry actions and 345 // "ambiguous shortcut" errors from the menu entry actions and
346 // will need to update the code.) 346 // will need to update the code.)
347 347
348 // Update: The bug was fixed in Qt 5.4 for shortcuts with no
349 // modifier, and I believe it is fixed in Qt 5.5 for shortcuts
350 // with Shift modifiers. The below reflects that
351
352 #if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
353
348 if (!m_menuShortcutMapper) { 354 if (!m_menuShortcutMapper) {
349 m_menuShortcutMapper = new QSignalMapper(this); 355 m_menuShortcutMapper = new QSignalMapper(this);
350 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), 356 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)),
351 this, SLOT(menuActionMapperInvoked(QObject *))); 357 this, SLOT(menuActionMapperInvoked(QObject *)));
352 } 358 }
372 378
373 // Note that the set of "single-key shortcuts" that aren't 379 // Note that the set of "single-key shortcuts" that aren't
374 // working and that we need to handle here includes those 380 // working and that we need to handle here includes those
375 // with the Shift modifier mask as well as those with no 381 // with the Shift modifier mask as well as those with no
376 // modifier at all 382 // modifier at all
383 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
384 // Nothing needed
385 if (false) {
386 #elif (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
387 if (sc.count() == 1 &&
388 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier) {
389 #else
377 if (sc.count() == 1 && 390 if (sc.count() == 1 &&
378 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier || 391 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier ||
379 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) { 392 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) {
393 #endif
380 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); 394 QShortcut *newSc = new QShortcut(sc, a->parentWidget());
381 QObject::connect(newSc, SIGNAL(activated()), 395 QObject::connect(newSc, SIGNAL(activated()),
382 m_menuShortcutMapper, SLOT(map())); 396 m_menuShortcutMapper, SLOT(map()));
383 m_menuShortcutMapper->setMapping(newSc, a); 397 m_menuShortcutMapper->setMapping(newSc, a);
384 m_appShortcuts.push_back(newSc); 398 m_appShortcuts.push_back(newSc);
385 } 399 }
386 } 400 }
387 } 401 }
402 #endif
388 #endif 403 #endif
389 } 404 }
390 405
391 void 406 void
392 MainWindowBase::menuActionMapperInvoked(QObject *o) 407 MainWindowBase::menuActionMapperInvoked(QObject *o)
689 // we want is the frame that was last committed to the soundcard 704 // we want is the frame that was last committed to the soundcard
690 // buffers, as the audio driver will continue playing up to that 705 // buffers, as the audio driver will continue playing up to that
691 // frame before switching to whichever one we decide we want to 706 // frame before switching to whichever one we decide we want to
692 // switch to, regardless of our efforts. 707 // switch to, regardless of our efforts.
693 708
694 int frame = m_playSource->getCurrentBufferedFrame(); 709 sv_frame_t frame = m_playSource->getCurrentBufferedFrame();
695 710
696 cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl; 711 cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl;
697 712
698 View::ModelSet soloModels = p->getModels(); 713 View::ModelSet soloModels = p->getModels();
699 714
778 if (!model) return; 793 if (!model) return;
779 794
780 Pane *currentPane = m_paneStack->getCurrentPane(); 795 Pane *currentPane = m_paneStack->getCurrentPane();
781 if (!currentPane) return; 796 if (!currentPane) return;
782 797
783 int startFrame, endFrame; 798 sv_frame_t startFrame, endFrame;
784 799
785 if (currentPane->getStartFrame() < 0) startFrame = 0; 800 if (currentPane->getStartFrame() < 0) startFrame = 0;
786 else startFrame = currentPane->getStartFrame(); 801 else startFrame = currentPane->getStartFrame();
787 802
788 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame(); 803 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame();
849 } 864 }
850 865
851 void 866 void
852 MainWindowBase::pasteAtPlaybackPosition() 867 MainWindowBase::pasteAtPlaybackPosition()
853 { 868 {
854 int pos = getFrame(); 869 sv_frame_t pos = getFrame();
855 Clipboard &clipboard = m_viewManager->getClipboard(); 870 Clipboard &clipboard = m_viewManager->getClipboard();
856 if (!clipboard.empty()) { 871 if (!clipboard.empty()) {
857 int firstEventFrame = clipboard.getPoints()[0].getFrame(); 872 sv_frame_t firstEventFrame = clipboard.getPoints()[0].getFrame();
858 int offset = 0; 873 sv_frame_t offset = 0;
859 if (firstEventFrame < 0) { 874 if (firstEventFrame < 0) {
860 offset = pos - firstEventFrame; 875 offset = pos - firstEventFrame;
861 } else if (firstEventFrame < pos) { 876 } else if (firstEventFrame < pos) {
862 offset = pos - firstEventFrame; 877 offset = pos - firstEventFrame;
863 } else { 878 } else {
866 pasteRelative(offset); 881 pasteRelative(offset);
867 } 882 }
868 } 883 }
869 884
870 void 885 void
871 MainWindowBase::pasteRelative(int offset) 886 MainWindowBase::pasteRelative(sv_frame_t offset)
872 { 887 {
873 Pane *currentPane = m_paneStack->getCurrentPane(); 888 Pane *currentPane = m_paneStack->getCurrentPane();
874 if (!currentPane) return; 889 if (!currentPane) return;
875 890
876 Layer *layer = currentPane->getSelectedLayer(); 891 Layer *layer = currentPane->getSelectedLayer();
934 } 949 }
935 } 950 }
936 951
937 // FrameTimer method 952 // FrameTimer method
938 953
939 int 954 sv_frame_t
940 MainWindowBase::getFrame() const 955 MainWindowBase::getFrame() const
941 { 956 {
942 if (m_playSource && m_playSource->isPlaying()) { 957 if (m_playSource && m_playSource->isPlaying()) {
943 return m_playSource->getCurrentPlayingFrame(); 958 return m_playSource->getCurrentPlayingFrame();
944 } else { 959 } else {
956 MainWindowBase::insertInstantsAtBoundaries() 971 MainWindowBase::insertInstantsAtBoundaries()
957 { 972 {
958 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 973 MultiSelection::SelectionList selections = m_viewManager->getSelections();
959 for (MultiSelection::SelectionList::iterator i = selections.begin(); 974 for (MultiSelection::SelectionList::iterator i = selections.begin();
960 i != selections.end(); ++i) { 975 i != selections.end(); ++i) {
961 int start = i->getStartFrame(); 976 sv_frame_t start = i->getStartFrame();
962 int end = i->getEndFrame(); 977 sv_frame_t end = i->getEndFrame();
963 if (start != end) { 978 if (start != end) {
964 insertInstantAt(start); 979 insertInstantAt(start);
965 insertInstantAt(end); 980 insertInstantAt(end);
966 } 981 }
967 } 982 }
968 } 983 }
969 984
970 void 985 void
971 MainWindowBase::insertInstantAt(int frame) 986 MainWindowBase::insertInstantAt(sv_frame_t frame)
972 { 987 {
973 Pane *pane = m_paneStack->getCurrentPane(); 988 Pane *pane = m_paneStack->getCurrentPane();
974 if (!pane) { 989 if (!pane) {
975 return; 990 return;
976 } 991 }
1058 MainWindowBase::insertItemAtSelection() 1073 MainWindowBase::insertItemAtSelection()
1059 { 1074 {
1060 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 1075 MultiSelection::SelectionList selections = m_viewManager->getSelections();
1061 for (MultiSelection::SelectionList::iterator i = selections.begin(); 1076 for (MultiSelection::SelectionList::iterator i = selections.begin();
1062 i != selections.end(); ++i) { 1077 i != selections.end(); ++i) {
1063 int start = i->getStartFrame(); 1078 sv_frame_t start = i->getStartFrame();
1064 int end = i->getEndFrame(); 1079 sv_frame_t end = i->getEndFrame();
1065 if (start < end) { 1080 if (start < end) {
1066 insertItemAt(start, end - start); 1081 insertItemAt(start, end - start);
1067 } 1082 }
1068 } 1083 }
1069 } 1084 }
1070 1085
1071 void 1086 void
1072 MainWindowBase::insertItemAt(int frame, int duration) 1087 MainWindowBase::insertItemAt(sv_frame_t frame, sv_frame_t duration)
1073 { 1088 {
1074 Pane *pane = m_paneStack->getCurrentPane(); 1089 Pane *pane = m_paneStack->getCurrentPane();
1075 if (!pane) { 1090 if (!pane) {
1076 return; 1091 return;
1077 } 1092 }
1078 1093
1079 // ugh! 1094 // ugh!
1080 1095
1081 int alignedStart = pane->alignFromReference(frame); 1096 sv_frame_t alignedStart = pane->alignFromReference(frame);
1082 int alignedEnd = pane->alignFromReference(frame + duration); 1097 sv_frame_t alignedEnd = pane->alignFromReference(frame + duration);
1083 if (alignedStart >= alignedEnd) return; 1098 if (alignedStart >= alignedEnd) return;
1084 int alignedDuration = alignedEnd - alignedStart; 1099 sv_frame_t alignedDuration = alignedEnd - alignedStart;
1085 1100
1086 Command *c = 0; 1101 Command *c = 0;
1087 1102
1088 QString name = tr("Add Item at %1 s") 1103 QString name = tr("Add Item at %1 s")
1089 .arg(RealTime::frame2RealTime 1104 .arg(RealTime::frame2RealTime
1279 1294
1280 source.waitForData(); 1295 source.waitForData();
1281 1296
1282 m_openingAudioFile = true; 1297 m_openingAudioFile = true;
1283 1298
1284 int rate = 0; 1299 sv_samplerate_t rate = 0;
1285 1300
1286 if (Preferences::getInstance()->getFixedSampleRate() != 0) { 1301 if (Preferences::getInstance()->getFixedSampleRate() != 0) {
1287 rate = Preferences::getInstance()->getFixedSampleRate(); 1302 rate = Preferences::getInstance()->getFixedSampleRate();
1288 } else if (Preferences::getInstance()->getResampleOnLoad()) { 1303 } else if (Preferences::getInstance()->getResampleOnLoad()) {
1289 rate = m_playSource->getSourceSampleRate(); 1304 rate = m_playSource->getSourceSampleRate();
2033 } 2048 }
2034 2049
2035 MainWindowBase::FileOpenStatus 2050 MainWindowBase::FileOpenStatus
2036 MainWindowBase::openLayersFromRDF(FileSource source) 2051 MainWindowBase::openLayersFromRDF(FileSource source)
2037 { 2052 {
2038 int rate = 0; 2053 sv_samplerate_t rate = 0;
2039 2054
2040 SVDEBUG << "MainWindowBase::openLayersFromRDF" << endl; 2055 SVDEBUG << "MainWindowBase::openLayersFromRDF" << endl;
2041 2056
2042 ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this); 2057 ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this);
2043 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); 2058 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
2281 } 2296 }
2282 2297
2283 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 2298 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2284 2299
2285 QTextStream out(&bzFile); 2300 QTextStream out(&bzFile);
2301 out.setCodec(QTextCodec::codecForName("UTF-8"));
2286 toXml(out, false); 2302 toXml(out, false);
2287 out.flush(); 2303 out.flush();
2288 2304
2289 QApplication::restoreOverrideCursor(); 2305 QApplication::restoreOverrideCursor();
2290 2306
2326 } 2342 }
2327 2343
2328 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 2344 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2329 2345
2330 QTextStream out(&file); 2346 QTextStream out(&file);
2347 out.setCodec(QTextCodec::codecForName("UTF-8"));
2331 toXml(out, true); 2348 toXml(out, true);
2332 out.flush(); 2349 out.flush();
2333 2350
2334 QApplication::restoreOverrideCursor(); 2351 QApplication::restoreOverrideCursor();
2335 2352
2413 if (!currentPane) return; 2430 if (!currentPane) return;
2414 2431
2415 Model *model = getMainModel(); 2432 Model *model = getMainModel();
2416 if (!model) return; 2433 if (!model) return;
2417 2434
2418 int start = model->getStartFrame(); 2435 sv_frame_t start = model->getStartFrame();
2419 int end = model->getEndFrame(); 2436 sv_frame_t end = model->getEndFrame();
2420 if (m_playSource) end = std::max(end, m_playSource->getPlayEndFrame()); 2437 if (m_playSource) end = std::max(end, m_playSource->getPlayEndFrame());
2421 int pixels = currentPane->width(); 2438 int pixels = currentPane->width();
2422 2439
2423 int sw = currentPane->getVerticalScaleWidth(); 2440 int sw = currentPane->getVerticalScaleWidth();
2424 if (pixels > sw * 2) pixels -= sw * 2; 2441 if (pixels > sw * 2) pixels -= sw * 2;
2425 else pixels = 1; 2442 else pixels = 1;
2426 if (pixels > 4) pixels -= 4; 2443 if (pixels > 4) pixels -= 4;
2427 2444
2428 int zoomLevel = (end - start) / pixels; 2445 int zoomLevel = int((end - start) / pixels);
2429 if (zoomLevel < 1) zoomLevel = 1; 2446 if (zoomLevel < 1) zoomLevel = 1;
2430 2447
2431 currentPane->setZoomLevel(zoomLevel); 2448 currentPane->setZoomLevel(zoomLevel);
2432 currentPane->setCentreFrame((start + end) / 2); 2449 currentPane->setCentreFrame((start + end) / 2);
2433 } 2450 }
2652 void 2669 void
2653 MainWindowBase::ffwd() 2670 MainWindowBase::ffwd()
2654 { 2671 {
2655 if (!getMainModel()) return; 2672 if (!getMainModel()) return;
2656 2673
2657 int frame = m_viewManager->getPlaybackFrame(); 2674 sv_frame_t frame = m_viewManager->getPlaybackFrame();
2658 ++frame; 2675 ++frame;
2659 2676
2660 Pane *pane = m_paneStack->getCurrentPane(); 2677 Pane *pane = m_paneStack->getCurrentPane();
2661 Layer *layer = getSnapLayer(); 2678 Layer *layer = getSnapLayer();
2662 int sr = getMainModel()->getSampleRate(); 2679 sv_samplerate_t sr = getMainModel()->getSampleRate();
2663 2680
2664 if (!layer) { 2681 if (!layer) {
2665 2682
2666 frame = RealTime::realTime2Frame 2683 frame = RealTime::realTime2Frame
2667 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr); 2684 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr);
2668 if (frame > int(getMainModel()->getEndFrame())) { 2685 if (frame > getMainModel()->getEndFrame()) {
2669 frame = getMainModel()->getEndFrame(); 2686 frame = getMainModel()->getEndFrame();
2670 } 2687 }
2671 2688
2672 } else { 2689 } else {
2673 2690
2682 } 2699 }
2683 2700
2684 if (frame < 0) frame = 0; 2701 if (frame < 0) frame = 0;
2685 2702
2686 if (m_viewManager->getPlaySelectionMode()) { 2703 if (m_viewManager->getPlaySelectionMode()) {
2687 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2704 frame = m_viewManager->constrainFrameToSelection(frame);
2688 } 2705 }
2689 2706
2690 m_viewManager->setPlaybackFrame(frame); 2707 m_viewManager->setPlaybackFrame(frame);
2691 2708
2692 if (frame == (int)getMainModel()->getEndFrame() && 2709 if (frame == getMainModel()->getEndFrame() &&
2693 m_playSource && 2710 m_playSource &&
2694 m_playSource->isPlaying() && 2711 m_playSource->isPlaying() &&
2695 !m_viewManager->getPlayLoopMode()) { 2712 !m_viewManager->getPlayLoopMode()) {
2696 stop(); 2713 stop();
2697 } 2714 }
2706 m_playSource->isPlaying() && 2723 m_playSource->isPlaying() &&
2707 !m_viewManager->getPlayLoopMode()) { 2724 !m_viewManager->getPlayLoopMode()) {
2708 stop(); 2725 stop();
2709 } 2726 }
2710 2727
2711 int frame = getMainModel()->getEndFrame(); 2728 sv_frame_t frame = getMainModel()->getEndFrame();
2712 2729
2713 if (m_viewManager->getPlaySelectionMode()) { 2730 if (m_viewManager->getPlaySelectionMode()) {
2714 frame = m_viewManager->constrainFrameToSelection(frame); 2731 frame = m_viewManager->constrainFrameToSelection(frame);
2715 } 2732 }
2716 2733
2724 2741
2725 Layer *layer = getSnapLayer(); 2742 Layer *layer = getSnapLayer();
2726 if (!layer) { ffwd(); return; } 2743 if (!layer) { ffwd(); return; }
2727 2744
2728 Pane *pane = m_paneStack->getCurrentPane(); 2745 Pane *pane = m_paneStack->getCurrentPane();
2729 int frame = m_viewManager->getPlaybackFrame(); 2746 sv_frame_t frame = m_viewManager->getPlaybackFrame();
2730 2747
2731 int resolution = 0; 2748 int resolution = 0;
2732 if (pane) frame = pane->alignFromReference(frame); 2749 if (pane) frame = pane->alignFromReference(frame);
2733 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), 2750 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(),
2734 frame, resolution, Layer::SnapRight)) { 2751 frame, resolution, Layer::SnapRight)) {
2738 } 2755 }
2739 2756
2740 if (frame < 0) frame = 0; 2757 if (frame < 0) frame = 0;
2741 2758
2742 if (m_viewManager->getPlaySelectionMode()) { 2759 if (m_viewManager->getPlaySelectionMode()) {
2743 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2760 frame = m_viewManager->constrainFrameToSelection(frame);
2744 } 2761 }
2745 2762
2746 m_viewManager->setPlaybackFrame(frame); 2763 m_viewManager->setPlaybackFrame(frame);
2747 2764
2748 if (frame == (int)getMainModel()->getEndFrame() && 2765 if (frame == getMainModel()->getEndFrame() &&
2749 m_playSource && 2766 m_playSource &&
2750 m_playSource->isPlaying() && 2767 m_playSource->isPlaying() &&
2751 !m_viewManager->getPlayLoopMode()) { 2768 !m_viewManager->getPlayLoopMode()) {
2752 stop(); 2769 stop();
2753 } 2770 }
2756 void 2773 void
2757 MainWindowBase::rewind() 2774 MainWindowBase::rewind()
2758 { 2775 {
2759 if (!getMainModel()) return; 2776 if (!getMainModel()) return;
2760 2777
2761 int frame = m_viewManager->getPlaybackFrame(); 2778 sv_frame_t frame = m_viewManager->getPlaybackFrame();
2762 if (frame > 0) --frame; 2779 if (frame > 0) --frame;
2763 2780
2764 Pane *pane = m_paneStack->getCurrentPane(); 2781 Pane *pane = m_paneStack->getCurrentPane();
2765 Layer *layer = getSnapLayer(); 2782 Layer *layer = getSnapLayer();
2766 int sr = getMainModel()->getSampleRate(); 2783 sv_samplerate_t sr = getMainModel()->getSampleRate();
2767 2784
2768 // when rewinding during playback, we want to allow a period 2785 // when rewinding during playback, we want to allow a period
2769 // following a rewind target point at which the rewind will go to 2786 // following a rewind target point at which the rewind will go to
2770 // the prior point instead of the immediately neighbouring one 2787 // the prior point instead of the immediately neighbouring one
2771 if (m_playSource && m_playSource->isPlaying()) { 2788 if (m_playSource && m_playSource->isPlaying()) {
2777 2794
2778 if (!layer) { 2795 if (!layer) {
2779 2796
2780 frame = RealTime::realTime2Frame 2797 frame = RealTime::realTime2Frame
2781 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr); 2798 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr);
2782 if (frame < int(getMainModel()->getStartFrame())) { 2799 if (frame < getMainModel()->getStartFrame()) {
2783 frame = getMainModel()->getStartFrame(); 2800 frame = getMainModel()->getStartFrame();
2784 } 2801 }
2785 2802
2786 } else { 2803 } else {
2787 2804
2796 } 2813 }
2797 2814
2798 if (frame < 0) frame = 0; 2815 if (frame < 0) frame = 0;
2799 2816
2800 if (m_viewManager->getPlaySelectionMode()) { 2817 if (m_viewManager->getPlaySelectionMode()) {
2801 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2818 frame = m_viewManager->constrainFrameToSelection(frame);
2802 } 2819 }
2803 2820
2804 m_viewManager->setPlaybackFrame(frame); 2821 m_viewManager->setPlaybackFrame(frame);
2805 } 2822 }
2806 2823
2807 void 2824 void
2808 MainWindowBase::rewindStart() 2825 MainWindowBase::rewindStart()
2809 { 2826 {
2810 if (!getMainModel()) return; 2827 if (!getMainModel()) return;
2811 2828
2812 int frame = getMainModel()->getStartFrame(); 2829 sv_frame_t frame = getMainModel()->getStartFrame();
2813 2830
2814 if (m_viewManager->getPlaySelectionMode()) { 2831 if (m_viewManager->getPlaySelectionMode()) {
2815 frame = m_viewManager->constrainFrameToSelection(frame); 2832 frame = m_viewManager->constrainFrameToSelection(frame);
2816 } 2833 }
2817 2834
2825 2842
2826 Layer *layer = getSnapLayer(); 2843 Layer *layer = getSnapLayer();
2827 if (!layer) { rewind(); return; } 2844 if (!layer) { rewind(); return; }
2828 2845
2829 Pane *pane = m_paneStack->getCurrentPane(); 2846 Pane *pane = m_paneStack->getCurrentPane();
2830 int frame = m_viewManager->getPlaybackFrame(); 2847 sv_frame_t frame = m_viewManager->getPlaybackFrame();
2831 2848
2832 int resolution = 0; 2849 int resolution = 0;
2833 if (pane) frame = pane->alignFromReference(frame); 2850 if (pane) frame = pane->alignFromReference(frame);
2834 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), 2851 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(),
2835 frame, resolution, Layer::SnapLeft)) { 2852 frame, resolution, Layer::SnapLeft)) {
2839 } 2856 }
2840 2857
2841 if (frame < 0) frame = 0; 2858 if (frame < 0) frame = 0;
2842 2859
2843 if (m_viewManager->getPlaySelectionMode()) { 2860 if (m_viewManager->getPlaySelectionMode()) {
2844 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2861 frame = m_viewManager->constrainFrameToSelection(frame);
2845 } 2862 }
2846 2863
2847 m_viewManager->setPlaybackFrame(frame); 2864 m_viewManager->setPlaybackFrame(frame);
2848 } 2865 }
2849 2866
3052 3069
3053 void 3070 void
3054 MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog) 3071 MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog)
3055 { 3072 {
3056 connect(m_viewManager, 3073 connect(m_viewManager,
3057 SIGNAL(globalCentreFrameChanged(int)), 3074 SIGNAL(globalCentreFrameChanged(sv_frame_t)),
3058 dialog, 3075 dialog,
3059 SLOT(userScrolledToFrame(int))); 3076 SLOT(userScrolledToFrame(sv_frame_t)));
3060 3077
3061 connect(m_viewManager, 3078 connect(m_viewManager,
3062 SIGNAL(playbackFrameChanged(int)), 3079 SIGNAL(playbackFrameChanged(sv_frame_t)),
3063 dialog, 3080 dialog,
3064 SLOT(playbackScrolledToFrame(int))); 3081 SLOT(playbackScrolledToFrame(sv_frame_t)));
3065 3082
3066 connect(dialog, 3083 connect(dialog,
3067 SIGNAL(scrollToFrame(int)), 3084 SIGNAL(scrollToFrame(sv_frame_t)),
3068 m_viewManager, 3085 m_viewManager,
3069 SLOT(setGlobalCentreFrame(int))); 3086 SLOT(setGlobalCentreFrame(sv_frame_t)));
3070 3087
3071 connect(dialog, 3088 connect(dialog,
3072 SIGNAL(scrollToFrame(int)), 3089 SIGNAL(scrollToFrame(sv_frame_t)),
3073 m_viewManager, 3090 m_viewManager,
3074 SLOT(setPlaybackFrame(int))); 3091 SLOT(setPlaybackFrame(sv_frame_t)));
3075 } 3092 }
3076 3093
3077 void 3094 void
3078 MainWindowBase::previousPane() 3095 MainWindowBase::previousPane()
3079 { 3096 {
3179 3196
3180 updateMenuStates(); 3197 updateMenuStates();
3181 } 3198 }
3182 3199
3183 void 3200 void
3184 MainWindowBase::playbackFrameChanged(int frame) 3201 MainWindowBase::playbackFrameChanged(sv_frame_t frame)
3185 { 3202 {
3186 if (!(m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; 3203 if (!(m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3187 3204
3188 updatePositionStatusDisplays(); 3205 updatePositionStatusDisplays();
3189 3206
3215 3232
3216 getStatusLabel()->setText(m_myStatusMessage); 3233 getStatusLabel()->setText(m_myStatusMessage);
3217 } 3234 }
3218 3235
3219 void 3236 void
3220 MainWindowBase::globalCentreFrameChanged(int ) 3237 MainWindowBase::globalCentreFrameChanged(sv_frame_t )
3221 { 3238 {
3222 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; 3239 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3223 Pane *p = 0; 3240 Pane *p = 0;
3224 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; 3241 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3225 if (!p->getFollowGlobalPan()) return; 3242 if (!p->getFollowGlobalPan()) return;
3226 updateVisibleRangeDisplay(p); 3243 updateVisibleRangeDisplay(p);
3227 } 3244 }
3228 3245
3229 void 3246 void
3230 MainWindowBase::viewCentreFrameChanged(View *v, int frame) 3247 MainWindowBase::viewCentreFrameChanged(View *v, sv_frame_t frame)
3231 { 3248 {
3232 // SVDEBUG << "MainWindowBase::viewCentreFrameChanged(" << v << "," << frame << ")" << endl; 3249 // SVDEBUG << "MainWindowBase::viewCentreFrameChanged(" << v << "," << frame << ")" << endl;
3233 3250
3234 if (m_viewDataDialogMap.find(v) != m_viewDataDialogMap.end()) { 3251 if (m_viewDataDialogMap.find(v) != m_viewDataDialogMap.end()) {
3235 for (DataDialogSet::iterator i = m_viewDataDialogMap[v].begin(); 3252 for (DataDialogSet::iterator i = m_viewDataDialogMap[v].begin();