changeset 70:bf306158803d

* Add stub for item-edit dialog (for editing properties of an item on double- click) -- doesn't actually do anything yet * Add code to invoke said non-working item-edit dialog on double-click in time-value, time-instants and note layers * Add overlay mode (no text, basic text, all text)
author Chris Cannam
date Thu, 30 Mar 2006 15:00:22 +0000
parents 6dad2724f3aa
children 72fa239a4880
files layer/NoteLayer.cpp layer/NoteLayer.h layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeRulerLayer.cpp layer/TimeValueLayer.cpp layer/TimeValueLayer.h widgets/ItemEditDialog.cpp widgets/ItemEditDialog.h widgets/Pane.cpp
diffstat 10 files changed, 567 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/layer/NoteLayer.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/NoteLayer.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -23,6 +23,8 @@
 
 #include "model/NoteModel.h"
 
+#include "widgets/ItemEditDialog.h"
+
 #include "SpectrogramLayer.h" // for optional frequency alignment
 
 #include <QPainter>
@@ -626,6 +628,46 @@
 }
 
 void
+NoteLayer::editOpen(View *v, QMouseEvent *e)
+{
+    if (!m_model) return;
+
+    NoteModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+
+    NoteModel::Point note = *points.begin();
+
+    ItemEditDialog *dialog = new ItemEditDialog
+        (m_model->getSampleRate(),
+         ItemEditDialog::ShowTime |
+         ItemEditDialog::ShowDuration |
+         ItemEditDialog::ShowValue |
+         ItemEditDialog::ShowText);
+
+    dialog->setFrameTime(note.frame);
+    dialog->setValue(note.value);
+    dialog->setFrameDuration(note.duration);
+    dialog->setText(note.label);
+
+    if (dialog->exec() == QDialog::Accepted) {
+
+        NoteModel::Point newNote = note;
+        newNote.frame = dialog->getFrameTime();
+        newNote.value = dialog->getValue();
+        newNote.duration = dialog->getFrameDuration();
+        newNote.label = dialog->getText();
+        
+        NoteModel::EditCommand *command = new NoteModel::EditCommand
+            (m_model, tr("Edit Point"));
+        command->deletePoint(note);
+        command->addPoint(newNote);
+        command->finish();
+    }
+
+    delete dialog;
+}
+
+void
 NoteLayer::moveSelection(Selection s, size_t newStartFrame)
 {
     NoteModel::EditCommand *command =
--- a/layer/NoteLayer.h	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/NoteLayer.h	Thu Mar 30 15:00:22 2006 +0000
@@ -48,6 +48,8 @@
     virtual void editDrag(View *v, QMouseEvent *);
     virtual void editEnd(View *v, QMouseEvent *);
 
+    virtual void editOpen(View *v, QMouseEvent *);
+
     virtual void moveSelection(Selection s, size_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
 
--- a/layer/TimeInstantLayer.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/TimeInstantLayer.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -22,6 +22,8 @@
 
 #include "model/SparseOneDimensionalModel.h"
 
+#include "widgets/ItemEditDialog.h"
+
 #include <QPainter>
 #include <QMouseEvent>
 
@@ -580,6 +582,40 @@
 }
 
 void
+TimeInstantLayer::editOpen(View *v, QMouseEvent *e)
+{
+    if (!m_model) return;
+
+    SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+
+    SparseOneDimensionalModel::Point point = *points.begin();
+
+    ItemEditDialog *dialog = new ItemEditDialog
+        (m_model->getSampleRate(),
+         ItemEditDialog::ShowTime |
+         ItemEditDialog::ShowText);
+
+    dialog->setFrameTime(point.frame);
+    dialog->setText(point.label);
+
+    if (dialog->exec() == QDialog::Accepted) {
+
+        SparseOneDimensionalModel::Point newPoint = point;
+        newPoint.frame = dialog->getFrameTime();
+        newPoint.label = dialog->getText();
+        
+        SparseOneDimensionalModel::EditCommand *command =
+            new SparseOneDimensionalModel::EditCommand(m_model, tr("Edit Point"));
+        command->deletePoint(point);
+        command->addPoint(newPoint);
+        command->finish();
+    }
+
+    delete dialog;
+}
+
+void
 TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame)
 {
     SparseOneDimensionalModel::EditCommand *command =
--- a/layer/TimeInstantLayer.h	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/TimeInstantLayer.h	Thu Mar 30 15:00:22 2006 +0000
@@ -48,6 +48,8 @@
     virtual void editDrag(View *v, QMouseEvent *);
     virtual void editEnd(View *v, QMouseEvent *);
 
+    virtual void editOpen(View *, QMouseEvent *);
+
     virtual void moveSelection(Selection s, size_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
--- a/layer/TimeRulerLayer.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/TimeRulerLayer.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -248,12 +248,16 @@
 
 	int tw = metrics.width(text);
 
-	if (v->getLayer(0) == this) {
-	    // backmost layer, don't worry about outlining the text
-	    paint.drawText(x+2 - tw/2, y, text);
-	} else {
-	    v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText);
-	}
+        if (v->getViewManager() && v->getViewManager()->getOverlayMode() !=
+            ViewManager::NoOverlays) {
+
+            if (v->getLayer(0) == this) {
+                // backmost layer, don't worry about outlining the text
+                paint.drawText(x+2 - tw/2, y, text);
+            } else {
+                v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText);
+            }
+        }
 
 	paint.setPen(greyColour);
 
