diff src/MainWindow.cpp @ 128:06f9caf5928d

Initial hack for switching visibility & audibility of layers on and off. This doesn't work well.
author Chris Cannam
date Thu, 09 Jan 2014 14:05:20 +0000
parents f2b8cff703ed
children eae80729b665
line wrap: on
line diff
--- a/src/MainWindow.cpp	Thu Jan 09 14:00:52 2014 +0000
+++ b/src/MainWindow.cpp	Thu Jan 09 14:05:20 2014 +0000
@@ -71,6 +71,7 @@
 #include <QPushButton>
 #include <QSettings>
 #include <QScrollArea>
+#include <QPainter>
 
 #include <iostream>
 #include <cstdio>
@@ -216,6 +217,8 @@
     frame->setLayout(layout);
 
     m_analyser = new Analyser();
+    connect(m_analyser, SIGNAL(layersChanged()),
+            this, SLOT(updateLayerStatuses()));
 
     setupMenus();
     setupToolbars();
@@ -661,6 +664,31 @@
     toolbar->addWidget(m_playSpeed);
     toolbar->addWidget(m_fader);
 
+    toolbar = addToolBar(tr("Show and Play"));
+    
+    QAction *cycleWaveformAction = toolbar->addAction(tr("Audio"));
+    //!!! shortcut etc
+    connect(cycleWaveformAction, SIGNAL(triggered()), this, SLOT(cycleWaveform()));
+
+    m_waveformStatus = new QLabel();
+    toolbar->addWidget(m_waveformStatus);
+    
+    QAction *cyclePitchAction = toolbar->addAction(tr("Pitch"));
+    //!!! shortcut etc
+    connect(cyclePitchAction, SIGNAL(triggered()), this, SLOT(cyclePitch()));
+
+    m_pitchStatus = new QLabel();
+    toolbar->addWidget(m_pitchStatus);
+    
+    QAction *cycleNotesAction = toolbar->addAction(tr("Notes"));
+    //!!! shortcut etc
+    connect(cycleNotesAction, SIGNAL(triggered()), this, SLOT(cycleNotes()));
+
+    m_notesStatus = new QLabel();
+    toolbar->addWidget(m_notesStatus);
+
+    updateLayerStatuses();
+
     Pane::registerShortcuts(*m_keyReference);
 }
 
@@ -742,6 +770,54 @@
 }
 
 void
+MainWindow::updateLayerStatuses()
+{
+    IconLoader il;
+    QPixmap eye = il.loadPixmap("eye");
+    QPixmap speaker = il.loadPixmap("speaker");
+
+    // NB these need to be in the same order as the Analyser::Component enum
+    QLabel *statuses[] = { m_waveformStatus, m_pitchStatus, m_notesStatus };
+
+    for (int i = 0; i < sizeof(statuses)/sizeof(statuses[0]); ++i) {
+        QPixmap p(40, 16);
+        p.fill(QColor(0, 0, 0, 0));
+        QPainter paint(&p);
+        if (m_analyser->isVisible((Analyser::Component)i)) {
+            paint.drawPixmap(0, 0, eye);
+        }
+        if (m_analyser->isAudible((Analyser::Component)i)) {
+            paint.drawPixmap(20, 0, speaker);
+        }
+        statuses[i]->setPixmap(p);
+    }
+}    
+
+void
+MainWindow::cycleWaveform()
+{
+    cerr << "cycleWaveform" << endl;
+    m_analyser->cycleStatus(Analyser::Audio);
+    updateLayerStatuses();
+}
+
+void
+MainWindow::cyclePitch()
+{
+    cerr << "cyclePitch" << endl;
+    m_analyser->cycleStatus(Analyser::PitchTrack);
+    updateLayerStatuses();
+}
+
+void
+MainWindow::cycleNotes()
+{
+    cerr << "cycleNotes" << endl;
+    m_analyser->cycleStatus(Analyser::Notes);
+    updateLayerStatuses();
+}
+
+void
 MainWindow::updateDescriptionLabel()
 {
     // Nothing, we don't have one