Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 117:8089a394829a
* Add display of selection extents in status bar when dragging a selection
* Some build fixes after that i18n update
author | Chris Cannam |
---|---|
date | Wed, 07 Mar 2007 18:00:49 +0000 |
parents | 99d65ba33c88 |
children | b4110b17bca8 |
comparison
equal
deleted
inserted
replaced
116:99d65ba33c88 | 117:8089a394829a |
---|---|
145 QGridLayout *layout = new QGridLayout; | 145 QGridLayout *layout = new QGridLayout; |
146 | 146 |
147 m_viewManager = new ViewManager(); | 147 m_viewManager = new ViewManager(); |
148 connect(m_viewManager, SIGNAL(selectionChanged()), | 148 connect(m_viewManager, SIGNAL(selectionChanged()), |
149 this, SLOT(updateMenuStates())); | 149 this, SLOT(updateMenuStates())); |
150 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), | |
151 this, SLOT(inProgressSelectionChanged())); | |
150 | 152 |
151 m_descriptionLabel = new QLabel; | 153 m_descriptionLabel = new QLabel; |
152 | 154 |
153 m_paneStack = new PaneStack(frame, m_viewManager); | 155 m_paneStack = new PaneStack(frame, m_viewManager); |
154 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), | 156 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), |
1569 } | 1571 } |
1570 | 1572 |
1571 void | 1573 void |
1572 MainWindow::updateMenuStates() | 1574 MainWindow::updateMenuStates() |
1573 { | 1575 { |
1576 Pane *currentPane = 0; | |
1577 Layer *currentLayer = 0; | |
1578 | |
1579 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); | |
1580 if (currentPane) currentLayer = currentPane->getSelectedLayer(); | |
1581 | |
1574 bool haveCurrentPane = | 1582 bool haveCurrentPane = |
1575 (m_paneStack && | 1583 (currentPane != 0); |
1576 (m_paneStack->getCurrentPane() != 0)); | |
1577 bool haveCurrentLayer = | 1584 bool haveCurrentLayer = |
1578 (haveCurrentPane && | 1585 (haveCurrentPane && |
1579 (m_paneStack->getCurrentPane()->getSelectedLayer())); | 1586 (currentLayer != 0)); |
1580 bool haveMainModel = | 1587 bool haveMainModel = |
1581 (getMainModel() != 0); | 1588 (getMainModel() != 0); |
1582 bool havePlayTarget = | 1589 bool havePlayTarget = |
1583 (m_playTarget != 0); | 1590 (m_playTarget != 0); |
1584 bool haveSelection = | 1591 bool haveSelection = |
1585 (m_viewManager && | 1592 (m_viewManager && |
1586 !m_viewManager->getSelections().empty()); | 1593 !m_viewManager->getSelections().empty()); |
1587 bool haveCurrentEditableLayer = | 1594 bool haveCurrentEditableLayer = |
1588 (haveCurrentLayer && | 1595 (haveCurrentLayer && |
1589 m_paneStack->getCurrentPane()->getSelectedLayer()-> | 1596 currentLayer->isLayerEditable()); |
1590 isLayerEditable()); | |
1591 bool haveCurrentTimeInstantsLayer = | 1597 bool haveCurrentTimeInstantsLayer = |
1592 (haveCurrentLayer && | 1598 (haveCurrentLayer && |
1593 dynamic_cast<TimeInstantLayer *> | 1599 dynamic_cast<TimeInstantLayer *>(currentLayer)); |
1594 (m_paneStack->getCurrentPane()->getSelectedLayer())); | |
1595 bool haveCurrentTimeValueLayer = | 1600 bool haveCurrentTimeValueLayer = |
1596 (haveCurrentLayer && | 1601 (haveCurrentLayer && |
1597 dynamic_cast<TimeValueLayer *> | 1602 dynamic_cast<TimeValueLayer *>(currentLayer)); |
1598 (m_paneStack->getCurrentPane()->getSelectedLayer())); | |
1599 bool haveCurrentColour3DPlot = | 1603 bool haveCurrentColour3DPlot = |
1600 (haveCurrentLayer && | 1604 (haveCurrentLayer && |
1601 dynamic_cast<Colour3DPlotLayer *> | 1605 dynamic_cast<Colour3DPlotLayer *>(currentLayer)); |
1602 (m_paneStack->getCurrentPane()->getSelectedLayer())); | |
1603 bool haveClipboardContents = | 1606 bool haveClipboardContents = |
1604 (m_viewManager && | 1607 (m_viewManager && |
1605 !m_viewManager->getClipboard().empty()); | 1608 !m_viewManager->getClipboard().empty()); |
1606 | 1609 |
1607 emit canAddPane(haveMainModel); | 1610 emit canAddPane(haveMainModel); |
3707 { | 3710 { |
3708 if (!getMainModel() || !p) { | 3711 if (!getMainModel() || !p) { |
3709 return; | 3712 return; |
3710 } | 3713 } |
3711 | 3714 |
3715 bool haveSelection = false; | |
3716 size_t startFrame = 0, endFrame = 0; | |
3717 | |
3718 if (m_viewManager && m_viewManager->haveInProgressSelection()) { | |
3719 | |
3720 bool exclusive = false; | |
3721 Selection s = m_viewManager->getInProgressSelection(exclusive); | |
3722 | |
3723 if (!s.isEmpty()) { | |
3724 haveSelection = true; | |
3725 startFrame = s.getStartFrame(); | |
3726 endFrame = s.getEndFrame(); | |
3727 } | |
3728 } | |
3729 | |
3730 if (!haveSelection) { | |
3731 startFrame = p->getFirstVisibleFrame(); | |
3732 endFrame = p->getLastVisibleFrame(); | |
3733 } | |
3734 | |
3712 RealTime start = RealTime::frame2RealTime | 3735 RealTime start = RealTime::frame2RealTime |
3713 (p->getFirstVisibleFrame(), getMainModel()->getSampleRate()); | 3736 (startFrame, getMainModel()->getSampleRate()); |
3714 | 3737 |
3715 RealTime end = RealTime::frame2RealTime | 3738 RealTime end = RealTime::frame2RealTime |
3716 (p->getLastVisibleFrame(), getMainModel()->getSampleRate()); | 3739 (endFrame, getMainModel()->getSampleRate()); |
3717 | 3740 |
3718 RealTime duration = end - start; | 3741 RealTime duration = end - start; |
3719 | 3742 |
3720 QString startStr, endStr, durationStr; | 3743 QString startStr, endStr, durationStr; |
3721 startStr = start.toText(true).c_str(); | 3744 startStr = start.toText(true).c_str(); |
3722 endStr = end.toText(true).c_str(); | 3745 endStr = end.toText(true).c_str(); |
3723 durationStr = duration.toText(true).c_str(); | 3746 durationStr = duration.toText(true).c_str(); |
3724 | 3747 |
3725 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)") | 3748 if (haveSelection) { |
3726 .arg(startStr).arg(endStr).arg(durationStr); | 3749 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)") |
3750 .arg(startStr).arg(endStr).arg(durationStr); | |
3751 } else { | |
3752 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)") | |
3753 .arg(startStr).arg(endStr).arg(durationStr); | |
3754 } | |
3727 | 3755 |
3728 statusBar()->showMessage(m_myStatusMessage); | 3756 statusBar()->showMessage(m_myStatusMessage); |
3729 } | 3757 } |
3730 | 3758 |
3731 void | 3759 void |
4439 | 4467 |
4440 void | 4468 void |
4441 MainWindow::mouseLeftWidget() | 4469 MainWindow::mouseLeftWidget() |
4442 { | 4470 { |
4443 contextHelpChanged(""); | 4471 contextHelpChanged(""); |
4472 } | |
4473 | |
4474 void | |
4475 MainWindow::inProgressSelectionChanged() | |
4476 { | |
4477 Pane *currentPane = 0; | |
4478 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); | |
4479 if (currentPane) updateVisibleRangeDisplay(currentPane); | |
4444 } | 4480 } |
4445 | 4481 |
4446 void | 4482 void |
4447 MainWindow::contextHelpChanged(const QString &s) | 4483 MainWindow::contextHelpChanged(const QString &s) |
4448 { | 4484 { |