# HG changeset patch # User Chris Cannam # Date 1399471933 -3600 # Node ID 410816717c2ce0edaa51640224a8e42c0dc5b603 # Parent 2cd6d2d17437e10d0b2113e107ce630bf792a78e# Parent 6388ddae6ce3b5ddaeb5a39221e680e0327e55cb Merge from tonioni branch diff -r 2cd6d2d17437 -r 410816717c2c layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/layer/FlexiNoteLayer.cpp Wed May 07 15:12:13 2014 +0100 @@ -1141,6 +1141,7 @@ break; } } + updateNoteValue(v, m_editingPoint); m_editingCommand->addPoint(m_editingPoint); std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl; @@ -1354,9 +1355,7 @@ command->deletePoint(note); - if (updateNoteValue(v, newNote)) { - command->addPoint(newNote); - } + } finish(command); diff -r 2cd6d2d17437 -r 410816717c2c layer/LayerFactory.cpp --- a/layer/LayerFactory.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/layer/LayerFactory.cpp Wed May 07 15:12:13 2014 +0100 @@ -197,7 +197,7 @@ LayerTypeSet types; types.insert(TimeInstants); types.insert(TimeValues); - types.insert(FlexiNotes); + types.insert(FlexiNotes); types.insert(Notes); types.insert(Regions); types.insert(Text); @@ -214,7 +214,7 @@ if (dynamic_cast(layer)) return TimeRuler; if (dynamic_cast(layer)) return TimeInstants; if (dynamic_cast(layer)) return TimeValues; - if (dynamic_cast(layer)) return FlexiNotes; + if (dynamic_cast(layer)) return FlexiNotes; if (dynamic_cast(layer)) return Notes; if (dynamic_cast(layer)) return Regions; if (dynamic_cast(layer)) return Text; @@ -235,7 +235,7 @@ case TimeInstants: return "instants"; case TimeValues: return "values"; case Notes: return "notes"; - case FlexiNotes: return "flexible notes"; + case FlexiNotes: return "flexinotes"; case Regions: return "regions"; case Text: return "text"; case Image: return "image"; @@ -349,7 +349,7 @@ return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1); } else if (layerType == TimeValues) { return new SparseTimeValueModel(baseModel->getSampleRate(), 1, true); - } else if (layerType == FlexiNotes) { + } else if (layerType == FlexiNotes) { return new FlexiNoteModel(baseModel->getSampleRate(), 1, true); } else if (layerType == Notes) { return new NoteModel(baseModel->getSampleRate(), 1, true); diff -r 2cd6d2d17437 -r 410816717c2c layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/layer/SpectrogramLayer.cpp Wed May 07 15:12:13 2014 +0100 @@ -3657,18 +3657,21 @@ "colourScheme=\"%4\" " "colourRotation=\"%5\" " "frequencyScale=\"%6\" " - "binDisplay=\"%7\" " - "normalizeColumns=\"%8\" " - "normalizeVisibleArea=\"%9\"") + "binDisplay=\"%7\" ") .arg(m_minFrequency) .arg(m_maxFrequency) .arg(m_colourScale) .arg(m_colourMap) .arg(m_colourRotation) .arg(m_frequencyScale) - .arg(m_binDisplay) + .arg(m_binDisplay); + + s += QString("normalizeColumns=\"%1\" " + "normalizeVisibleArea=\"%2\" " + "normalizeHybrid=\"%3\" ") .arg(m_normalizeColumns ? "true" : "false") - .arg(m_normalizeVisibleArea ? "true" : "false"); + .arg(m_normalizeVisibleArea ? "true" : "false") + .arg(m_normalizeHybrid ? "true" : "false"); Layer::toXml(stream, indent, extraAttributes + " " + s); } @@ -3741,5 +3744,9 @@ bool normalizeVisibleArea = (attributes.value("normalizeVisibleArea").trimmed() == "true"); setNormalizeVisibleArea(normalizeVisibleArea); + + bool normalizeHybrid = + (attributes.value("normalizeHybrid").trimmed() == "true"); + setNormalizeHybrid(normalizeHybrid); } diff -r 2cd6d2d17437 -r 410816717c2c view/Pane.cpp --- a/view/Pane.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/view/Pane.cpp Wed May 07 15:12:13 2014 +0100 @@ -465,6 +465,10 @@ m_scaleWidth = 0; + if (workModel) { + drawModelTimeExtents(r, paint, workModel); + } + if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) { drawVerticalScale(r, topLayer, paint); } @@ -775,6 +779,39 @@ } void +Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) +{ + int x0 = getXForFrame(model->getStartFrame()); + int x1 = getXForFrame(model->getEndFrame()); + + int lw = 10; + + paint.save(); + + QBrush brush; + + if (hasLightBackground()) { + brush = QBrush(QColor("#f8f8f8")); + paint.setPen(Qt::black); + } else { + brush = QBrush(QColor("#101010")); + paint.setPen(Qt::white); + } + + if (x0 > r.x()) { + paint.fillRect(0, 0, x0, height(), brush); + paint.drawLine(x0, 0, x0, height()); + } + + if (x1 < r.x() + r.width()) { + paint.fillRect(x1, 0, width() - x1, height(), brush); + paint.drawLine(x1, 0, x1, height()); + } + + paint.restore(); +} + +void Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model, bool down) { diff -r 2cd6d2d17437 -r 410816717c2c view/Pane.h --- a/view/Pane.h Wed Apr 02 08:53:32 2014 +0100 +++ b/view/Pane.h Wed May 07 15:12:13 2014 +0100 @@ -107,6 +107,7 @@ void drawVerticalScale(QRect r, Layer *, QPainter &); void drawFeatureDescription(Layer *, QPainter &); void drawCentreLine(int, QPainter &, bool omitLine); + void drawModelTimeExtents(QRect, QPainter &, const Model *); void drawDurationAndRate(QRect, const Model *, int, QPainter &); void drawWorkTitle(QRect, QPainter &, const Model *); void drawLayerNames(QRect, QPainter &); diff -r 2cd6d2d17437 -r 410816717c2c view/ViewManager.cpp --- a/view/ViewManager.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/view/ViewManager.cpp Wed May 07 15:12:13 2014 +0100 @@ -258,6 +258,14 @@ } void +ViewManager::addSelectionQuietly(const Selection &selection) +{ + MultiSelection ms(m_selections); + ms.addSelection(selection); + setSelections(ms, true); +} + +void ViewManager::removeSelection(const Selection &selection) { MultiSelection ms(m_selections); @@ -274,12 +282,14 @@ } void -ViewManager::setSelections(const MultiSelection &ms) +ViewManager::setSelections(const MultiSelection &ms, bool quietly) { if (m_selections.getSelections() == ms.getSelections()) return; SetSelectionCommand *command = new SetSelectionCommand(this, ms); CommandHistory::getInstance()->addCommand(command); - emit selectionChangedByUser(); + if (!quietly) { + emit selectionChangedByUser(); + } } size_t diff -r 2cd6d2d17437 -r 410816717c2c view/ViewManager.h --- a/view/ViewManager.h Wed Apr 02 08:53:32 2014 +0100 +++ b/view/ViewManager.h Wed May 07 15:12:13 2014 +0100 @@ -86,6 +86,13 @@ size_t constrainFrameToSelection(size_t frame) const; /** + * Adding a selection normally emits the selectionChangedByUser + * signal. Call this to add a selection without emitting that signal. + * This is used in session file load, for example. + */ + void addSelectionQuietly(const Selection &selection); + + /** * Return the selection that contains a given frame. * If defaultToFollowing is true, and if the frame is not in a * selected area, return the next selection after the given frame. @@ -297,7 +304,7 @@ bool m_playSoloMode; bool m_alignMode; - void setSelections(const MultiSelection &ms); + void setSelections(const MultiSelection &ms, bool quietly = false); void signalSelectionChange(); class SetSelectionCommand : public Command diff -r 2cd6d2d17437 -r 410816717c2c widgets/InteractiveFileFinder.cpp --- a/widgets/InteractiveFileFinder.cpp Wed Apr 02 08:53:32 2014 +0100 +++ b/widgets/InteractiveFileFinder.cpp Wed May 07 15:12:13 2014 +0100 @@ -33,6 +33,7 @@ InteractiveFileFinder::m_instance; InteractiveFileFinder::InteractiveFileFinder() : + m_sessionExtension("sv"), m_lastLocatedLocation("") { SVDEBUG << "Registering interactive file finder" << endl; @@ -43,6 +44,12 @@ { } +void +InteractiveFileFinder::setApplicationSessionExtension(QString extension) +{ + m_sessionExtension = extension; +} + QString InteractiveFileFinder::getOpenFileName(FileType type, QString fallbackLocation) { @@ -57,7 +64,10 @@ case SessionFile: settingsKey = "sessionpath"; title = tr("Select a session file"); - filter = tr("Sonic Visualiser session files (*.sv)\nRDF files (%1)\nAll files (*.*)").arg(RDFImporter::getKnownExtensions()); + filter = tr("%1 session files (*.%1)\nRDF files (%3)\nAll files (*.*)") + .arg(QApplication::applicationName()) + .arg(m_sessionExtension) + .arg(RDFImporter::getKnownExtensions()); break; case AudioFile: @@ -97,9 +107,11 @@ case SessionOrAudioFile: settingsKey = "lastpath"; - filter = tr("All supported files (*.sv %1 %2)\nSonic Visualiser session files (*.sv)\nAudio files (%2)\nRDF files (%1)\nAll files (*.*)") + filter = tr("All supported files (*.sv %1 %2)\n%3 session files (*.%4)\nAudio files (%2)\nRDF files (%1)\nAll files (*.*)") .arg(RDFImporter::getKnownExtensions()) - .arg(AudioFileReaderFactory::getKnownExtensions()); + .arg(AudioFileReaderFactory::getKnownExtensions()) + .arg(QApplication::applicationName()) + .arg(m_sessionExtension); break; case ImageFile: @@ -123,10 +135,12 @@ case AnyFile: settingsKey = "lastpath"; - filter = tr("All supported files (*.sv %1 %2 %3)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nLayer files (%2)\nRDF files (%3)\nAll files (*.*)") + filter = tr("All supported files (*.sv %1 %2 %3)\n%4 session files (*.%5)\nAudio files (%1)\nLayer files (%2)\nRDF files (%3)\nAll files (*.*)") .arg(AudioFileReaderFactory::getKnownExtensions()) .arg(DataFileReaderFactory::getKnownExtensions()) - .arg(RDFImporter::getKnownExtensions()); + .arg(RDFImporter::getKnownExtensions()) + .arg(QApplication::applicationName()) + .arg(m_sessionExtension); break; }; @@ -216,7 +230,8 @@ case SessionFile: settingsKey = "savesessionpath"; title = tr("Select a session file"); - filter = tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)"); + filter = tr("%1 session files (*.%2)\nAll files (*.*)") + .arg(QApplication::applicationName()).arg(m_sessionExtension); break; case AudioFile: @@ -300,7 +315,7 @@ dialog.setConfirmOverwrite(false); // we'll do that if (type == SessionFile) { - dialog.setDefaultSuffix("sv"); + dialog.setDefaultSuffix(m_sessionExtension); } else if (type == AudioFile) { dialog.setDefaultSuffix("wav"); } else if (type == ImageFile) { diff -r 2cd6d2d17437 -r 410816717c2c widgets/InteractiveFileFinder.h --- a/widgets/InteractiveFileFinder.h Wed Apr 02 08:53:32 2014 +0100 +++ b/widgets/InteractiveFileFinder.h Wed May 07 15:12:13 2014 +0100 @@ -18,6 +18,7 @@ #include "data/fileio/FileFinder.h" +#include #include #include @@ -29,6 +30,14 @@ public: virtual ~InteractiveFileFinder(); + /// Specify the extension for this application's session files + /// (without the dot) + void setApplicationSessionExtension(QString extension); + + QString getApplicationSessionExtension() const { + return m_sessionExtension; + } + QString getOpenFileName(FileType type, QString fallbackLocation = ""); QString getSaveFileName(FileType type, QString fallbackLocation = ""); void registerLastOpenedFilePath(FileType type, QString path); @@ -44,6 +53,7 @@ QString findRelative(QString location, QString relativeTo); QString locateInteractive(FileType type, QString thing); + QString m_sessionExtension; QString m_lastLocatedLocation; };