comparison framework/MainWindowBase.cpp @ 100:22bf057ea151 1.2-stable

* merge from trunk (1.2 ended up being tracked from trunk, but we may want this branch for fixes later)
author Chris Cannam
date Wed, 27 Feb 2008 10:32:45 +0000
parents a8acc7841d70
children
comparison
equal deleted inserted replaced
71:a8acc7841d70 100:22bf057ea151
275 Pane *currentPane = 0; 275 Pane *currentPane = 0;
276 Layer *currentLayer = 0; 276 Layer *currentLayer = 0;
277 277
278 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); 278 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
279 if (currentPane) currentLayer = currentPane->getSelectedLayer(); 279 if (currentPane) currentLayer = currentPane->getSelectedLayer();
280
281 bool havePrevPane = false, haveNextPane = false;
282 bool havePrevLayer = false, haveNextLayer = false;
283
284 if (currentPane) {
285 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
286 if (m_paneStack->getPane(i) == currentPane) {
287 if (i > 0) havePrevPane = true;
288 if (i < m_paneStack->getPaneCount()-1) haveNextPane = true;
289 break;
290 }
291 }
292 if (currentLayer) {
293 for (int i = 0; i < currentPane->getLayerCount(); ++i) {
294 if (currentPane->getLayer(i) == currentLayer) {
295 if (i > 0) havePrevLayer = true;
296 if (i < currentPane->getLayerCount()-1) haveNextLayer = true;
297 break;
298 }
299 }
300 }
301 }
280 302
281 bool haveCurrentPane = 303 bool haveCurrentPane =
282 (currentPane != 0); 304 (currentPane != 0);
283 bool haveCurrentLayer = 305 bool haveCurrentLayer =
284 (haveCurrentPane && 306 (haveCurrentPane &&
320 emit canMeasureLayer(haveCurrentLayer); 342 emit canMeasureLayer(haveCurrentLayer);
321 emit canSelect(haveMainModel && haveCurrentPane); 343 emit canSelect(haveMainModel && haveCurrentPane);
322 emit canPlay(havePlayTarget); 344 emit canPlay(havePlayTarget);
323 emit canFfwd(true); 345 emit canFfwd(true);
324 emit canRewind(true); 346 emit canRewind(true);
325 emit canPaste(haveCurrentEditableLayer && haveClipboardContents); 347 emit canPaste(haveClipboardContents);
326 emit canInsertInstant(haveCurrentPane); 348 emit canInsertInstant(haveCurrentPane);
327 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); 349 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection);
328 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection); 350 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection);
329 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection); 351 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
330 emit canClearSelection(haveSelection); 352 emit canClearSelection(haveSelection);
331 emit canEditSelection(haveSelection && haveCurrentEditableLayer); 353 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
332 emit canSave(m_sessionFile != "" && m_documentModified); 354 emit canSave(m_sessionFile != "" && m_documentModified);
355 emit canSelectPreviousPane(havePrevPane);
356 emit canSelectNextPane(haveNextPane);
357 emit canSelectPreviousLayer(havePrevLayer);
358 emit canSelectNextLayer(haveNextLayer);
333 } 359 }
334 360
335 void 361 void
336 MainWindowBase::documentModified() 362 MainWindowBase::documentModified()
337 { 363 {
421 if (m_viewManager) m_viewManager->setPlaybackModel(0); 447 if (m_viewManager) m_viewManager->setPlaybackModel(0);
422 return; 448 return;
423 } 449 }
424 450
425 Model *prevPlaybackModel = m_viewManager->getPlaybackModel(); 451 Model *prevPlaybackModel = m_viewManager->getPlaybackModel();
426 int frame = m_playSource->getCurrentPlayingFrame(); 452
427 453 // What we want here is not the currently playing frame (unless we
428 std::cerr << "playing frame (in ref model) = " << frame << std::endl; 454 // are about to clear out the audio playback buffers -- which may
455 // or may not be possible, depending on the audio driver). What
456 // we want is the frame that was last committed to the soundcard
457 // buffers, as the audio driver will continue playing up to that
458 // frame before switching to whichever one we decide we want to
459 // switch to, regardless of our efforts.
460
461 int frame = m_playSource->getCurrentBufferedFrame();
462
463 // std::cerr << "currentPaneChanged: current frame (in ref model) = " << frame << std::endl;
429 464
430 View::ModelSet soloModels = p->getModels(); 465 View::ModelSet soloModels = p->getModels();
431 466
432 View::ModelSet sources; 467 View::ModelSet sources;
433 for (View::ModelSet::iterator mi = soloModels.begin(); 468 for (View::ModelSet::iterator mi = soloModels.begin();
460 getPlaybackModel()); 495 getPlaybackModel());
461 496
462 m_playSource->setSoloModelSet(soloModels); 497 m_playSource->setSoloModelSet(soloModels);
463 498
464 if (a && b && (a != b)) { 499 if (a && b && (a != b)) {
465 /*!!!
466 int rframe = a->alignToReference(frame);
467 int bframe = b->alignFromReference(rframe);
468 if (m_playSource->isPlaying()) m_playSource->play(bframe);
469 */
470 if (m_playSource->isPlaying()) m_playSource->play(frame); 500 if (m_playSource->isPlaying()) m_playSource->play(frame);
471 } 501 }
472 } 502 }
473 503
474 void 504 void
544 574
545 CommandHistory::getInstance()->startCompoundOperation(tr("Cut"), true); 575 CommandHistory::getInstance()->startCompoundOperation(tr("Cut"), true);
546 576
547 for (MultiSelection::SelectionList::iterator i = selections.begin(); 577 for (MultiSelection::SelectionList::iterator i = selections.begin();
548 i != selections.end(); ++i) { 578 i != selections.end(); ++i) {
549 layer->copy(*i, clipboard); 579 layer->copy(currentPane, *i, clipboard);
550 layer->deleteSelection(*i); 580 layer->deleteSelection(*i);
551 } 581 }
552 582
553 CommandHistory::getInstance()->endCompoundOperation(); 583 CommandHistory::getInstance()->endCompoundOperation();
554 } 584 }
567 597
568 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 598 MultiSelection::SelectionList selections = m_viewManager->getSelections();
569 599
570 for (MultiSelection::SelectionList::iterator i = selections.begin(); 600 for (MultiSelection::SelectionList::iterator i = selections.begin();
571 i != selections.end(); ++i) { 601 i != selections.end(); ++i) {
572 layer->copy(*i, clipboard); 602 layer->copy(currentPane, *i, clipboard);
573 } 603 }
574 } 604 }
575 605
576 void 606 void
577 MainWindowBase::paste() 607 MainWindowBase::paste()
578 { 608 {
579 Pane *currentPane = m_paneStack->getCurrentPane(); 609 Pane *currentPane = m_paneStack->getCurrentPane();
580 if (!currentPane) return; 610 if (!currentPane) return;
581 611
582 //!!! if we have no current layer, we should create one of the most
583 // appropriate type
584
585 Layer *layer = currentPane->getSelectedLayer(); 612 Layer *layer = currentPane->getSelectedLayer();
586 if (!layer) return;
587 613
588 Clipboard &clipboard = m_viewManager->getClipboard(); 614 Clipboard &clipboard = m_viewManager->getClipboard();
589 Clipboard::PointList contents = clipboard.getPoints(); 615 // Clipboard::PointList contents = clipboard.getPoints();
590 /* 616
591 long minFrame = 0; 617 bool inCompound = false;
592 bool have = false; 618
593 for (int i = 0; i < contents.size(); ++i) { 619 if (!layer || !layer->isLayerEditable()) {
594 if (!contents[i].haveFrame()) continue; 620
595 if (!have || contents[i].getFrame() < minFrame) { 621 CommandHistory::getInstance()->startCompoundOperation
596 minFrame = contents[i].getFrame(); 622 (tr("Paste"), true);
597 have = true; 623
598 } 624 // no suitable current layer: create one of the most
599 } 625 // appropriate sort
600 626 LayerFactory::LayerType type =
601 long frameOffset = long(m_viewManager->getGlobalCentreFrame()) - minFrame; 627 LayerFactory::getInstance()->getLayerTypeForClipboardContents(clipboard);
602 628 layer = m_document->createEmptyLayer(type);
603 layer->paste(clipboard, frameOffset); 629
604 */ 630 if (!layer) {
605 layer->paste(clipboard, 0, true); 631 CommandHistory::getInstance()->endCompoundOperation();
632 return;
633 }
634
635 m_document->addLayerToView(currentPane, layer);
636 m_paneStack->setCurrentLayer(currentPane, layer);
637
638 inCompound = true;
639 }
640
641 layer->paste(currentPane, clipboard, 0, true);
642
643 if (inCompound) CommandHistory::getInstance()->endCompoundOperation();
606 } 644 }
607 645
608 void 646 void
609 MainWindowBase::deleteSelected() 647 MainWindowBase::deleteSelected()
610 { 648 {
658 { 696 {
659 Pane *pane = m_paneStack->getCurrentPane(); 697 Pane *pane = m_paneStack->getCurrentPane();
660 if (!pane) { 698 if (!pane) {
661 return; 699 return;
662 } 700 }
701
702 frame = pane->alignFromReference(frame);
663 703
664 Layer *layer = dynamic_cast<TimeInstantLayer *> 704 Layer *layer = dynamic_cast<TimeInstantLayer *>
665 (pane->getSelectedLayer()); 705 (pane->getSelectedLayer());
666 706
667 if (!layer) { 707 if (!layer) {
695 bool havePrevPoint = false; 735 bool havePrevPoint = false;
696 736
697 SparseOneDimensionalModel::EditCommand *command = 737 SparseOneDimensionalModel::EditCommand *command =
698 new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point")); 738 new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point"));
699 739
700 if (m_labeller->actingOnPrevPoint()) { 740 if (m_labeller->requiresPrevPoint()) {
701 741
702 SparseOneDimensionalModel::PointList prevPoints = 742 SparseOneDimensionalModel::PointList prevPoints =
703 sodm->getPreviousPoints(frame); 743 sodm->getPreviousPoints(frame);
704 744
705 if (!prevPoints.empty()) { 745 if (!prevPoints.empty()) {
710 750
711 if (m_labeller) { 751 if (m_labeller) {
712 752
713 m_labeller->setSampleRate(sodm->getSampleRate()); 753 m_labeller->setSampleRate(sodm->getSampleRate());
714 754
715 if (havePrevPoint) { 755 if (m_labeller->actingOnPrevPoint()) {
716 command->deletePoint(prevPoint); 756 command->deletePoint(prevPoint);
717 } 757 }
718 758
719 m_labeller->label<SparseOneDimensionalModel::Point> 759 m_labeller->label<SparseOneDimensionalModel::Point>
720 (point, havePrevPoint ? &prevPoint : 0); 760 (point, havePrevPoint ? &prevPoint : 0);
721 761
722 if (havePrevPoint) { 762 if (m_labeller->actingOnPrevPoint()) {
723 command->addPoint(prevPoint); 763 command->addPoint(prevPoint);
724 } 764 }
725 } 765 }
726 766
727 command->addPoint(point); 767 command->addPoint(point);
764 } 804 }
765 805
766 MainWindowBase::FileOpenStatus 806 MainWindowBase::FileOpenStatus
767 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode) 807 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode)
768 { 808 {
769 return open(FileSource(fileOrUrl, true), mode); 809 return open(FileSource(fileOrUrl, FileSource::ProgressDialog), mode);
770 } 810 }
771 811
772 MainWindowBase::FileOpenStatus 812 MainWindowBase::FileOpenStatus
773 MainWindowBase::open(FileSource source, AudioFileOpenMode mode) 813 MainWindowBase::open(FileSource source, AudioFileOpenMode mode)
774 { 814 {
1006 bool someSuccess = false; 1046 bool someSuccess = false;
1007 1047
1008 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin(); 1048 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin();
1009 i != playlist.end(); ++i) { 1049 i != playlist.end(); ++i) {
1010 1050
1011 FileOpenStatus status = openAudio(FileSource(*i, true), mode); 1051 FileOpenStatus status = openAudio
1052 (FileSource(*i, FileSource::ProgressDialog), mode);
1012 1053
1013 if (status == FileOpenCancelled) { 1054 if (status == FileOpenCancelled) {
1014 return FileOpenCancelled; 1055 return FileOpenCancelled;
1015 } 1056 }
1016 1057
1057 << "): Failed to open file for reading" << std::endl; 1098 << "): Failed to open file for reading" << std::endl;
1058 return FileOpenFailed; 1099 return FileOpenFailed;
1059 } 1100 }
1060 1101
1061 SVFileReader reader(m_document, callback, source.getLocation()); 1102 SVFileReader reader(m_document, callback, source.getLocation());
1103 connect
1104 (&reader, SIGNAL(modelRegenerationFailed(QString, QString, QString)),
1105 this, SLOT(modelRegenerationFailed(QString, QString, QString)));
1106 connect
1107 (&reader, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
1108 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
1062 reader.setCurrentPane(pane); 1109 reader.setCurrentPane(pane);
1063 1110
1064 QXmlInputSource inputSource(&file); 1111 QXmlInputSource inputSource(&file);
1065 reader.parse(inputSource); 1112 reader.parse(inputSource);
1066 1113
1076 1123
1077 if (!source.isRemote()) { 1124 if (!source.isRemote()) {
1078 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog 1125 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog
1079 } 1126 }
1080 1127
1128 return FileOpenSucceeded;
1129
1081 } else { 1130 } else {
1082 1131
1083 try { 1132 try {
1084 1133
1085 Model *model = DataFileReaderFactory::load 1134 Model *model = DataFileReaderFactory::load
1092 Layer *newLayer = m_document->createImportedLayer(model); 1141 Layer *newLayer = m_document->createImportedLayer(model);
1093 1142
1094 if (newLayer) { 1143 if (newLayer) {
1095 1144
1096 m_document->addLayerToView(pane, newLayer); 1145 m_document->addLayerToView(pane, newLayer);
1146 m_paneStack->setCurrentLayer(pane, newLayer);
1147
1097 m_recentFiles.addFile(source.getLocation()); 1148 m_recentFiles.addFile(source.getLocation());
1098 1149
1099 if (!source.isRemote()) { 1150 if (!source.isRemote()) {
1100 registerLastOpenedFilePath 1151 registerLastOpenedFilePath
1101 (FileFinder::LayerFile, 1152 (FileFinder::LayerFile,
1102 path); // for file dialog 1153 path); // for file dialog
1103 } 1154 }
1104 1155
1105 return FileOpenSucceeded; 1156 return FileOpenSucceeded;
1106 } 1157 }
1107 } 1158 }
1108 } catch (DataFileReaderFactory::Exception e) { 1159 } catch (DataFileReaderFactory::Exception e) {
1109 if (e == DataFileReaderFactory::ImportCancelled) { 1160 if (e == DataFileReaderFactory::ImportCancelled) {
1110 return FileOpenCancelled; 1161 return FileOpenCancelled;
1111 } 1162 }
1112 } 1163 }
1113 } 1164 }
1114 1165
1115 source.setLeaveLocalFile(true);
1116 return FileOpenFailed; 1166 return FileOpenFailed;
1117 } 1167 }
1118 1168
1119 MainWindowBase::FileOpenStatus 1169 MainWindowBase::FileOpenStatus
1120 MainWindowBase::openImage(FileSource source) 1170 MainWindowBase::openImage(FileSource source)
1167 } 1217 }
1168 1218
1169 MainWindowBase::FileOpenStatus 1219 MainWindowBase::FileOpenStatus
1170 MainWindowBase::openSessionFile(QString fileOrUrl) 1220 MainWindowBase::openSessionFile(QString fileOrUrl)
1171 { 1221 {
1172 return openSession(FileSource(fileOrUrl, true)); 1222 return openSession(FileSource(fileOrUrl, FileSource::ProgressDialog));
1173 } 1223 }
1174 1224
1175 MainWindowBase::FileOpenStatus 1225 MainWindowBase::FileOpenStatus
1176 MainWindowBase::openSession(FileSource source) 1226 MainWindowBase::openSession(FileSource source)
1177 { 1227 {
1190 1240
1191 PaneCallback callback(this); 1241 PaneCallback callback(this);
1192 m_viewManager->clearSelections(); 1242 m_viewManager->clearSelections();
1193 1243
1194 SVFileReader reader(m_document, callback, source.getLocation()); 1244 SVFileReader reader(m_document, callback, source.getLocation());
1245 connect
1246 (&reader, SIGNAL(modelRegenerationFailed(QString, QString, QString)),
1247 this, SLOT(modelRegenerationFailed(QString, QString, QString)));
1248 connect
1249 (&reader, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
1250 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
1195 QXmlInputSource inputSource(&bzFile); 1251 QXmlInputSource inputSource(&bzFile);
1196 reader.parse(inputSource); 1252 reader.parse(inputSource);
1197 1253
1198 if (!reader.isOK()) { 1254 if (!reader.isOK()) {
1199 error = tr("SV XML file read error:\n%1").arg(reader.getErrorString()); 1255 error = tr("SV XML file read error:\n%1").arg(reader.getErrorString());
1280 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)), 1336 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)),
1281 this, SLOT(mainModelChanged(WaveFileModel *))); 1337 this, SLOT(mainModelChanged(WaveFileModel *)));
1282 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)), 1338 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
1283 this, SLOT(modelAboutToBeDeleted(Model *))); 1339 this, SLOT(modelAboutToBeDeleted(Model *)));
1284 1340
1285 connect(m_document, SIGNAL(modelGenerationFailed(QString)), 1341 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
1286 this, SLOT(modelGenerationFailed(QString))); 1342 this, SLOT(modelGenerationFailed(QString, QString)));
1287 connect(m_document, SIGNAL(modelRegenerationFailed(QString, QString)), 1343 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
1288 this, SLOT(modelRegenerationFailed(QString, QString))); 1344 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
1345 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
1346 this, SLOT(modelGenerationFailed(QString, QString)));
1347 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
1348 this, SLOT(modelRegenerationWarning(QString, QString, QString)));
1349 connect(m_document, SIGNAL(alignmentFailed(QString, QString)),
1350 this, SLOT(alignmentFailed(QString, QString)));
1289 } 1351 }
1290 1352
1291 bool 1353 bool
1292 MainWindowBase::saveSessionFile(QString path) 1354 MainWindowBase::saveSessionFile(QString path)
1293 { 1355 {
1543 if (!getMainModel()) return; 1605 if (!getMainModel()) return;
1544 1606
1545 int frame = m_viewManager->getPlaybackFrame(); 1607 int frame = m_viewManager->getPlaybackFrame();
1546 ++frame; 1608 ++frame;
1547 1609
1610 Pane *pane = m_paneStack->getCurrentPane();
1548 Layer *layer = getSnapLayer(); 1611 Layer *layer = getSnapLayer();
1549 size_t sr = getMainModel()->getSampleRate(); 1612 size_t sr = getMainModel()->getSampleRate();
1550 1613
1551 if (!layer) { 1614 if (!layer) {
1552 1615
1557 } 1620 }
1558 1621
1559 } else { 1622 } else {
1560 1623
1561 size_t resolution = 0; 1624 size_t resolution = 0;
1562 if (!layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), 1625 if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(),
1563 frame, resolution, Layer::SnapRight)) { 1626 frame, resolution, Layer::SnapRight)) {
1627 if (pane) frame = pane->alignToReference(frame);
1628 } else {
1564 frame = getMainModel()->getEndFrame(); 1629 frame = getMainModel()->getEndFrame();
1565 } 1630 }
1566 } 1631 }
1567 1632
1568 if (frame < 0) frame = 0; 1633 if (frame < 0) frame = 0;
1594 if (!getMainModel()) return; 1659 if (!getMainModel()) return;
1595 1660
1596 int frame = m_viewManager->getPlaybackFrame(); 1661 int frame = m_viewManager->getPlaybackFrame();
1597 if (frame > 0) --frame; 1662 if (frame > 0) --frame;
1598 1663
1664 Pane *pane = m_paneStack->getCurrentPane();
1599 Layer *layer = getSnapLayer(); 1665 Layer *layer = getSnapLayer();
1600 size_t sr = getMainModel()->getSampleRate(); 1666 size_t sr = getMainModel()->getSampleRate();
1601 1667
1602 // when rewinding during playback, we want to allow a period 1668 // when rewinding during playback, we want to allow a period
1603 // following a rewind target point at which the rewind will go to 1669 // following a rewind target point at which the rewind will go to
1620 } 1686 }
1621 1687
1622 } else { 1688 } else {
1623 1689
1624 size_t resolution = 0; 1690 size_t resolution = 0;
1625 if (!layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), 1691 if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(),
1626 frame, resolution, Layer::SnapLeft)) { 1692 frame, resolution, Layer::SnapLeft)) {
1693
1694 if (pane) frame = pane->alignToReference(frame);
1695 } else {
1627 frame = getMainModel()->getStartFrame(); 1696 frame = getMainModel()->getStartFrame();
1628 } 1697 }
1629 } 1698 }
1630 1699
1631 if (frame < 0) frame = 0; 1700 if (frame < 0) frame = 0;
1807 if (layer) { 1876 if (layer) {
1808 m_document->removeLayerFromView(pane, layer); 1877 m_document->removeLayerFromView(pane, layer);
1809 } 1878 }
1810 } 1879 }
1811 updateMenuStates(); 1880 updateMenuStates();
1881 }
1882
1883 void
1884 MainWindowBase::previousPane()
1885 {
1886 if (!m_paneStack) return;
1887
1888 Pane *currentPane = m_paneStack->getCurrentPane();
1889 if (!currentPane) return;
1890
1891 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
1892 if (m_paneStack->getPane(i) == currentPane) {
1893 if (i == 0) return;
1894 m_paneStack->setCurrentPane(m_paneStack->getPane(i-1));
1895 updateMenuStates();
1896 return;
1897 }
1898 }
1899 }
1900
1901 void
1902 MainWindowBase::nextPane()
1903 {
1904 if (!m_paneStack) return;
1905
1906 Pane *currentPane = m_paneStack->getCurrentPane();
1907 if (!currentPane) return;
1908
1909 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
1910 if (m_paneStack->getPane(i) == currentPane) {
1911 if (i == m_paneStack->getPaneCount()-1) return;
1912 m_paneStack->setCurrentPane(m_paneStack->getPane(i+1));
1913 updateMenuStates();
1914 return;
1915 }
1916 }
1917 }
1918
1919 void
1920 MainWindowBase::previousLayer()
1921 {
1922 //!!! Not right -- pane lists layers in stacking order
1923
1924 if (!m_paneStack) return;
1925
1926 Pane *currentPane = m_paneStack->getCurrentPane();
1927 if (!currentPane) return;
1928
1929 Layer *currentLayer = currentPane->getSelectedLayer();
1930 if (!currentLayer) return;
1931
1932 for (int i = 0; i < currentPane->getLayerCount(); ++i) {
1933 if (currentPane->getLayer(i) == currentLayer) {
1934 if (i == 0) return;
1935 m_paneStack->setCurrentLayer(currentPane,
1936 currentPane->getLayer(i-1));
1937 updateMenuStates();
1938 return;
1939 }
1940 }
1941 }
1942
1943 void
1944 MainWindowBase::nextLayer()
1945 {
1946 //!!! Not right -- pane lists layers in stacking order
1947
1948 if (!m_paneStack) return;
1949
1950 Pane *currentPane = m_paneStack->getCurrentPane();
1951 if (!currentPane) return;
1952
1953 Layer *currentLayer = currentPane->getSelectedLayer();
1954 if (!currentLayer) return;
1955
1956 for (int i = 0; i < currentPane->getLayerCount(); ++i) {
1957 if (currentPane->getLayer(i) == currentLayer) {
1958 if (i == currentPane->getLayerCount()-1) return;
1959 m_paneStack->setCurrentLayer(currentPane,
1960 currentPane->getLayer(i+1));
1961 updateMenuStates();
1962 return;
1963 }
1964 }
1812 } 1965 }
1813 1966
1814 void 1967 void
1815 MainWindowBase::playbackFrameChanged(unsigned long frame) 1968 MainWindowBase::playbackFrameChanged(unsigned long frame)
1816 { 1969 {