Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 449:12d982e52190
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:21:08 +0100 |
parents | ba789baf642b |
children | d9d132c0e240 c651a736ebc4 |
comparison
equal
deleted
inserted
replaced
432:9876a1db566c | 449:12d982e52190 |
---|---|
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" |
104 | 103 |
105 #include <iostream> | 104 #include <iostream> |
106 #include <cstdio> | 105 #include <cstdio> |
107 #include <errno.h> | 106 #include <errno.h> |
108 | 107 |
109 | |
110 | |
111 | |
112 using std::vector; | 108 using std::vector; |
113 using std::map; | 109 using std::map; |
114 using std::set; | 110 using std::set; |
115 | 111 |
116 #ifdef Q_WS_X11 | 112 #ifdef Q_WS_X11 |
159 m_statusLabel(0), | 155 m_statusLabel(0), |
160 m_menuShortcutMapper(0) | 156 m_menuShortcutMapper(0) |
161 { | 157 { |
162 Profiler profiler("MainWindowBase::MainWindowBase"); | 158 Profiler profiler("MainWindowBase::MainWindowBase"); |
163 | 159 |
160 qRegisterMetaType<sv_frame_t>("sv_frame_t"); | |
161 qRegisterMetaType<sv_samplerate_t>("sv_samplerate_t"); | |
162 | |
164 #ifdef Q_WS_X11 | 163 #ifdef Q_WS_X11 |
165 XSetErrorHandler(handle_x11_error); | 164 XSetErrorHandler(handle_x11_error); |
166 #endif | 165 #endif |
167 | 166 |
168 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()), | 167 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()), |
176 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), | 175 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), |
177 this, SLOT(inProgressSelectionChanged())); | 176 this, SLOT(inProgressSelectionChanged())); |
178 | 177 |
179 // set a sensible default font size for views -- cannot do this | 178 // set a sensible default font size for views -- cannot do this |
180 // in Preferences, which is in base and not supposed to use QtGui | 179 // in Preferences, which is in base and not supposed to use QtGui |
181 int viewFontSize = QApplication::font().pointSize() * 0.9; | 180 int viewFontSize = int(QApplication::font().pointSize() * 0.9); |
182 QSettings settings; | 181 QSettings settings; |
183 settings.beginGroup("Preferences"); | 182 settings.beginGroup("Preferences"); |
184 viewFontSize = settings.value("view-font-size", viewFontSize).toInt(); | 183 viewFontSize = settings.value("view-font-size", viewFontSize).toInt(); |
185 settings.setValue("view-font-size", viewFontSize); | 184 settings.setValue("view-font-size", viewFontSize); |
186 settings.endGroup(); | 185 settings.endGroup(); |
216 this, SLOT(paneDeleteButtonClicked(Pane *))); | 215 this, SLOT(paneDeleteButtonClicked(Pane *))); |
217 | 216 |
218 m_playSource = new AudioCallbackPlaySource(m_viewManager, | 217 m_playSource = new AudioCallbackPlaySource(m_viewManager, |
219 QApplication::applicationName()); | 218 QApplication::applicationName()); |
220 | 219 |
221 connect(m_playSource, SIGNAL(sampleRateMismatch(int, int, bool)), | 220 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), |
222 this, SLOT(sampleRateMismatch(int, int, bool))); | 221 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); |
223 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), | 222 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), |
224 this, SLOT(audioOverloadPluginDisabled())); | 223 this, SLOT(audioOverloadPluginDisabled())); |
225 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), | 224 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), |
226 this, SLOT(audioTimeStretchMultiChannelDisabled())); | 225 this, SLOT(audioTimeStretchMultiChannelDisabled())); |
227 | 226 |
228 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)), | 227 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)), |
229 this, SLOT(outputLevelsChanged(float, float))); | 228 this, SLOT(outputLevelsChanged(float, float))); |
230 | 229 |
231 connect(m_viewManager, SIGNAL(playbackFrameChanged(int)), | 230 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)), |
232 this, SLOT(playbackFrameChanged(int))); | 231 this, SLOT(playbackFrameChanged(sv_frame_t))); |
233 | 232 |
234 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(int)), | 233 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), |
235 this, SLOT(globalCentreFrameChanged(int))); | 234 this, SLOT(globalCentreFrameChanged(sv_frame_t))); |
236 | 235 |
237 connect(m_viewManager, SIGNAL(viewCentreFrameChanged(View *, int)), | 236 connect(m_viewManager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), |
238 this, SLOT(viewCentreFrameChanged(View *, int))); | 237 this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); |
239 | 238 |
240 connect(m_viewManager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), | 239 connect(m_viewManager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), |
241 this, SLOT(viewZoomLevelChanged(View *, int, bool))); | 240 this, SLOT(viewZoomLevelChanged(View *, int, bool))); |
242 | 241 |
243 connect(Preferences::getInstance(), | 242 connect(Preferences::getInstance(), |
343 // i.e. that will not otherwise work. The downside is that if this | 342 // 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 | 343 // bug is fixed in a future Qt release, we will start getting |
345 // "ambiguous shortcut" errors from the menu entry actions and | 344 // "ambiguous shortcut" errors from the menu entry actions and |
346 // will need to update the code.) | 345 // will need to update the code.) |
347 | 346 |
347 // Update: The bug was fixed in Qt 5.4 for shortcuts with no | |
348 // modifier, and I believe it is fixed in Qt 5.5 for shortcuts | |
349 // with Shift modifiers. The below reflects that | |
350 | |
351 #if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) | |
352 | |
348 if (!m_menuShortcutMapper) { | 353 if (!m_menuShortcutMapper) { |
349 m_menuShortcutMapper = new QSignalMapper(this); | 354 m_menuShortcutMapper = new QSignalMapper(this); |
350 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), | 355 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), |
351 this, SLOT(menuActionMapperInvoked(QObject *))); | 356 this, SLOT(menuActionMapperInvoked(QObject *))); |
352 } | 357 } |
372 | 377 |
373 // Note that the set of "single-key shortcuts" that aren't | 378 // Note that the set of "single-key shortcuts" that aren't |
374 // working and that we need to handle here includes those | 379 // working and that we need to handle here includes those |
375 // with the Shift modifier mask as well as those with no | 380 // with the Shift modifier mask as well as those with no |
376 // modifier at all | 381 // modifier at all |
382 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) | |
383 // Nothing needed | |
384 if (false) { | |
385 #elif (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)) | |
386 if (sc.count() == 1 && | |
387 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier) { | |
388 #else | |
377 if (sc.count() == 1 && | 389 if (sc.count() == 1 && |
378 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier || | 390 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier || |
379 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) { | 391 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) { |
392 #endif | |
380 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); | 393 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); |
381 QObject::connect(newSc, SIGNAL(activated()), | 394 QObject::connect(newSc, SIGNAL(activated()), |
382 m_menuShortcutMapper, SLOT(map())); | 395 m_menuShortcutMapper, SLOT(map())); |
383 m_menuShortcutMapper->setMapping(newSc, a); | 396 m_menuShortcutMapper->setMapping(newSc, a); |
384 m_appShortcuts.push_back(newSc); | 397 m_appShortcuts.push_back(newSc); |
385 } | 398 } |
386 } | 399 } |
387 } | 400 } |
401 #endif | |
388 #endif | 402 #endif |
389 } | 403 } |
390 | 404 |
391 void | 405 void |
392 MainWindowBase::menuActionMapperInvoked(QObject *o) | 406 MainWindowBase::menuActionMapperInvoked(QObject *o) |
689 // we want is the frame that was last committed to the soundcard | 703 // we want is the frame that was last committed to the soundcard |
690 // buffers, as the audio driver will continue playing up to that | 704 // buffers, as the audio driver will continue playing up to that |
691 // frame before switching to whichever one we decide we want to | 705 // frame before switching to whichever one we decide we want to |
692 // switch to, regardless of our efforts. | 706 // switch to, regardless of our efforts. |
693 | 707 |
694 int frame = m_playSource->getCurrentBufferedFrame(); | 708 sv_frame_t frame = m_playSource->getCurrentBufferedFrame(); |
695 | 709 |
696 cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl; | 710 cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl; |
697 | 711 |
698 View::ModelSet soloModels = p->getModels(); | 712 View::ModelSet soloModels = p->getModels(); |
699 | 713 |
778 if (!model) return; | 792 if (!model) return; |
779 | 793 |
780 Pane *currentPane = m_paneStack->getCurrentPane(); | 794 Pane *currentPane = m_paneStack->getCurrentPane(); |
781 if (!currentPane) return; | 795 if (!currentPane) return; |
782 | 796 |
783 int startFrame, endFrame; | 797 sv_frame_t startFrame, endFrame; |
784 | 798 |
785 if (currentPane->getStartFrame() < 0) startFrame = 0; | 799 if (currentPane->getStartFrame() < 0) startFrame = 0; |
786 else startFrame = currentPane->getStartFrame(); | 800 else startFrame = currentPane->getStartFrame(); |
787 | 801 |
788 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame(); | 802 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame(); |
849 } | 863 } |
850 | 864 |
851 void | 865 void |
852 MainWindowBase::pasteAtPlaybackPosition() | 866 MainWindowBase::pasteAtPlaybackPosition() |
853 { | 867 { |
854 int pos = getFrame(); | 868 sv_frame_t pos = getFrame(); |
855 Clipboard &clipboard = m_viewManager->getClipboard(); | 869 Clipboard &clipboard = m_viewManager->getClipboard(); |
856 if (!clipboard.empty()) { | 870 if (!clipboard.empty()) { |
857 int firstEventFrame = clipboard.getPoints()[0].getFrame(); | 871 sv_frame_t firstEventFrame = clipboard.getPoints()[0].getFrame(); |
858 int offset = 0; | 872 sv_frame_t offset = 0; |
859 if (firstEventFrame < 0) { | 873 if (firstEventFrame < 0) { |
860 offset = pos - firstEventFrame; | 874 offset = pos - firstEventFrame; |
861 } else if (firstEventFrame < pos) { | 875 } else if (firstEventFrame < pos) { |
862 offset = pos - firstEventFrame; | 876 offset = pos - firstEventFrame; |
863 } else { | 877 } else { |
866 pasteRelative(offset); | 880 pasteRelative(offset); |
867 } | 881 } |
868 } | 882 } |
869 | 883 |
870 void | 884 void |
871 MainWindowBase::pasteRelative(int offset) | 885 MainWindowBase::pasteRelative(sv_frame_t offset) |
872 { | 886 { |
873 Pane *currentPane = m_paneStack->getCurrentPane(); | 887 Pane *currentPane = m_paneStack->getCurrentPane(); |
874 if (!currentPane) return; | 888 if (!currentPane) return; |
875 | 889 |
876 Layer *layer = currentPane->getSelectedLayer(); | 890 Layer *layer = currentPane->getSelectedLayer(); |
934 } | 948 } |
935 } | 949 } |
936 | 950 |
937 // FrameTimer method | 951 // FrameTimer method |
938 | 952 |
939 int | 953 sv_frame_t |
940 MainWindowBase::getFrame() const | 954 MainWindowBase::getFrame() const |
941 { | 955 { |
942 if (m_playSource && m_playSource->isPlaying()) { | 956 if (m_playSource && m_playSource->isPlaying()) { |
943 return m_playSource->getCurrentPlayingFrame(); | 957 return m_playSource->getCurrentPlayingFrame(); |
944 } else { | 958 } else { |
956 MainWindowBase::insertInstantsAtBoundaries() | 970 MainWindowBase::insertInstantsAtBoundaries() |
957 { | 971 { |
958 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | 972 MultiSelection::SelectionList selections = m_viewManager->getSelections(); |
959 for (MultiSelection::SelectionList::iterator i = selections.begin(); | 973 for (MultiSelection::SelectionList::iterator i = selections.begin(); |
960 i != selections.end(); ++i) { | 974 i != selections.end(); ++i) { |
961 int start = i->getStartFrame(); | 975 sv_frame_t start = i->getStartFrame(); |
962 int end = i->getEndFrame(); | 976 sv_frame_t end = i->getEndFrame(); |
963 if (start != end) { | 977 if (start != end) { |
964 insertInstantAt(start); | 978 insertInstantAt(start); |
965 insertInstantAt(end); | 979 insertInstantAt(end); |
966 } | 980 } |
967 } | 981 } |
968 } | 982 } |
969 | 983 |
970 void | 984 void |
971 MainWindowBase::insertInstantAt(int frame) | 985 MainWindowBase::insertInstantAt(sv_frame_t frame) |
972 { | 986 { |
973 Pane *pane = m_paneStack->getCurrentPane(); | 987 Pane *pane = m_paneStack->getCurrentPane(); |
974 if (!pane) { | 988 if (!pane) { |
975 return; | 989 return; |
976 } | 990 } |
1058 MainWindowBase::insertItemAtSelection() | 1072 MainWindowBase::insertItemAtSelection() |
1059 { | 1073 { |
1060 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | 1074 MultiSelection::SelectionList selections = m_viewManager->getSelections(); |
1061 for (MultiSelection::SelectionList::iterator i = selections.begin(); | 1075 for (MultiSelection::SelectionList::iterator i = selections.begin(); |
1062 i != selections.end(); ++i) { | 1076 i != selections.end(); ++i) { |
1063 int start = i->getStartFrame(); | 1077 sv_frame_t start = i->getStartFrame(); |
1064 int end = i->getEndFrame(); | 1078 sv_frame_t end = i->getEndFrame(); |
1065 if (start < end) { | 1079 if (start < end) { |
1066 insertItemAt(start, end - start); | 1080 insertItemAt(start, end - start); |
1067 } | 1081 } |
1068 } | 1082 } |
1069 } | 1083 } |
1070 | 1084 |
1071 void | 1085 void |
1072 MainWindowBase::insertItemAt(int frame, int duration) | 1086 MainWindowBase::insertItemAt(sv_frame_t frame, sv_frame_t duration) |
1073 { | 1087 { |
1074 Pane *pane = m_paneStack->getCurrentPane(); | 1088 Pane *pane = m_paneStack->getCurrentPane(); |
1075 if (!pane) { | 1089 if (!pane) { |
1076 return; | 1090 return; |
1077 } | 1091 } |
1078 | 1092 |
1079 // ugh! | 1093 // ugh! |
1080 | 1094 |
1081 int alignedStart = pane->alignFromReference(frame); | 1095 sv_frame_t alignedStart = pane->alignFromReference(frame); |
1082 int alignedEnd = pane->alignFromReference(frame + duration); | 1096 sv_frame_t alignedEnd = pane->alignFromReference(frame + duration); |
1083 if (alignedStart >= alignedEnd) return; | 1097 if (alignedStart >= alignedEnd) return; |
1084 int alignedDuration = alignedEnd - alignedStart; | 1098 sv_frame_t alignedDuration = alignedEnd - alignedStart; |
1085 | 1099 |
1086 Command *c = 0; | 1100 Command *c = 0; |
1087 | 1101 |
1088 QString name = tr("Add Item at %1 s") | 1102 QString name = tr("Add Item at %1 s") |
1089 .arg(RealTime::frame2RealTime | 1103 .arg(RealTime::frame2RealTime |
1279 | 1293 |
1280 source.waitForData(); | 1294 source.waitForData(); |
1281 | 1295 |
1282 m_openingAudioFile = true; | 1296 m_openingAudioFile = true; |
1283 | 1297 |
1284 int rate = 0; | 1298 sv_samplerate_t rate = 0; |
1285 | 1299 |
1286 if (Preferences::getInstance()->getFixedSampleRate() != 0) { | 1300 if (Preferences::getInstance()->getFixedSampleRate() != 0) { |
1287 rate = Preferences::getInstance()->getFixedSampleRate(); | 1301 rate = Preferences::getInstance()->getFixedSampleRate(); |
1288 } else if (Preferences::getInstance()->getResampleOnLoad()) { | 1302 } else if (Preferences::getInstance()->getResampleOnLoad()) { |
1289 rate = m_playSource->getSourceSampleRate(); | 1303 rate = m_playSource->getSourceSampleRate(); |
1988 } | 2002 } |
1989 | 2003 |
1990 MainWindowBase::FileOpenStatus | 2004 MainWindowBase::FileOpenStatus |
1991 MainWindowBase::openLayersFromRDF(FileSource source) | 2005 MainWindowBase::openLayersFromRDF(FileSource source) |
1992 { | 2006 { |
1993 int rate = 0; | 2007 sv_samplerate_t rate = 0; |
1994 | 2008 |
1995 SVDEBUG << "MainWindowBase::openLayersFromRDF" << endl; | 2009 SVDEBUG << "MainWindowBase::openLayersFromRDF" << endl; |
1996 | 2010 |
1997 ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this); | 2011 ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this); |
1998 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); | 2012 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); |
2368 if (!currentPane) return; | 2382 if (!currentPane) return; |
2369 | 2383 |
2370 Model *model = getMainModel(); | 2384 Model *model = getMainModel(); |
2371 if (!model) return; | 2385 if (!model) return; |
2372 | 2386 |
2373 int start = model->getStartFrame(); | 2387 sv_frame_t start = model->getStartFrame(); |
2374 int end = model->getEndFrame(); | 2388 sv_frame_t end = model->getEndFrame(); |
2375 if (m_playSource) end = std::max(end, m_playSource->getPlayEndFrame()); | 2389 if (m_playSource) end = std::max(end, m_playSource->getPlayEndFrame()); |
2376 int pixels = currentPane->width(); | 2390 int pixels = currentPane->width(); |
2377 | 2391 |
2378 int sw = currentPane->getVerticalScaleWidth(); | 2392 int sw = currentPane->getVerticalScaleWidth(); |
2379 if (pixels > sw * 2) pixels -= sw * 2; | 2393 if (pixels > sw * 2) pixels -= sw * 2; |
2380 else pixels = 1; | 2394 else pixels = 1; |
2381 if (pixels > 4) pixels -= 4; | 2395 if (pixels > 4) pixels -= 4; |
2382 | 2396 |
2383 int zoomLevel = (end - start) / pixels; | 2397 int zoomLevel = int((end - start) / pixels); |
2384 if (zoomLevel < 1) zoomLevel = 1; | 2398 if (zoomLevel < 1) zoomLevel = 1; |
2385 | 2399 |
2386 currentPane->setZoomLevel(zoomLevel); | 2400 currentPane->setZoomLevel(zoomLevel); |
2387 currentPane->setCentreFrame((start + end) / 2); | 2401 currentPane->setCentreFrame((start + end) / 2); |
2388 } | 2402 } |
2607 void | 2621 void |
2608 MainWindowBase::ffwd() | 2622 MainWindowBase::ffwd() |
2609 { | 2623 { |
2610 if (!getMainModel()) return; | 2624 if (!getMainModel()) return; |
2611 | 2625 |
2612 int frame = m_viewManager->getPlaybackFrame(); | 2626 sv_frame_t frame = m_viewManager->getPlaybackFrame(); |
2613 ++frame; | 2627 ++frame; |
2614 | 2628 |
2615 Pane *pane = m_paneStack->getCurrentPane(); | 2629 Pane *pane = m_paneStack->getCurrentPane(); |
2616 Layer *layer = getSnapLayer(); | 2630 Layer *layer = getSnapLayer(); |
2617 int sr = getMainModel()->getSampleRate(); | 2631 sv_samplerate_t sr = getMainModel()->getSampleRate(); |
2618 | 2632 |
2619 if (!layer) { | 2633 if (!layer) { |
2620 | 2634 |
2621 frame = RealTime::realTime2Frame | 2635 frame = RealTime::realTime2Frame |
2622 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr); | 2636 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr); |
2623 if (frame > int(getMainModel()->getEndFrame())) { | 2637 if (frame > getMainModel()->getEndFrame()) { |
2624 frame = getMainModel()->getEndFrame(); | 2638 frame = getMainModel()->getEndFrame(); |
2625 } | 2639 } |
2626 | 2640 |
2627 } else { | 2641 } else { |
2628 | 2642 |
2637 } | 2651 } |
2638 | 2652 |
2639 if (frame < 0) frame = 0; | 2653 if (frame < 0) frame = 0; |
2640 | 2654 |
2641 if (m_viewManager->getPlaySelectionMode()) { | 2655 if (m_viewManager->getPlaySelectionMode()) { |
2642 frame = m_viewManager->constrainFrameToSelection(int(frame)); | 2656 frame = m_viewManager->constrainFrameToSelection(frame); |
2643 } | 2657 } |
2644 | 2658 |
2645 m_viewManager->setPlaybackFrame(frame); | 2659 m_viewManager->setPlaybackFrame(frame); |
2646 | 2660 |
2647 if (frame == (int)getMainModel()->getEndFrame() && | 2661 if (frame == getMainModel()->getEndFrame() && |
2648 m_playSource && | 2662 m_playSource && |
2649 m_playSource->isPlaying() && | 2663 m_playSource->isPlaying() && |
2650 !m_viewManager->getPlayLoopMode()) { | 2664 !m_viewManager->getPlayLoopMode()) { |
2651 stop(); | 2665 stop(); |
2652 } | 2666 } |
2661 m_playSource->isPlaying() && | 2675 m_playSource->isPlaying() && |
2662 !m_viewManager->getPlayLoopMode()) { | 2676 !m_viewManager->getPlayLoopMode()) { |
2663 stop(); | 2677 stop(); |
2664 } | 2678 } |
2665 | 2679 |
2666 int frame = getMainModel()->getEndFrame(); | 2680 sv_frame_t frame = getMainModel()->getEndFrame(); |
2667 | 2681 |
2668 if (m_viewManager->getPlaySelectionMode()) { | 2682 if (m_viewManager->getPlaySelectionMode()) { |
2669 frame = m_viewManager->constrainFrameToSelection(frame); | 2683 frame = m_viewManager->constrainFrameToSelection(frame); |
2670 } | 2684 } |
2671 | 2685 |
2679 | 2693 |
2680 Layer *layer = getSnapLayer(); | 2694 Layer *layer = getSnapLayer(); |
2681 if (!layer) { ffwd(); return; } | 2695 if (!layer) { ffwd(); return; } |
2682 | 2696 |
2683 Pane *pane = m_paneStack->getCurrentPane(); | 2697 Pane *pane = m_paneStack->getCurrentPane(); |
2684 int frame = m_viewManager->getPlaybackFrame(); | 2698 sv_frame_t frame = m_viewManager->getPlaybackFrame(); |
2685 | 2699 |
2686 int resolution = 0; | 2700 int resolution = 0; |
2687 if (pane) frame = pane->alignFromReference(frame); | 2701 if (pane) frame = pane->alignFromReference(frame); |
2688 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), | 2702 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), |
2689 frame, resolution, Layer::SnapRight)) { | 2703 frame, resolution, Layer::SnapRight)) { |
2693 } | 2707 } |
2694 | 2708 |
2695 if (frame < 0) frame = 0; | 2709 if (frame < 0) frame = 0; |
2696 | 2710 |
2697 if (m_viewManager->getPlaySelectionMode()) { | 2711 if (m_viewManager->getPlaySelectionMode()) { |
2698 frame = m_viewManager->constrainFrameToSelection(int(frame)); | 2712 frame = m_viewManager->constrainFrameToSelection(frame); |
2699 } | 2713 } |
2700 | 2714 |
2701 m_viewManager->setPlaybackFrame(frame); | 2715 m_viewManager->setPlaybackFrame(frame); |
2702 | 2716 |
2703 if (frame == (int)getMainModel()->getEndFrame() && | 2717 if (frame == getMainModel()->getEndFrame() && |
2704 m_playSource && | 2718 m_playSource && |
2705 m_playSource->isPlaying() && | 2719 m_playSource->isPlaying() && |
2706 !m_viewManager->getPlayLoopMode()) { | 2720 !m_viewManager->getPlayLoopMode()) { |
2707 stop(); | 2721 stop(); |
2708 } | 2722 } |
2711 void | 2725 void |
2712 MainWindowBase::rewind() | 2726 MainWindowBase::rewind() |
2713 { | 2727 { |
2714 if (!getMainModel()) return; | 2728 if (!getMainModel()) return; |
2715 | 2729 |
2716 int frame = m_viewManager->getPlaybackFrame(); | 2730 sv_frame_t frame = m_viewManager->getPlaybackFrame(); |
2717 if (frame > 0) --frame; | 2731 if (frame > 0) --frame; |
2718 | 2732 |
2719 Pane *pane = m_paneStack->getCurrentPane(); | 2733 Pane *pane = m_paneStack->getCurrentPane(); |
2720 Layer *layer = getSnapLayer(); | 2734 Layer *layer = getSnapLayer(); |
2721 int sr = getMainModel()->getSampleRate(); | 2735 sv_samplerate_t sr = getMainModel()->getSampleRate(); |
2722 | 2736 |
2723 // when rewinding during playback, we want to allow a period | 2737 // when rewinding during playback, we want to allow a period |
2724 // following a rewind target point at which the rewind will go to | 2738 // following a rewind target point at which the rewind will go to |
2725 // the prior point instead of the immediately neighbouring one | 2739 // the prior point instead of the immediately neighbouring one |
2726 if (m_playSource && m_playSource->isPlaying()) { | 2740 if (m_playSource && m_playSource->isPlaying()) { |
2732 | 2746 |
2733 if (!layer) { | 2747 if (!layer) { |
2734 | 2748 |
2735 frame = RealTime::realTime2Frame | 2749 frame = RealTime::realTime2Frame |
2736 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr); | 2750 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr); |
2737 if (frame < int(getMainModel()->getStartFrame())) { | 2751 if (frame < getMainModel()->getStartFrame()) { |
2738 frame = getMainModel()->getStartFrame(); | 2752 frame = getMainModel()->getStartFrame(); |
2739 } | 2753 } |
2740 | 2754 |
2741 } else { | 2755 } else { |
2742 | 2756 |
2751 } | 2765 } |
2752 | 2766 |
2753 if (frame < 0) frame = 0; | 2767 if (frame < 0) frame = 0; |
2754 | 2768 |
2755 if (m_viewManager->getPlaySelectionMode()) { | 2769 if (m_viewManager->getPlaySelectionMode()) { |
2756 frame = m_viewManager->constrainFrameToSelection(int(frame)); | 2770 frame = m_viewManager->constrainFrameToSelection(frame); |
2757 } | 2771 } |
2758 | 2772 |
2759 m_viewManager->setPlaybackFrame(frame); | 2773 m_viewManager->setPlaybackFrame(frame); |
2760 } | 2774 } |
2761 | 2775 |
2762 void | 2776 void |
2763 MainWindowBase::rewindStart() | 2777 MainWindowBase::rewindStart() |
2764 { | 2778 { |
2765 if (!getMainModel()) return; | 2779 if (!getMainModel()) return; |
2766 | 2780 |
2767 int frame = getMainModel()->getStartFrame(); | 2781 sv_frame_t frame = getMainModel()->getStartFrame(); |
2768 | 2782 |
2769 if (m_viewManager->getPlaySelectionMode()) { | 2783 if (m_viewManager->getPlaySelectionMode()) { |
2770 frame = m_viewManager->constrainFrameToSelection(frame); | 2784 frame = m_viewManager->constrainFrameToSelection(frame); |
2771 } | 2785 } |
2772 | 2786 |
2780 | 2794 |
2781 Layer *layer = getSnapLayer(); | 2795 Layer *layer = getSnapLayer(); |
2782 if (!layer) { rewind(); return; } | 2796 if (!layer) { rewind(); return; } |
2783 | 2797 |
2784 Pane *pane = m_paneStack->getCurrentPane(); | 2798 Pane *pane = m_paneStack->getCurrentPane(); |
2785 int frame = m_viewManager->getPlaybackFrame(); | 2799 sv_frame_t frame = m_viewManager->getPlaybackFrame(); |
2786 | 2800 |
2787 int resolution = 0; | 2801 int resolution = 0; |
2788 if (pane) frame = pane->alignFromReference(frame); | 2802 if (pane) frame = pane->alignFromReference(frame); |
2789 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), | 2803 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), |
2790 frame, resolution, Layer::SnapLeft)) { | 2804 frame, resolution, Layer::SnapLeft)) { |
2794 } | 2808 } |
2795 | 2809 |
2796 if (frame < 0) frame = 0; | 2810 if (frame < 0) frame = 0; |
2797 | 2811 |
2798 if (m_viewManager->getPlaySelectionMode()) { | 2812 if (m_viewManager->getPlaySelectionMode()) { |
2799 frame = m_viewManager->constrainFrameToSelection(int(frame)); | 2813 frame = m_viewManager->constrainFrameToSelection(frame); |
2800 } | 2814 } |
2801 | 2815 |
2802 m_viewManager->setPlaybackFrame(frame); | 2816 m_viewManager->setPlaybackFrame(frame); |
2803 } | 2817 } |
2804 | 2818 |
3007 | 3021 |
3008 void | 3022 void |
3009 MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog) | 3023 MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog) |
3010 { | 3024 { |
3011 connect(m_viewManager, | 3025 connect(m_viewManager, |
3012 SIGNAL(globalCentreFrameChanged(int)), | 3026 SIGNAL(globalCentreFrameChanged(sv_frame_t)), |
3013 dialog, | 3027 dialog, |
3014 SLOT(userScrolledToFrame(int))); | 3028 SLOT(userScrolledToFrame(sv_frame_t))); |
3015 | 3029 |
3016 connect(m_viewManager, | 3030 connect(m_viewManager, |
3017 SIGNAL(playbackFrameChanged(int)), | 3031 SIGNAL(playbackFrameChanged(sv_frame_t)), |
3018 dialog, | 3032 dialog, |
3019 SLOT(playbackScrolledToFrame(int))); | 3033 SLOT(playbackScrolledToFrame(sv_frame_t))); |
3020 | 3034 |
3021 connect(dialog, | 3035 connect(dialog, |
3022 SIGNAL(scrollToFrame(int)), | 3036 SIGNAL(scrollToFrame(sv_frame_t)), |
3023 m_viewManager, | 3037 m_viewManager, |
3024 SLOT(setGlobalCentreFrame(int))); | 3038 SLOT(setGlobalCentreFrame(sv_frame_t))); |
3025 | 3039 |
3026 connect(dialog, | 3040 connect(dialog, |
3027 SIGNAL(scrollToFrame(int)), | 3041 SIGNAL(scrollToFrame(sv_frame_t)), |
3028 m_viewManager, | 3042 m_viewManager, |
3029 SLOT(setPlaybackFrame(int))); | 3043 SLOT(setPlaybackFrame(sv_frame_t))); |
3030 } | 3044 } |
3031 | 3045 |
3032 void | 3046 void |
3033 MainWindowBase::previousPane() | 3047 MainWindowBase::previousPane() |
3034 { | 3048 { |
3134 | 3148 |
3135 updateMenuStates(); | 3149 updateMenuStates(); |
3136 } | 3150 } |
3137 | 3151 |
3138 void | 3152 void |
3139 MainWindowBase::playbackFrameChanged(int frame) | 3153 MainWindowBase::playbackFrameChanged(sv_frame_t frame) |
3140 { | 3154 { |
3141 if (!(m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; | 3155 if (!(m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; |
3142 | 3156 |
3143 updatePositionStatusDisplays(); | 3157 updatePositionStatusDisplays(); |
3144 | 3158 |
3170 | 3184 |
3171 getStatusLabel()->setText(m_myStatusMessage); | 3185 getStatusLabel()->setText(m_myStatusMessage); |
3172 } | 3186 } |
3173 | 3187 |
3174 void | 3188 void |
3175 MainWindowBase::globalCentreFrameChanged(int ) | 3189 MainWindowBase::globalCentreFrameChanged(sv_frame_t ) |
3176 { | 3190 { |
3177 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; | 3191 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; |
3178 Pane *p = 0; | 3192 Pane *p = 0; |
3179 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; | 3193 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; |
3180 if (!p->getFollowGlobalPan()) return; | 3194 if (!p->getFollowGlobalPan()) return; |
3181 updateVisibleRangeDisplay(p); | 3195 updateVisibleRangeDisplay(p); |
3182 } | 3196 } |
3183 | 3197 |
3184 void | 3198 void |
3185 MainWindowBase::viewCentreFrameChanged(View *v, int frame) | 3199 MainWindowBase::viewCentreFrameChanged(View *v, sv_frame_t frame) |
3186 { | 3200 { |
3187 // SVDEBUG << "MainWindowBase::viewCentreFrameChanged(" << v << "," << frame << ")" << endl; | 3201 // SVDEBUG << "MainWindowBase::viewCentreFrameChanged(" << v << "," << frame << ")" << endl; |
3188 | 3202 |
3189 if (m_viewDataDialogMap.find(v) != m_viewDataDialogMap.end()) { | 3203 if (m_viewDataDialogMap.find(v) != m_viewDataDialogMap.end()) { |
3190 for (DataDialogSet::iterator i = m_viewDataDialogMap[v].begin(); | 3204 for (DataDialogSet::iterator i = m_viewDataDialogMap[v].begin(); |