changeset 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
files document/Document.cpp main/MainWindow.cpp main/MainWindow.h
diffstat 3 files changed, 56 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/document/Document.cpp	Wed Mar 07 17:07:02 2007 +0000
+++ b/document/Document.cpp	Wed Mar 07 18:00:49 2007 +0000
@@ -26,6 +26,7 @@
 #include "base/PlayParameterRepository.h"
 #include "base/PlayParameters.h"
 #include "transform/TransformFactory.h"
+#include <QApplication>
 #include <iostream>
 
 //!!! still need to handle command history, documentRestored/documentModified
@@ -643,7 +644,7 @@
     m_d(d),
     m_view(view),
     m_layer(layer),
-    m_name(qApp->translate("Add %1 Layer").arg(layer->objectName())),
+    m_name(qApp->translate("AddLayerCommand", "Add %1 Layer").arg(layer->objectName())),
     m_added(false)
 {
 }
@@ -691,7 +692,7 @@
     m_d(d),
     m_view(view),
     m_layer(layer),
-    m_name(qApp->translate("Delete %1 Layer").arg(layer->objectName())),
+    m_name(qApp->translate("RemoveLayerCommand", "Delete %1 Layer").arg(layer->objectName())),
     m_added(true)
 {
 }
--- a/main/MainWindow.cpp	Wed Mar 07 17:07:02 2007 +0000
+++ b/main/MainWindow.cpp	Wed Mar 07 18:00:49 2007 +0000
@@ -147,6 +147,8 @@
     m_viewManager = new ViewManager();
     connect(m_viewManager, SIGNAL(selectionChanged()),
 	    this, SLOT(updateMenuStates()));
+    connect(m_viewManager, SIGNAL(inProgressSelectionChanged()),
+	    this, SLOT(inProgressSelectionChanged()));
 
     m_descriptionLabel = new QLabel;
 
@@ -1571,12 +1573,17 @@
 void
 MainWindow::updateMenuStates()
 {
+    Pane *currentPane = 0;
+    Layer *currentLayer = 0;
+
+    if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
+    if (currentPane) currentLayer = currentPane->getSelectedLayer();
+
     bool haveCurrentPane =
-	(m_paneStack &&
-	 (m_paneStack->getCurrentPane() != 0));
+        (currentPane != 0);
     bool haveCurrentLayer =
-	(haveCurrentPane &&
-	 (m_paneStack->getCurrentPane()->getSelectedLayer()));
+        (haveCurrentPane &&
+         (currentLayer != 0));
     bool haveMainModel =
 	(getMainModel() != 0);
     bool havePlayTarget =
@@ -1586,20 +1593,16 @@
 	 !m_viewManager->getSelections().empty());
     bool haveCurrentEditableLayer =
 	(haveCurrentLayer &&
-	 m_paneStack->getCurrentPane()->getSelectedLayer()->
-	 isLayerEditable());
+	 currentLayer->isLayerEditable());
     bool haveCurrentTimeInstantsLayer = 
 	(haveCurrentLayer &&
-	 dynamic_cast<TimeInstantLayer *>
-	 (m_paneStack->getCurrentPane()->getSelectedLayer()));
+	 dynamic_cast<TimeInstantLayer *>(currentLayer));
     bool haveCurrentTimeValueLayer = 
 	(haveCurrentLayer &&
-	 dynamic_cast<TimeValueLayer *>
-	 (m_paneStack->getCurrentPane()->getSelectedLayer()));
+	 dynamic_cast<TimeValueLayer *>(currentLayer));
     bool haveCurrentColour3DPlot =
         (haveCurrentLayer &&
-         dynamic_cast<Colour3DPlotLayer *>
-         (m_paneStack->getCurrentPane()->getSelectedLayer()));
+         dynamic_cast<Colour3DPlotLayer *>(currentLayer));
     bool haveClipboardContents =
         (m_viewManager &&
          !m_viewManager->getClipboard().empty());
@@ -3709,11 +3712,31 @@
         return;
     }
 
+    bool haveSelection = false;
+    size_t startFrame = 0, endFrame = 0;
+
+    if (m_viewManager && m_viewManager->haveInProgressSelection()) {
+
+        bool exclusive = false;
+        Selection s = m_viewManager->getInProgressSelection(exclusive);
+
+        if (!s.isEmpty()) {
+            haveSelection = true;
+            startFrame = s.getStartFrame();
+            endFrame = s.getEndFrame();
+        }
+    }
+
+    if (!haveSelection) {
+        startFrame = p->getFirstVisibleFrame();
+        endFrame = p->getLastVisibleFrame();
+    }
+
     RealTime start = RealTime::frame2RealTime
-        (p->getFirstVisibleFrame(), getMainModel()->getSampleRate());
+        (startFrame, getMainModel()->getSampleRate());
 
     RealTime end = RealTime::frame2RealTime
-        (p->getLastVisibleFrame(), getMainModel()->getSampleRate());
+        (endFrame, getMainModel()->getSampleRate());
 
     RealTime duration = end - start;
 
@@ -3722,8 +3745,13 @@
     endStr = end.toText(true).c_str();
     durationStr = duration.toText(true).c_str();
 
-    m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
-        .arg(startStr).arg(endStr).arg(durationStr);
+    if (haveSelection) {
+        m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
+            .arg(startStr).arg(endStr).arg(durationStr);
+    } else {
+        m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
+            .arg(startStr).arg(endStr).arg(durationStr);
+    }
 
     statusBar()->showMessage(m_myStatusMessage);
 }
@@ -4444,6 +4472,14 @@
 }
 
 void
+MainWindow::inProgressSelectionChanged()
+{
+    Pane *currentPane = 0;
+    if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
+    if (currentPane) updateVisibleRangeDisplay(currentPane);
+}
+
+void
 MainWindow::contextHelpChanged(const QString &s)
 {
     if (s == "" && m_myStatusMessage != "") {
--- a/main/MainWindow.h	Wed Mar 07 17:07:02 2007 +0000
+++ b/main/MainWindow.h	Wed Mar 07 18:00:49 2007 +0000
@@ -227,6 +227,7 @@
     void mouseEnteredWidget();
     void mouseLeftWidget();
     void contextHelpChanged(const QString &);
+    void inProgressSelectionChanged();
 
     void website();
     void help();