comparison src/MainWindow.cpp @ 142:edff2113260c

Add octave up/down editing
author Chris Cannam
date Fri, 10 Jan 2014 15:21:13 +0000
parents e7f2da26c9ac
children b5e46f9bceb8
comparison
equal deleted inserted replaced
141:585fe1be1ac0 142:edff2113260c
388 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected())); 388 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
389 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); 389 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
390 group->addAction(action); 390 group->addAction(action);
391 m_keyReference->registerShortcut(action); 391 m_keyReference->registerShortcut(action);
392 */ 392 */
393
394 menu->addSeparator();
395
396 //!!! shortcuts, status tip etc
397 action = new QAction(tr("Octave Shift Up"), this);
398 action->setShortcut(tr("PgUp"));
399 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp()));
400 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
401 menu->addAction(action);
402
403 action = new QAction(tr("Octave Shift Down"), this);
404 action->setShortcut(tr("PgDown"));
405 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown()));
406 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
407 menu->addAction(action);
393 } 408 }
394 409
395 void 410 void
396 MainWindow::setupViewMenu() 411 MainWindow::setupViewMenu()
397 { 412 {
553 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart())); 568 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
554 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool))); 569 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
555 570
556 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"), 571 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
557 tr("Rewind")); 572 tr("Rewind"));
558 m_rwdAction->setShortcut(tr("PgUp"));
559 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch")); 573 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
560 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind())); 574 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
561 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool))); 575 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
562 576
563 QAction *playAction = toolbar->addAction(il.load("playpause"), 577 QAction *playAction = toolbar->addAction(il.load("playpause"),
570 playAction, SLOT(setChecked(bool))); 584 playAction, SLOT(setChecked(bool)));
571 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool))); 585 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
572 586
573 m_ffwdAction = toolbar->addAction(il.load("ffwd"), 587 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
574 tr("Fast Forward")); 588 tr("Fast Forward"));
575 m_ffwdAction->setShortcut(tr("PgDown"));
576 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch")); 589 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
577 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd())); 590 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
578 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool))); 591 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
579 592
580 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"), 593 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
1380 1393
1381 m_viewManager->setSelection(Selection(f0, f1)); 1394 m_viewManager->setSelection(Selection(f0, f1));
1382 } 1395 }
1383 1396
1384 void 1397 void
1398 MainWindow::octaveShiftUp()
1399 {
1400 octaveShift(true);
1401 }
1402
1403 void
1404 MainWindow::octaveShiftDown()
1405 {
1406 octaveShift(false);
1407 }
1408
1409 void
1410 MainWindow::octaveShift(bool up)
1411 {
1412 float factor = (up ? 2.f : 0.5f);
1413
1414 MultiSelection::SelectionList selections = m_viewManager->getSelections();
1415
1416 CommandHistory::getInstance()->startCompoundOperation(tr("Octave Shift"), true);
1417
1418 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
1419
1420 Pane *pane = m_paneStack->getPane(i);
1421 if (!pane) continue;
1422
1423 for (int j = 0; j < pane->getLayerCount(); ++j) {
1424
1425 Layer *layer = pane->getLayer(j);
1426 if (!layer) continue;
1427
1428 for (MultiSelection::SelectionList::iterator k = selections.begin();
1429 k != selections.end(); ++k) {
1430
1431 Clipboard clip;
1432 layer->copy(pane, *k, clip);
1433 layer->deleteSelection(*k);
1434
1435 Clipboard shifted;
1436 foreach (Clipboard::Point p, clip.getPoints()) {
1437 if (p.haveValue()) {
1438 Clipboard::Point sp =
1439 p.withValue(p.getValue() * factor);
1440 shifted.addPoint(sp);
1441 } else {
1442 shifted.addPoint(p);
1443 }
1444 }
1445
1446 layer->paste(pane, shifted, 0, false);
1447 }
1448 }
1449 }
1450
1451 CommandHistory::getInstance()->endCompoundOperation();
1452 }
1453
1454 void
1385 MainWindow::playSpeedChanged(int position) 1455 MainWindow::playSpeedChanged(int position)
1386 { 1456 {
1387 PlaySpeedRangeMapper mapper(0, 200); 1457 PlaySpeedRangeMapper mapper(0, 200);
1388 1458
1389 float percent = m_playSpeed->mappedValue(); 1459 float percent = m_playSpeed->mappedValue();