--- a/layer/TimeValueLayer.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/TimeValueLayer.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -22,6 +22,8 @@
 
 #include "model/SparseTimeValueModel.h"
 
+#include "widgets/ItemEditDialog.h"
+
 #include "SpectrogramLayer.h" // for optional frequency alignment
 
 #include <QPainter>
@@ -845,6 +847,43 @@
 }
 
 void
+TimeValueLayer::editOpen(View *v, QMouseEvent *e)
+{
+    if (!m_model) return;
+
+    SparseTimeValueModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+
+    SparseTimeValueModel::Point point = *points.begin();
+
+    ItemEditDialog *dialog = new ItemEditDialog
+        (m_model->getSampleRate(),
+         ItemEditDialog::ShowTime |
+         ItemEditDialog::ShowValue |
+         ItemEditDialog::ShowText);
+
+    dialog->setFrameTime(point.frame);
+    dialog->setValue(point.value);
+    dialog->setText(point.label);
+
+    if (dialog->exec() == QDialog::Accepted) {
+
+        SparseTimeValueModel::Point newPoint = point;
+        newPoint.frame = dialog->getFrameTime();
+        newPoint.value = dialog->getValue();
+        newPoint.label = dialog->getText();
+        
+        SparseTimeValueModel::EditCommand *command =
+            new SparseTimeValueModel::EditCommand(m_model, tr("Edit Point"));
+        command->deletePoint(point);
+        command->addPoint(newPoint);
+        command->finish();
+    }
+
+    delete dialog;
+}
+
+void
 TimeValueLayer::moveSelection(Selection s, size_t newStartFrame)
 {
     SparseTimeValueModel::EditCommand *command =
--- a/layer/TimeValueLayer.h	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/TimeValueLayer.h	Thu Mar 30 15:00:22 2006 +0000
@@ -51,6 +51,8 @@
     virtual void editDrag(View *v, QMouseEvent *);
     virtual void editEnd(View *v, QMouseEvent *);
 
+    virtual void editOpen(View *v, QMouseEvent *);
+
     virtual void moveSelection(Selection s, size_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/ItemEditDialog.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -0,0 +1,273 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "ItemEditDialog.h"
+
+#include <QLineEdit>
+#include <QDoubleSpinBox>
+#include <QGridLayout>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+
+
+ItemEditDialog::ItemEditDialog(size_t sampleRate, int options, QWidget *parent) :
+    QDialog(parent),
+    m_sampleRate(sampleRate),
+    m_frame(0),
+    m_duration(0),
+    m_value(0.0)
+{
+    QGridLayout *grid = new QGridLayout;
+    setLayout(grid);
+    
+    int row = 0;
+    QLineEdit *line = 0;
+
+    if (options & ShowTime) {
+
+        grid->addWidget(new QLabel(tr("Frame time:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(frameTimeChanged(QString)));
+
+        ++row;
+
+        grid->addWidget(new QLabel(tr("Secs:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(realTimeSecsChanged(QString)));
+
+        ++row;
+
+        grid->addWidget(new QLabel(tr("Nsecs:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(realTimeSecsChanged(QString)));
+
+        ++row;
+    }
+
+    if (options & ShowDuration) {
+
+        grid->addWidget(new QLabel(tr("Frame duration:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(frameDurationChanged(QString)));
+
+        ++row;
+
+        grid->addWidget(new QLabel(tr("Secs:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(realDurationSecsChanged(QString)));
+
+        ++row;
+
+        grid->addWidget(new QLabel(tr("Nsecs:")), row, 0);
+
+        line = new QLineEdit;
+        line->setValidator(new QIntValidator(this));
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(realDurationSecsChanged(QString)));
+
+        ++row;
+    }
+
+    if (options & ShowValue) {
+        
+        grid->addWidget(new QLabel(tr("Value:")), row, 0);
+
+        QDoubleSpinBox *spinbox = new QDoubleSpinBox;
+        grid->addWidget(spinbox, row, 1);
+        connect(spinbox, SIGNAL(valueChanged(double)),
+                this, SLOT(valueChanged(double)));
+
+        ++row;
+    }
+
+    if (options & ShowText) {
+        
+        grid->addWidget(new QLabel(tr("Text:")), row, 0);
+
+        line = new QLineEdit;
+        grid->addWidget(line, row, 1);
+        connect(line, SIGNAL(textChanged(QString)),
+                this, SLOT(textChanged(QString)));
+
+        ++row;
+    }
+
+    QHBoxLayout *hbox = new QHBoxLayout;
+    grid->addLayout(hbox, row, 0, 1, 2);
+    
+    QPushButton *ok = new QPushButton(tr("OK"));
+    QPushButton *cancel = new QPushButton(tr("Cancel"));
+    hbox->addStretch(10);
+    hbox->addWidget(ok);
+    hbox->addWidget(cancel);
+    connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
+    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+void
+ItemEditDialog::setFrameTime(long frame)
+{
+    m_frame = frame;
+    //!!!
+}
+
+long
+ItemEditDialog::getFrameTime() const
+{
+    return m_frame;
+}
+
+void
+ItemEditDialog::setRealTime(RealTime rt)
+{
+    m_frame = RealTime::realTime2Frame(rt, m_sampleRate);
+    //!!!
+}
+
+RealTime
+ItemEditDialog::getRealTime() const
+{
+    return RealTime::frame2RealTime(m_frame, m_sampleRate);
+}
+
+void
+ItemEditDialog::setFrameDuration(long duration)
+{
+    m_duration = duration;
+    //!!!
+}
+
+long
+ItemEditDialog::getFrameDuration() const
+{
+    return m_duration;
+}
+
+void
+ItemEditDialog::setRealDuration(RealTime rt)
+{
+    m_duration = RealTime::realTime2Frame(rt, m_sampleRate);
+}
+
+RealTime
+ItemEditDialog::getRealDuration() const
+{
+    return RealTime::frame2RealTime(m_duration, m_sampleRate);
+}
+
+void
+ItemEditDialog::setValue(float v)
+{
+    m_value = v; 
+    //!!!
+}
+
+float
+ItemEditDialog::getValue() const
+{
+    return m_value;
+}
+
+void
+ItemEditDialog::setText(QString text)
+{
+    m_text = text;
+    //!!!
+}
+
+QString
+ItemEditDialog::getText() const
+{
+    return m_text;
+}
+
+void
+ItemEditDialog::frameTimeChanged(QString s)
+{
+    setFrameTime(s.toInt());
+}
+
+void
+ItemEditDialog::realTimeSecsChanged(QString s)
+{
+    RealTime rt = getRealTime();
+    rt.sec = s.toInt();
+    setRealTime(rt);
+}
+
+void
+ItemEditDialog::realTimeNSecsChanged(QString s)
+{
+    RealTime rt = getRealTime();
+    rt.nsec = s.toInt();
+    setRealTime(rt);
+}
+
+void
+ItemEditDialog::frameDurationChanged(QString s)
+{
+    setFrameDuration(s.toInt());
+}
+
+void
+ItemEditDialog::realDurationSecsChanged(QString s)
+{
+    RealTime rt = getRealDuration();
+    rt.sec = s.toInt();
+    setRealDuration(rt);
+}
+
+void
+ItemEditDialog::realDurationNSecsChanged(QString s)
+{
+    RealTime rt = getRealDuration();
+    rt.nsec = s.toInt();
+    setRealDuration(rt);
+}
+
+void
+ItemEditDialog::valueChanged(double v)
+{
+    setValue((float)v);
+}
+
+void
+ItemEditDialog::textChanged(QString text)
+{
+    setText(text);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/ItemEditDialog.h	Thu Mar 30 15:00:22 2006 +0000
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _ITEM_EDIT_DIALOG_H_
+#define _ITEM_EDIT_DIALOG_H_
+
+#include <QDialog>
+#include <QString>
+
+#include "base/RealTime.h"
+
+class ItemEditDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    enum {
+        ShowTime       = 1 << 0,
+        ShowDuration   = 1 << 1,
+        ShowValue      = 1 << 2,
+        ShowText       = 1 << 3
+    };
+
+    ItemEditDialog(size_t sampleRate, int options, QWidget *parent = 0);
+
+    void setFrameTime(long frame);
+    long getFrameTime() const;
+
+    void setRealTime(RealTime rt);
+    RealTime getRealTime() const;
+
+    void setFrameDuration(long frame);
+    long getFrameDuration() const;
+    
+    void setRealDuration(RealTime rt);
+    RealTime getRealDuration() const;
+
+    void setValue(float value);
+    float getValue() const;
+    
+    void setText(QString text);
+    QString getText() const;
+
+protected slots:
+    void frameTimeChanged(QString);
+    void realTimeSecsChanged(QString);
+    void realTimeNSecsChanged(QString);
+    void frameDurationChanged(QString);
+    void realDurationSecsChanged(QString);
+    void realDurationNSecsChanged(QString);
+    void valueChanged(double);
+    void textChanged(QString);
+
+protected:
+    size_t m_sampleRate;
+    long m_frame;
+    long m_duration;
+    double m_value;
+    QString m_text;
+};
+
+#endif
--- a/widgets/Pane.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/widgets/Pane.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -144,86 +144,90 @@
     int fontHeight = paint.fontMetrics().height();
     int fontAscent = paint.fontMetrics().ascent();
 
-    for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
-	--vi;
+    if (m_manager &&
+        m_manager->getOverlayMode() != ViewManager::NoOverlays) {
 
-	if (dynamic_cast<WaveformLayer *>(*vi)) {
-	    waveformModel = (*vi)->getModel();
-	}
+        for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
+            --vi;
 
-	verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
+            if (dynamic_cast<WaveformLayer *>(*vi)) {
+                waveformModel = (*vi)->getModel();
+            }
 
-	if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
+            verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
+
+            if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
 
 //	    Profiler profiler("Pane::paintEvent - painting vertical scale", true);
 
 //	    std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
-	    paint.save();
+                paint.save();
 
-	    paint.setPen(Qt::black);
-	    paint.setBrush(Qt::white);
-	    paint.drawRect(0, -1, verticalScaleWidth, height()+1);
+                paint.setPen(Qt::black);
+                paint.setBrush(Qt::white);
+                paint.drawRect(0, -1, verticalScaleWidth, height()+1);
 
-	    paint.setBrush(Qt::NoBrush);
-	    (*vi)->paintVerticalScale
-		(this, paint, QRect(0, 0, verticalScaleWidth, height()));
+                paint.setBrush(Qt::NoBrush);
+                (*vi)->paintVerticalScale
+                    (this, paint, QRect(0, 0, verticalScaleWidth, height()));
 
-	    paint.restore();
-	}
+                paint.restore();
+            }
 	
-	if (m_identifyFeatures) {
+            if (m_identifyFeatures) {
 
-	    QPoint pos = m_identifyPoint;
-	    QString desc = (*vi)->getFeatureDescription(this, pos);
+                QPoint pos = m_identifyPoint;
+                QString desc = (*vi)->getFeatureDescription(this, pos);
 	    
-	    if (desc != "") {
+                if (desc != "") {
 
-		paint.save();
+                    paint.save();
 
-		int tabStop =
-		    paint.fontMetrics().width(tr("Some lengthy prefix:"));
+                    int tabStop =
+                        paint.fontMetrics().width(tr("Some lengthy prefix:"));
 
-		QRect boundingRect = 
-		    paint.fontMetrics().boundingRect
-		    (rect(),
-		     Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
-		     desc, tabStop);
+                    QRect boundingRect = 
+                        paint.fontMetrics().boundingRect
+                        (rect(),
+                         Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
+                         desc, tabStop);
 
-		if (hasLightBackground()) {
-		    paint.setPen(Qt::NoPen);
-		    paint.setBrush(QColor(250, 250, 250, 200));
-		} else {
-		    paint.setPen(Qt::NoPen);
-		    paint.setBrush(QColor(50, 50, 50, 200));
-		}
+                    if (hasLightBackground()) {
+                        paint.setPen(Qt::NoPen);
+                        paint.setBrush(QColor(250, 250, 250, 200));
+                    } else {
+                        paint.setPen(Qt::NoPen);
+                        paint.setBrush(QColor(50, 50, 50, 200));
+                    }
 
-		int extra = paint.fontMetrics().descent();
-		paint.drawRect(width() - boundingRect.width() - 10 - extra,
-			       10 - extra,
-			       boundingRect.width() + 2 * extra,
-			       boundingRect.height() + extra);
+                    int extra = paint.fontMetrics().descent();
+                    paint.drawRect(width() - boundingRect.width() - 10 - extra,
+                                   10 - extra,
+                                   boundingRect.width() + 2 * extra,
+                                   boundingRect.height() + extra);
 
-		if (hasLightBackground()) {
-		    paint.setPen(QColor(150, 20, 0));
-		} else {
-		    paint.setPen(QColor(255, 150, 100));
-		}
+                    if (hasLightBackground()) {
+                        paint.setPen(QColor(150, 20, 0));
+                    } else {
+                        paint.setPen(QColor(255, 150, 100));
+                    }
 		
-		QTextOption option;
-		option.setWrapMode(QTextOption::NoWrap);
-		option.setAlignment(Qt::AlignRight | Qt::AlignTop);
-		option.setTabStop(tabStop);
-		paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
-				      boundingRect.width(),
-				      boundingRect.height()),
-			       desc,
-			       option);
+                    QTextOption option;
+                    option.setWrapMode(QTextOption::NoWrap);
+                    option.setAlignment(Qt::AlignRight | Qt::AlignTop);
+                    option.setTabStop(tabStop);
+                    paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
+                                          boundingRect.width(),
+                                          boundingRect.height()),
+                                   desc,
+                                   option);
 
-		paint.restore();
-	    }
-	}
+                    paint.restore();
+                }
+            }
 
-	break;
+            break;
+        }
     }
     
     int sampleRate = getModelsSampleRate();
@@ -264,24 +268,28 @@
 	    }
 	}
 
-	if (sampleRate) {
+        if (m_manager &&
+            m_manager->getOverlayMode() != ViewManager::NoOverlays) {
 
-	    QString text(QString::fromStdString
-			 (RealTime::frame2RealTime
-			  (m_centreFrame, sampleRate).toText(true)));
+            if (sampleRate) {
 
-	    int tw = paint.fontMetrics().width(text);
-	    int x = width()/2 - 4 - tw;
-
-	    drawVisibleText(paint, x, y, text, OutlinedText);
-	}
-
-	QString text = QString("%1").arg(m_centreFrame);
-
-	int tw = paint.fontMetrics().width(text);
-	int x = width()/2 + 4;
-
-	drawVisibleText(paint, x, y, text, OutlinedText);
+                QString text(QString::fromStdString
+                             (RealTime::frame2RealTime
+                              (m_centreFrame, sampleRate).toText(true)));
+                
+                int tw = paint.fontMetrics().width(text);
+                int x = width()/2 - 4 - tw;
+                
+                drawVisibleText(paint, x, y, text, OutlinedText);
+            }
+            
+            QString text = QString("%1").arg(m_centreFrame);
+            
+            int tw = paint.fontMetrics().width(text);
+            int x = width()/2 + 4;
+            
+            drawVisibleText(paint, x, y, text, OutlinedText);
+        }
 
     } else {
 
@@ -289,6 +297,8 @@
     }
 
     if (waveformModel &&
+        m_manager &&
+        m_manager->getOverlayMode() != ViewManager::NoOverlays &&
 	r.y() + r.height() >= height() - fontHeight - 6) {
 
 	size_t mainModelRate = m_manager->getMainModelSampleRate();
@@ -322,7 +332,9 @@
 	}
     }
 
-    if (r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) {
+    if (m_manager &&
+        m_manager->getOverlayMode() == ViewManager::AllOverlays &&
+        r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) {
 
 	std::vector<QString> texts;
 	int maxTextWidth = 0;