├── .gitignore ├── .hgignore ├── widgets ├── NotifyingCheckBox.cpp ├── NotifyingComboBox.cpp ├── NotifyingPushButton.cpp ├── NotifyingToolButton.cpp ├── PluginReviewDialog.h ├── ClickableLabel.h ├── ActivityLog.h ├── NotifyingTabBar.h ├── ColourMapComboBox.h ├── IconLoader.h ├── WindowShapePreview.h ├── MIDIFileImportDialog.h ├── LabelCounterInputDialog.h ├── LayerTreeDialog.h ├── NotifyingCheckBox.h ├── NotifyingComboBox.h ├── NotifyingTabBar.cpp ├── NotifyingPushButton.h ├── NotifyingToolButton.h ├── RangeInputDialog.h ├── WindowTypeSelector.h ├── ColourNameDialog.h ├── SelectableLabel.h ├── CSVAudioFormatDialog.h ├── ProgressDialog.h ├── MenuTitle.h ├── ListInputDialog.h ├── ImageDialog.h ├── TransformFinder.h ├── WheelCounter.h ├── UnitConverter.h ├── ColourMapComboBox.cpp ├── PluginParameterBox.h ├── WidgetScale.h ├── ColourComboBox.h ├── ModelDataTableDialog.h ├── PluginPathConfigurator.h ├── MIDIFileImportDialog.cpp ├── PropertyStack.h ├── Fader.h ├── TipDialog.h ├── LEDButton.h ├── InteractiveFileFinder.h ├── SubdividingMenu.h ├── ActivityLog.cpp ├── LevelPanToolButton.h ├── PropertyBox.h ├── LabelCounterInputDialog.cpp ├── CSVFormatDialog.h ├── ListInputDialog.cpp ├── Thumbwheel.h ├── ProgressDialog.cpp ├── ColourNameDialog.cpp ├── ItemEditDialog.h ├── LayerTreeDialog.cpp ├── RangeInputDialog.cpp ├── WindowTypeSelector.cpp ├── ColourComboBox.cpp ├── CSVExportDialog.h ├── LevelPanWidget.h ├── PluginParameterDialog.h ├── LayerTree.h ├── SelectableLabel.cpp └── TextAbbrev.h ├── layer ├── ImageRegionFinder.h ├── LogNumericalScale.h ├── LogColourScale.h ├── LinearColourScale.h ├── LinearNumericalScale.h ├── HorizontalFrequencyScale.h ├── PianoScale.h ├── ShowLayerCommand.h ├── ColourScaleLayer.h ├── HorizontalScaleProvider.h ├── SliceableLayer.h ├── PaintAssistant.h ├── VerticalBinLayer.h ├── HorizontalFrequencyScale.cpp ├── TimeRulerLayer.h ├── LinearNumericalScale.cpp ├── LogNumericalScale.cpp ├── LinearColourScale.cpp ├── LogColourScale.cpp ├── LayerFactory.h ├── SingleColourLayer.h ├── ImageRegionFinder.cpp ├── RenderTimer.h ├── ScrollableMagRangeCache.cpp └── ColourMapper.h ├── .hgtags └── view ├── AlignmentView.h └── Overview.h /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.orig 3 | *.rej 4 | doc/html/ 5 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | Makefile 3 | */Makefile 4 | o/* 5 | */o/* 6 | */tmp_obj/* 7 | */tmp_moc/* 8 | doc/html/ 9 | *.o 10 | *.so 11 | *.so.* 12 | *.a 13 | *.wav 14 | *~ 15 | *.orig 16 | *.rej 17 | -------------------------------------------------------------------------------- /widgets/NotifyingCheckBox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "NotifyingCheckBox.h" 17 | 18 | namespace sv { 19 | 20 | NotifyingCheckBox::~NotifyingCheckBox() 21 | { 22 | } 23 | 24 | void 25 | NotifyingCheckBox::enterEvent(QEnterEvent *e) 26 | { 27 | QCheckBox::enterEvent(e); 28 | emit mouseEntered(); 29 | } 30 | 31 | void 32 | NotifyingCheckBox::leaveEvent(QEvent *e) 33 | { 34 | QCheckBox::leaveEvent(e); 35 | emit mouseLeft(); 36 | } 37 | 38 | } // end namespace sv 39 | 40 | -------------------------------------------------------------------------------- /widgets/NotifyingComboBox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "NotifyingComboBox.h" 17 | 18 | namespace sv { 19 | 20 | NotifyingComboBox::~NotifyingComboBox() 21 | { 22 | } 23 | 24 | void 25 | NotifyingComboBox::enterEvent(QEnterEvent *e) 26 | { 27 | QComboBox::enterEvent(e); 28 | emit mouseEntered(); 29 | } 30 | 31 | void 32 | NotifyingComboBox::leaveEvent(QEvent *e) 33 | { 34 | QComboBox::leaveEvent(e); 35 | emit mouseLeft(); 36 | } 37 | 38 | } // end namespace sv 39 | 40 | -------------------------------------------------------------------------------- /widgets/NotifyingPushButton.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "NotifyingPushButton.h" 17 | 18 | namespace sv { 19 | 20 | NotifyingPushButton::~NotifyingPushButton() 21 | { 22 | } 23 | 24 | void 25 | NotifyingPushButton::enterEvent(QEnterEvent *e) 26 | { 27 | QPushButton::enterEvent(e); 28 | emit mouseEntered(); 29 | } 30 | 31 | void 32 | NotifyingPushButton::leaveEvent(QEvent *e) 33 | { 34 | QPushButton::leaveEvent(e); 35 | emit mouseLeft(); 36 | } 37 | 38 | } // end namespace sv 39 | 40 | -------------------------------------------------------------------------------- /widgets/NotifyingToolButton.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "NotifyingToolButton.h" 17 | 18 | namespace sv { 19 | 20 | NotifyingToolButton::~NotifyingToolButton() 21 | { 22 | } 23 | 24 | void 25 | NotifyingToolButton::enterEvent(QEnterEvent *e) 26 | { 27 | QToolButton::enterEvent(e); 28 | emit mouseEntered(); 29 | } 30 | 31 | void 32 | NotifyingToolButton::leaveEvent(QEvent *e) 33 | { 34 | QToolButton::leaveEvent(e); 35 | emit mouseLeft(); 36 | } 37 | 38 | } // end namespace sv 39 | 40 | -------------------------------------------------------------------------------- /layer/ImageRegionFinder.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_IMAGE_REGION_FINDER_H 17 | #define SV_IMAGE_REGION_FINDER_H 18 | 19 | #include 20 | #include 21 | 22 | class QImage; 23 | 24 | namespace sv { 25 | 26 | class ImageRegionFinder 27 | { 28 | public: 29 | ImageRegionFinder(); 30 | virtual ~ImageRegionFinder(); 31 | 32 | QRect findRegionExtents(QImage *image, QPoint origin) const; 33 | 34 | protected: 35 | bool similar(QRgb a, QRgb b) const; 36 | }; 37 | 38 | } // end namespace sv 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /layer/LogNumericalScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LOG_NUMERICAL_SCALE_H 17 | #define SV_LOG_NUMERICAL_SCALE_H 18 | 19 | #include 20 | 21 | class QPainter; 22 | namespace sv { 23 | 24 | class LayerDimensionProvider; 25 | class CoordinateScale; 26 | 27 | class LogNumericalScale 28 | { 29 | public: 30 | int getWidth(LayerDimensionProvider *v, QPainter &paint); 31 | 32 | void paintVertical 33 | (LayerDimensionProvider *v, const CoordinateScale &scale, 34 | QPainter &paint, int x0); 35 | }; 36 | 37 | } // end namespace sv 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /layer/LogColourScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef LOG_COLOUR_SCALE_H 17 | #define LOG_COLOUR_SCALE_H 18 | 19 | #include 20 | 21 | class QPainter; 22 | namespace sv { 23 | 24 | class LayerGeometryProvider; 25 | class ColourScaleLayer; 26 | 27 | class LogColourScale 28 | { 29 | public: 30 | int getWidth(LayerGeometryProvider *v, QPainter &paint); 31 | 32 | void paintVertical 33 | (LayerGeometryProvider *v, const ColourScaleLayer *layer, QPainter &paint, int x0, 34 | double minf, double maxf); 35 | }; 36 | 37 | } // end namespace sv 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /widgets/PluginReviewDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_PLUGIN_REVIEW_DIALOG_H 16 | #define SV_PLUGIN_REVIEW_DIALOG_H 17 | 18 | #include 19 | #include 20 | 21 | class QEvent; 22 | 23 | namespace sv { 24 | 25 | class PluginReviewDialog : public QDialog 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | PluginReviewDialog(QWidget *parent = 0); 31 | ~PluginReviewDialog(); 32 | 33 | public slots: 34 | void populate(); 35 | void repopulateIgnoredTable(); 36 | 37 | private: 38 | QTableWidget *m_table; 39 | QTableWidget *m_ignoredTable; 40 | }; 41 | 42 | } // end namespace sv 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /layer/LinearColourScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef LINEAR_COLOUR_SCALE_H 17 | #define LINEAR_COLOUR_SCALE_H 18 | 19 | #include 20 | 21 | class QPainter; 22 | namespace sv { 23 | 24 | class LayerGeometryProvider; 25 | class ColourScaleLayer; 26 | 27 | class LinearColourScale 28 | { 29 | public: 30 | int getWidth(LayerGeometryProvider *v, QPainter &paint); 31 | 32 | void paintVertical 33 | (LayerGeometryProvider *v, const ColourScaleLayer *layer, QPainter &paint, int x0, 34 | double minf, double maxf); 35 | }; 36 | 37 | } // end namespace sv 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /layer/LinearNumericalScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LINEAR_NUMERICAL_SCALE_H 17 | #define SV_LINEAR_NUMERICAL_SCALE_H 18 | 19 | #include 20 | 21 | class QPainter; 22 | 23 | namespace sv { 24 | 25 | class LayerDimensionProvider; 26 | class CoordinateScale; 27 | 28 | class LinearNumericalScale 29 | { 30 | public: 31 | int getWidth(LayerDimensionProvider *v, QPainter &paint); 32 | 33 | void paintVertical 34 | (LayerDimensionProvider *v, const CoordinateScale &verticalScale, 35 | QPainter &paint, int x0); 36 | }; 37 | 38 | } // end namespace sv 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /widgets/ClickableLabel.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_CLICKABLE_LABEL_H 16 | #define SV_CLICKABLE_LABEL_H 17 | 18 | #include 19 | 20 | namespace sv { 21 | 22 | class ClickableLabel : public QLabel 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | ClickableLabel(const QString &text, QWidget *parent = 0) : 28 | QLabel(text, parent) { } 29 | ClickableLabel(QWidget *parent = 0) : QLabel(parent) { } 30 | ~ClickableLabel() { } 31 | 32 | signals: 33 | void clicked(); 34 | 35 | protected: 36 | void mousePressEvent(QMouseEvent *) override { 37 | emit clicked(); 38 | } 39 | }; 40 | 41 | } // end namespace sv 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /widgets/ActivityLog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2009 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_ACTIVITY_LOG_H 17 | #define SV_ACTIVITY_LOG_H 18 | 19 | #include 20 | #include 21 | 22 | class QListView; 23 | class QStringListModel; 24 | 25 | namespace sv { 26 | 27 | class ActivityLog : public QDialog 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | ActivityLog(); 33 | ~ActivityLog(); 34 | 35 | public slots: 36 | void activityHappened(QString); 37 | void scrollToEnd(); 38 | 39 | private: 40 | QListView *m_listView; 41 | QStringListModel *m_model; 42 | QString m_prevName; 43 | }; 44 | 45 | } // end namespace sv 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /layer/HorizontalFrequencyScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_HORIZONTAL_FREQUENCY_SCALE_H 17 | #define SV_HORIZONTAL_FREQUENCY_SCALE_H 18 | 19 | #include 20 | 21 | class QPainter; 22 | namespace sv { 23 | 24 | class LayerGeometryProvider; 25 | class HorizontalScaleProvider; 26 | 27 | class HorizontalFrequencyScale 28 | { 29 | public: 30 | int getHeight(LayerGeometryProvider *v, QPainter &paint); 31 | 32 | void paintScale 33 | (LayerGeometryProvider *v, const HorizontalScaleProvider *provider, 34 | QPainter &paint, QRect r, bool logarithmic); 35 | }; 36 | 37 | } // end namespace sv 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /layer/PianoScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef PIANO_SCALE_H 17 | #define PIANO_SCALE_H 18 | 19 | #include 20 | 21 | #include "LayerGeometryProvider.h" 22 | 23 | class QPainter; 24 | namespace sv { 25 | 26 | class HorizontalScaleProvider; 27 | 28 | class PianoScale 29 | { 30 | public: 31 | void paintPianoVertical 32 | (LayerGeometryProvider *v, QPainter &paint, QRect rect, 33 | const CoordinateScale &scale); 34 | 35 | void paintPianoHorizontal 36 | (LayerGeometryProvider *v, const HorizontalScaleProvider *p, 37 | QPainter &paint, QRect rect); 38 | }; 39 | 40 | } // end namespace sv 41 | 42 | #endif 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /widgets/NotifyingTabBar.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_NOTIFYING_TAB_BAR_H 17 | #define SV_NOTIFYING_TAB_BAR_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | class NotifyingTabBar : public QTabBar 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | NotifyingTabBar(QWidget *parent = 0); 29 | virtual ~NotifyingTabBar(); 30 | 31 | signals: 32 | void mouseEntered(); 33 | void mouseLeft(); 34 | void activeTabClicked(); 35 | 36 | protected: 37 | void mousePressEvent(QMouseEvent *) override; 38 | void enterEvent(QEnterEvent *) override; 39 | void leaveEvent(QEvent *) override; 40 | }; 41 | 42 | } // end namespace sv 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /widgets/ColourMapComboBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2016 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_COLOURMAP_COMBO_BOX_H 17 | #define SV_COLOURMAP_COMBO_BOX_H 18 | 19 | #include "NotifyingComboBox.h" 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Colour map picker combo box with optional swatches 25 | */ 26 | class ColourMapComboBox : public NotifyingComboBox 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | ColourMapComboBox(bool includeSwatches, QWidget *parent = 0); 32 | 33 | signals: 34 | void colourMapChanged(int index); 35 | 36 | private slots: 37 | void rebuild(); 38 | void comboActivated(int); 39 | 40 | private: 41 | bool m_includeSwatches; 42 | }; 43 | 44 | } // end namespace sv 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /widgets/IconLoader.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_ICON_LOADER_H 17 | #define SV_ICON_LOADER_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | class IconLoader 24 | { 25 | public: 26 | IconLoader() { } 27 | virtual ~IconLoader() { } 28 | 29 | QIcon load(QString name); 30 | 31 | private: 32 | bool shouldInvert() const; 33 | bool shouldAutoInvert(QString) const; 34 | QPixmap loadPixmap(QString, int); 35 | QPixmap loadScalable(QString, int); 36 | QPixmap invertPixmap(QPixmap); 37 | QString makeScalableFilename(QString, bool); 38 | QString makeNonScalableFilename(QString, int, bool); 39 | }; 40 | 41 | } // end namespace sv 42 | 43 | #endif 44 | 45 | 46 | -------------------------------------------------------------------------------- /widgets/WindowShapePreview.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_WINDOW_SHAPE_PREVIEW_H 17 | #define SV_WINDOW_SHAPE_PREVIEW_H 18 | 19 | #include 20 | 21 | #include "base/Window.h" 22 | 23 | class QLabel; 24 | 25 | namespace sv { 26 | 27 | class WindowShapePreview : public QFrame 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | WindowShapePreview(QWidget *parent = 0); 33 | virtual ~WindowShapePreview(); 34 | 35 | public slots: 36 | void setWindowType(WindowType type); 37 | 38 | protected: 39 | QLabel *m_windowTimeExampleLabel; 40 | QLabel *m_windowFreqExampleLabel; 41 | WindowType m_windowType; 42 | 43 | void updateLabels(); 44 | }; 45 | 46 | } // end namespace sv 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /widgets/MIDIFileImportDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_MIDI_FILE_IMPORT_DIALOG_H 16 | #define SV_MIDI_FILE_IMPORT_DIALOG_H 17 | 18 | #include 19 | 20 | #include "data/fileio/MIDIFileReader.h" 21 | 22 | namespace sv { 23 | 24 | class MIDIFileImportDialog : public QObject, 25 | public MIDIFileImportPreferenceAcquirer 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | MIDIFileImportDialog(QWidget *parent = 0); 31 | 32 | TrackPreference getTrackImportPreference 33 | (QStringList trackNames, bool haveSomePercussion, 34 | QString &singleTrack) const override; 35 | 36 | void showError(QString error) override; 37 | 38 | protected: 39 | QWidget *m_parent; 40 | }; 41 | 42 | } // end namespace sv 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /widgets/LabelCounterInputDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LABEL_COUNTER_INPUT_DIALOG_H 17 | #define SV_LABEL_COUNTER_INPUT_DIALOG_H 18 | 19 | #include 20 | #include "data/model/Labeller.h" 21 | 22 | namespace sv { 23 | 24 | class LabelCounterInputDialog : public QDialog 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | LabelCounterInputDialog(Labeller *labeller, QWidget *parent); 30 | virtual ~LabelCounterInputDialog(); 31 | 32 | protected slots: 33 | void counterChanged(int); 34 | void secondCounterChanged(int); 35 | void cancelClicked(); 36 | 37 | protected: 38 | Labeller *m_labeller; 39 | int m_origCounter; 40 | int m_origSecondCounter; 41 | }; 42 | 43 | } // end namespace sv 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /widgets/LayerTreeDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LAYER_TREE_DIALOG_H 17 | #define SV_LAYER_TREE_DIALOG_H 18 | 19 | #include 20 | 21 | class QTreeView; 22 | class QTableView; 23 | 24 | namespace sv { 25 | 26 | class ModelMetadataModel; 27 | class LayerTreeModel; 28 | class PaneStack; 29 | 30 | class LayerTreeDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | LayerTreeDialog(PaneStack *stack, QWidget *parent = 0); 36 | ~LayerTreeDialog(); 37 | 38 | protected: 39 | PaneStack *m_paneStack; 40 | ModelMetadataModel *m_modelModel; 41 | QTableView *m_modelView; 42 | LayerTreeModel *m_layerModel; 43 | QTreeView *m_layerView; 44 | }; 45 | 46 | } // end namespace sv 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /widgets/NotifyingCheckBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_NOTIFYING_CHECK_BOX_H 17 | #define SV_NOTIFYING_CHECK_BOX_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Very trivial enhancement to QCheckBox to make it emit signals when 25 | * the mouse enters and leaves (for context help). 26 | */ 27 | 28 | class NotifyingCheckBox : public QCheckBox 29 | { 30 | Q_OBJECT 31 | public: 32 | 33 | NotifyingCheckBox(QWidget *parent = 0) : 34 | QCheckBox(parent) { } 35 | 36 | virtual ~NotifyingCheckBox(); 37 | 38 | signals: 39 | void mouseEntered(); 40 | void mouseLeft(); 41 | 42 | protected: 43 | void enterEvent(QEnterEvent *) override; 44 | void leaveEvent(QEvent *) override; 45 | }; 46 | 47 | } // end namespace sv 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /widgets/NotifyingComboBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_NOTIFYING_COMBO_BOX_H 17 | #define SV_NOTIFYING_COMBO_BOX_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Very trivial enhancement to QComboBox to make it emit signals when 25 | * the mouse enters and leaves (for context help). 26 | */ 27 | 28 | class NotifyingComboBox : public QComboBox 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | NotifyingComboBox(QWidget *parent = 0) : 34 | QComboBox(parent) { } 35 | 36 | virtual ~NotifyingComboBox(); 37 | 38 | signals: 39 | void mouseEntered(); 40 | void mouseLeft(); 41 | 42 | protected: 43 | void enterEvent(QEnterEvent *) override; 44 | void leaveEvent(QEvent *) override; 45 | }; 46 | 47 | } // end namespace sv 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /widgets/NotifyingTabBar.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "NotifyingTabBar.h" 17 | 18 | #include 19 | 20 | namespace sv { 21 | 22 | NotifyingTabBar::NotifyingTabBar(QWidget *parent) : 23 | QTabBar(parent) 24 | { 25 | } 26 | 27 | NotifyingTabBar::~NotifyingTabBar() 28 | { 29 | } 30 | 31 | void 32 | NotifyingTabBar::mousePressEvent(QMouseEvent *e) 33 | { 34 | int i = currentIndex(); 35 | QTabBar::mousePressEvent(e); 36 | if (currentIndex() == i) { 37 | emit activeTabClicked(); 38 | } 39 | } 40 | 41 | void 42 | NotifyingTabBar::enterEvent(QEnterEvent *e) 43 | { 44 | QTabBar::enterEvent(e); 45 | emit mouseEntered(); 46 | } 47 | 48 | void 49 | NotifyingTabBar::leaveEvent(QEvent *e) 50 | { 51 | QTabBar::leaveEvent(e); 52 | emit mouseLeft(); 53 | } 54 | 55 | } // end namespace sv 56 | 57 | -------------------------------------------------------------------------------- /layer/ShowLayerCommand.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_SHOW_LAYER_COMMAND_H 17 | #define SV_SHOW_LAYER_COMMAND_H 18 | 19 | #include "base/Command.h" 20 | 21 | namespace sv { 22 | 23 | class ShowLayerCommand : public Command 24 | { 25 | public: 26 | ShowLayerCommand(View *view, Layer *layer, bool show, QString commandName) : 27 | m_view(view), m_layer(layer), m_show(show), m_name(commandName) { } 28 | void execute() override { 29 | m_layer->showLayer(m_view, m_show); 30 | } 31 | void unexecute() override { 32 | m_layer->showLayer(m_view, !m_show); 33 | } 34 | QString getName() const override { 35 | return m_name; 36 | } 37 | protected: 38 | View *m_view; 39 | Layer *m_layer; 40 | bool m_show; 41 | QString m_name; 42 | }; 43 | 44 | } // end namespace sv 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /widgets/NotifyingPushButton.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_NOTIFYING_PUSH_BUTTON_H 17 | #define SV_NOTIFYING_PUSH_BUTTON_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Very trivial enhancement to QPushButton to make it emit signals 25 | * when the mouse enters and leaves (for context help). See also 26 | * NotifyingToolButton 27 | */ 28 | 29 | class NotifyingPushButton : public QPushButton 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | NotifyingPushButton(QWidget *parent = 0) : 35 | QPushButton(parent) { } 36 | 37 | virtual ~NotifyingPushButton(); 38 | 39 | signals: 40 | void mouseEntered(); 41 | void mouseLeft(); 42 | 43 | protected: 44 | void enterEvent(QEnterEvent *) override; 45 | void leaveEvent(QEvent *) override; 46 | }; 47 | 48 | } // end namespace sv 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /widgets/NotifyingToolButton.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_NOTIFYING_TOOL_BUTTON_H 17 | #define SV_NOTIFYING_TOOL_BUTTON_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Very trivial enhancement to QToolButton to make it emit signals 25 | * when the mouse enters and leaves (for context help). See also 26 | * NotifyingPushButton 27 | */ 28 | 29 | class NotifyingToolButton : public QToolButton 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | NotifyingToolButton(QWidget *parent = 0) : 35 | QToolButton(parent) { } 36 | 37 | virtual ~NotifyingToolButton(); 38 | 39 | signals: 40 | void mouseEntered(); 41 | void mouseLeft(); 42 | 43 | protected: 44 | void enterEvent(QEnterEvent *) override; 45 | void leaveEvent(QEvent *) override; 46 | }; 47 | 48 | } // end namespace sv 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /layer/ColourScaleLayer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef COLOUR_SCALE_LAYER_H 17 | #define COLOUR_SCALE_LAYER_H 18 | 19 | #include 20 | #include 21 | 22 | namespace sv { 23 | 24 | class LayerGeometryProvider; 25 | 26 | /** 27 | * Interface for layers in which a colour scale represents (or can 28 | * sometimes represent, depending on the display mode) the sample 29 | * value. For example, TimeValueLayer uses colour scale when in 30 | * segment mode and so provides this interface for use by the 31 | * LogColourScale or LinearColourScale scale renderers. 32 | */ 33 | class ColourScaleLayer 34 | { 35 | public: 36 | virtual ~ColourScaleLayer() { } 37 | virtual QString getScaleUnits() const = 0; 38 | virtual QColor getColourForValue(LayerGeometryProvider *v, double value) const = 0; 39 | }; 40 | 41 | } // end namespace sv 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /layer/HorizontalScaleProvider.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_HORIZONTAL_SCALE_PROVIDER_H 17 | #define SV_HORIZONTAL_SCALE_PROVIDER_H 18 | 19 | namespace sv { 20 | 21 | class LayerGeometryProvider; 22 | 23 | /** 24 | * Interface to be implemented by objects, such as layers or objects 25 | * they delegate to, in which the X axis corresponds to frequency. For 26 | * example, SpectrumLayer. 27 | */ 28 | class HorizontalScaleProvider 29 | { 30 | public: 31 | virtual ~HorizontalScaleProvider() { } 32 | 33 | virtual double getFrequencyForX(const LayerGeometryProvider *, 34 | double x) 35 | const = 0; 36 | 37 | virtual double getXForFrequency(const LayerGeometryProvider *, 38 | double freq) 39 | const = 0; 40 | }; 41 | 42 | } // end namespace sv 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /widgets/RangeInputDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_RANGE_INPUT_DIALOG_H 17 | #define SV_RANGE_INPUT_DIALOG_H 18 | 19 | #include 20 | #include 21 | 22 | class QDoubleSpinBox; 23 | 24 | namespace sv { 25 | 26 | class RangeInputDialog : public QDialog 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | RangeInputDialog(QString title, QString message, QString unit, 32 | float min, float max, QWidget *parent = 0); 33 | virtual ~RangeInputDialog(); 34 | 35 | void getRange(float &start, float &end); 36 | 37 | signals: 38 | void rangeChanged(float start, float end); 39 | 40 | public slots: 41 | void setRange(float start, float end); 42 | 43 | protected slots: 44 | void rangeStartChanged(double); 45 | void rangeEndChanged(double); 46 | 47 | protected: 48 | QDoubleSpinBox *m_rangeStart; 49 | QDoubleSpinBox *m_rangeEnd; 50 | }; 51 | 52 | } // end namespace sv 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | 0f36cdf407a684653a2b7cf496272b1d417169d4 sv1-v0.9rc1 2 | 1092181784a3a2beaaa97f5661ac4f7ef4e65f46 sv-v1.6 3 | 10eec0da9efe413ce70b99fd5a4c9d59bc163022 last-cc-copyright 4 | 272e58f0bf8b97910e35ae0d4d57f2a672533fd3 sv-v1.4 5 | 272e58f0bf8b97910e35ae0d4d57f2a672533fd3 sv-v1.4rc1 6 | 2e8194a30f40d478e7d009cd8f0c2cec2d0df7ce sv-v1.7.1 7 | 34bbbcb3c01fb752b8de786a24f2bc881b966acf sv1-1.0pre1 8 | 387f2f6fc333d85b054ec8c1e77b8b208bad4ba4 sv1-1.0pre2 9 | 3fe622570b3581341928b6ddac8244c87f2ae9bc sv1-v1.0 10 | 4cb5cd9ccac7b35b5af1dbe5e73359928a4d57bb sv1-v1.3 11 | 4cb5cd9ccac7b35b5af1dbe5e73359928a4d57bb sv1-v1.3rc1 12 | 50c0a548d23e9311e3bd8b75e56036b2ae5bf4b5 sv1-1.0pre4 13 | 5de07bba4676987e9dbfb44bb70fac71bca5628f sv1-1.0pre3 14 | 6167a28d25fcc2eff5bba06d68f97b7445cf2fb6 sv1-v1.2pre3 15 | 67f82da3d29c60d6e756d33415fce848c657af07 sv1-v1.2 16 | 8ce53683d0d7ba8c892b333c396522247aaaf007 sv1-v0.9rc2 17 | 8ebc2ce2a210514aa880ce73aa959fc25f3440d1 sv1-v1.2pre5 18 | c2ba2796cbeea309cf7657a45c29d2d79ed4fb4d sv-v1.7 19 | e6d0b097d1022d03217379c8ed0a58220a6c037f sv1-1.0rc1 20 | e6e38632e8ea1ef0a1e4d90f9160e23b1d74d45a sv-v1.5 21 | eabefd56299550f55296a2256f160e30b62db15c sv-v1.7.2 22 | eedb7f341ec5c27425e1d441e2b13ca8da287e1d sv1-v1.2pre4 23 | ff1dc4f302bd8b8b5ad01931e225bc3b70232543 sv-v1.5pre1 24 | c9d6cf9c51c8e15a06fa1f5c1678d0331dc837cb sv_v1.8 25 | 3803f6dcf361c9ec82badb20e3ca9f5c712c5d2f sv_v1.9 26 | ea786e8bd931243adc95a040988edd0d6b5bbc0a sv_v2.0 27 | c6d705bf1672f2cd7f3d4cfe46aa3db6062c004c sv_v2.1 28 | c6d705bf1672f2cd7f3d4cfe46aa3db6062c004c sv_v2.1 29 | 77fa3fdbfc7e2b9f96eac6524d48294fb47760c3 sv_v2.1 30 | -------------------------------------------------------------------------------- /layer/SliceableLayer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_SLICEABLE_LAYER_H 17 | #define SV_SLICEABLE_LAYER_H 18 | 19 | #include "Layer.h" 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Base class for layers that can be sliced, that is, that contain 25 | * models appropriate for use in a SliceLayer. 26 | */ 27 | 28 | class SliceableLayer : public Layer 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | // Get a model that can be sliced, i.e. a 34 | // DenseThreeDimensionalModel. This may be the layer's usual 35 | // model, or it may be a model derived from it (e.g. FFTModel in a 36 | // spectrogram that was constructed from a DenseTimeValueModel). 37 | // The SliceableLayer retains ownership of the model, and will 38 | // emit sliceableModelReplaced if it is about to become invalid. 39 | virtual ModelId getSliceableModel() const = 0; 40 | 41 | signals: 42 | void sliceableModelReplaced(ModelId, ModelId); 43 | }; 44 | 45 | } // end namespace sv 46 | 47 | #endif 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /widgets/WindowTypeSelector.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_WINDOW_TYPE_SELECTOR_H 17 | #define SV_WINDOW_TYPE_SELECTOR_H 18 | 19 | #include 20 | 21 | #include "base/Window.h" 22 | 23 | class QComboBox; 24 | 25 | namespace sv { 26 | 27 | class WindowShapePreview; 28 | 29 | class WindowTypeSelector : public QFrame 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | WindowTypeSelector(WindowType defaultType); 35 | WindowTypeSelector(); // get window type from preferences 36 | virtual ~WindowTypeSelector(); 37 | 38 | WindowType getWindowType() const; 39 | 40 | signals: 41 | void windowTypeChanged(WindowType type); 42 | 43 | public slots: 44 | void setWindowType(WindowType type); 45 | 46 | protected slots: 47 | void windowIndexChanged(int index); 48 | 49 | protected: 50 | QComboBox *m_windowCombo; 51 | WindowShapePreview *m_windowShape; 52 | WindowType *m_windows; 53 | WindowType m_windowType; 54 | 55 | void init(WindowType type); 56 | }; 57 | 58 | } // end namespace sv 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /widgets/ColourNameDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_COLOUR_NAME_DIALOG_H 17 | #define SV_COLOUR_NAME_DIALOG_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class QLabel; 24 | class QLineEdit; 25 | class QCheckBox; 26 | class QPushButton; 27 | 28 | namespace sv { 29 | 30 | class ColourNameDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | ColourNameDialog(QString title, QString message, QColor colour, 36 | QString defaultName, 37 | QWidget *parent = 0); 38 | 39 | void showDarkBackgroundCheckbox(QString text); 40 | 41 | QString getColourName() const; 42 | bool isDarkBackgroundChecked() const; 43 | 44 | protected slots: 45 | void darkBackgroundChanged(int); 46 | void textChanged(const QString &); 47 | 48 | protected: 49 | QColor m_colour; 50 | QLabel *m_colourLabel; 51 | QLineEdit *m_textField; 52 | QPushButton *m_okButton; 53 | QCheckBox *m_darkBackground; 54 | 55 | void fillColourLabel(); 56 | }; 57 | 58 | } // end namespace sv 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /widgets/SelectableLabel.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_SELECTABLE_LABEL_H 17 | #define SV_SELECTABLE_LABEL_H 18 | 19 | #include 20 | 21 | namespace sv { 22 | 23 | class SelectableLabel : public QLabel 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | SelectableLabel(QWidget *parent = 0); 29 | virtual ~SelectableLabel(); 30 | 31 | void setSelectedText(QString); 32 | void setUnselectedText(QString); 33 | 34 | bool isSelected() const { return m_selected; } 35 | 36 | signals: 37 | void selectionChanged(); 38 | void doubleClicked(); 39 | 40 | public slots: 41 | void setSelected(bool); 42 | void toggle(); 43 | 44 | protected: 45 | void mousePressEvent(QMouseEvent *e) override; 46 | void mouseReleaseEvent(QMouseEvent *e) override; 47 | void mouseDoubleClickEvent(QMouseEvent *e) override; 48 | void enterEvent(QEnterEvent *) override; 49 | void leaveEvent(QEvent *) override; 50 | void setupStyle(); 51 | QString m_selectedText; 52 | QString m_unselectedText; 53 | bool m_selected; 54 | bool m_swallowRelease; 55 | }; 56 | 57 | } // end namespace sv 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /widgets/CSVAudioFormatDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_CSV_AUDIO_FORMAT_DIALOG_H 17 | #define SV_CSV_AUDIO_FORMAT_DIALOG_H 18 | 19 | #include "data/fileio/CSVFormat.h" 20 | 21 | class QTableWidget; 22 | class QComboBox; 23 | class QLabel; 24 | 25 | #include 26 | 27 | namespace sv { 28 | 29 | class CSVAudioFormatDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | CSVAudioFormatDialog(QWidget *parent, 35 | CSVFormat initialFormat, 36 | int maxDisplayCols = 5); 37 | ~CSVAudioFormatDialog(); 38 | 39 | CSVFormat getFormat() const; 40 | 41 | protected slots: 42 | void sampleRateChanged(QString); 43 | void sampleRangeChanged(int); 44 | void columnPurposeChanged(int purpose); 45 | 46 | void updateFormatFromDialog(); 47 | 48 | protected: 49 | CSVFormat m_format; 50 | int m_maxDisplayCols; 51 | 52 | QComboBox *m_sampleRateCombo; 53 | QComboBox *m_sampleRangeCombo; 54 | 55 | QList m_columnPurposeCombos; 56 | int m_fuzzyColumn; 57 | }; 58 | 59 | } // end namespace sv 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /widgets/ProgressDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PROGRESS_DIALOG_H 17 | 18 | #include "base/ProgressReporter.h" 19 | 20 | class QProgressDialog; 21 | class QTimer; 22 | 23 | namespace sv { 24 | 25 | class ProgressDialog : public ProgressReporter 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | ProgressDialog(QString message, 31 | bool cancellable, 32 | int timeBeforeShow = 0, /* milliseconds */ 33 | QWidget *parent = 0, 34 | Qt::WindowModality modality = Qt::NonModal); 35 | virtual ~ProgressDialog(); 36 | 37 | bool isDefinite() const override; 38 | void setDefinite(bool definite) override; 39 | 40 | bool wasCancelled() const override; 41 | 42 | signals: 43 | void showing(); 44 | void cancelled(); 45 | 46 | public slots: 47 | void setMessage(QString text) override; 48 | void setProgress(int percentage) override; 49 | 50 | protected slots: 51 | virtual void showTimerElapsed(); 52 | void canceled(); 53 | 54 | protected: 55 | QProgressDialog *m_dialog; 56 | QTimer *m_showTimer; 57 | bool m_timerElapsed; 58 | bool m_cancelled; 59 | }; 60 | 61 | } // end namespace sv 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /widgets/MenuTitle.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_MENU_TITLE_H 16 | #define SV_MENU_TITLE_H 17 | 18 | #include "view/ViewManager.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace sv { 27 | 28 | class MenuTitle 29 | { 30 | public: 31 | static void addTitle(QMenu *m, QString text) { 32 | 33 | #ifdef Q_OS_LINUX 34 | static int leftIndent = 35 | (ViewManager::scalePixelSize(8) + 36 | qApp->style()->pixelMetric(QStyle::PM_SmallIconSize)); 37 | #else 38 | #ifdef Q_OS_WIN 39 | static int leftIndent = 40 | (9 + qApp->style()->pixelMetric(QStyle::PM_SmallIconSize)); 41 | #else 42 | static int leftIndent = 16; 43 | #endif 44 | #endif 45 | 46 | QWidgetAction *wa = new QWidgetAction(m); 47 | QLabel *title = new QLabel; 48 | title->setText(QObject::tr("%1") 49 | .arg(XmlExportable::encodeEntities(text))); 50 | title->setMargin(ViewManager::scalePixelSize(3)); 51 | title->setIndent(leftIndent); 52 | wa->setDefaultWidget(title); 53 | m->addAction(wa); 54 | m->addSeparator(); 55 | } 56 | }; 57 | 58 | } // end namespace sv 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /widgets/ListInputDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LIST_INPUT_DIALOG_H 17 | #define SV_LIST_INPUT_DIALOG_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | class QRadioButton; 26 | class QLabel; 27 | 28 | namespace sv { 29 | 30 | /** 31 | * Like QInputDialog::getItem(), except that it offers the items as a 32 | * set of radio buttons instead of in a single combo box. 33 | */ 34 | 35 | class ListInputDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | ListInputDialog(QWidget *parent, const QString &title, 41 | const QString &label, const QStringList &list, 42 | int current = 0); 43 | virtual ~ListInputDialog(); 44 | 45 | void setItemAvailability(int item, bool available); 46 | void setFootnote(QString footnote); 47 | 48 | QString getCurrentString() const; 49 | 50 | static QString getItem(QWidget *parent, const QString &title, 51 | const QString &label, const QStringList &list, 52 | int current = 0, bool *ok = 0); 53 | 54 | protected: 55 | QStringList m_strings; 56 | std::vector m_radioButtons; 57 | QLabel *m_footnote; 58 | }; 59 | 60 | } // end namespace sv 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /widgets/ImageDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_IMAGE_DIALOG_H 17 | #define SV_IMAGE_DIALOG_H 18 | 19 | #include 20 | #include 21 | 22 | class QLineEdit; 23 | class QLabel; 24 | class QPushButton; 25 | namespace sv { 26 | 27 | class FileSource; 28 | 29 | class ImageDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | ImageDialog(QString title, 35 | QString image = "", 36 | QString label = "", 37 | QWidget *parent = 0); 38 | virtual ~ImageDialog(); 39 | 40 | QString getImage(); 41 | QPixmap getPixmap(); 42 | QString getLabel(); 43 | 44 | signals: 45 | void imageChanged(QString image); 46 | void labelChanged(QString label); 47 | 48 | public slots: 49 | void setImage(QString image); 50 | void setLabel(QString label); 51 | void updatePreview(); 52 | 53 | protected slots: 54 | void browseClicked(); 55 | void imageEditEdited(const QString &); 56 | void imageEditEdited(); 57 | 58 | protected: 59 | void resizeEvent(QResizeEvent *) override; 60 | 61 | QLineEdit *m_imageEdit; 62 | QLineEdit *m_labelEdit; 63 | QLabel *m_imagePreview; 64 | 65 | QString m_loadedImageFile; 66 | QPixmap m_loadedImage; 67 | 68 | QPushButton *m_okButton; 69 | 70 | FileSource *m_remoteFile; 71 | }; 72 | 73 | } // end namespace sv 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /layer/PaintAssistant.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2007 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PAINT_ASSISTANT_H 17 | #define SV_PAINT_ASSISTANT_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "base/AudioLevel.h" 24 | 25 | class QPainter; 26 | namespace sv { 27 | 28 | class Layer; 29 | class LayerDimensionProvider; 30 | 31 | class PaintAssistant 32 | { 33 | public: 34 | enum Scale { LinearScale, MeterScale, dBScale }; 35 | 36 | static void paintVerticalLevelScale(QPainter &p, QRect rect, 37 | double minVal, double maxVal, 38 | Scale scale, AudioLevel::Quantity sort, 39 | int &multRtn, 40 | std::vector *markCoordRtns = 0); 41 | 42 | static int getYForValue(Scale scale, AudioLevel::Quantity sort, 43 | double value, double minVal, double maxVal, 44 | int minY, int height); 45 | 46 | enum TextStyle { 47 | BoxedText, 48 | OutlinedText, 49 | OutlinedItalicText 50 | }; 51 | 52 | static void drawVisibleText(const LayerDimensionProvider *, 53 | QPainter &p, int x, int y, 54 | QString text, TextStyle style); 55 | }; 56 | 57 | } // end namespace sv 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /widgets/TransformFinder.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_TRANSFORM_FINDER_H 17 | #define SV_TRANSFORM_FINDER_H 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include "transform/Transform.h" 24 | #include "transform/TransformFactory.h" 25 | 26 | class QVBoxLayout; 27 | class QScrollArea; 28 | class QLabel; 29 | class QWidget; 30 | class QTimer; 31 | 32 | namespace sv { 33 | 34 | class SelectableLabel; 35 | 36 | class TransformFinder : public QDialog 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | TransformFinder(QWidget *parent = 0); 42 | ~TransformFinder(); 43 | 44 | TransformId getTransform() const; 45 | 46 | protected slots: 47 | void searchTextChanged(const QString &); 48 | void selectedLabelChanged(); 49 | void labelDoubleClicked(); 50 | void timeout(); 51 | void up(); 52 | void down(); 53 | 54 | protected: 55 | QLabel *m_infoLabel; 56 | QLabel *m_beforeSearchLabel; 57 | QLabel *m_noResultsLabel; 58 | 59 | QScrollArea *m_resultsScroll; 60 | QWidget *m_resultsFrame; 61 | QVBoxLayout *m_resultsLayout; 62 | std::vector m_labels; 63 | TransformId m_selectedTransform; 64 | QTimer *m_timer; 65 | 66 | void setupBeforeSearchLabel(); 67 | 68 | QString m_newSearchText; 69 | typedef std::vector SortedResults; 70 | SortedResults m_sortedResults; 71 | int m_upToDateCount; 72 | }; 73 | 74 | } // end namespace sv 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /widgets/WheelCounter.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_WHEEL_COUNTER_H 16 | #define SV_WHEEL_COUNTER_H 17 | 18 | #include 19 | 20 | namespace sv { 21 | 22 | /** 23 | * Manage the little bit of tedious book-keeping associated with 24 | * translating vertical wheel events into up/down notch counts 25 | */ 26 | class WheelCounter 27 | { 28 | public: 29 | WheelCounter() : m_pendingWheelAngle(0) { } 30 | 31 | ~WheelCounter() { } 32 | 33 | int count(QWheelEvent *e) { 34 | 35 | e->accept(); 36 | 37 | int delta = e->angleDelta().y(); 38 | if (delta == 0) { 39 | return 0; 40 | } 41 | 42 | if (e->phase() == Qt::ScrollBegin || 43 | std::abs(delta) >= 120 || 44 | (delta > 0 && m_pendingWheelAngle < 0) || 45 | (delta < 0 && m_pendingWheelAngle > 0)) { 46 | m_pendingWheelAngle = delta; 47 | } else { 48 | m_pendingWheelAngle += delta; 49 | } 50 | 51 | if (abs(m_pendingWheelAngle) >= 600) { 52 | // Sometimes on Linux we're seeing absurdly extreme angles 53 | // on the first wheel event -- discard those entirely 54 | m_pendingWheelAngle = 0; 55 | return 0; 56 | } 57 | 58 | int count = m_pendingWheelAngle / 120; 59 | m_pendingWheelAngle -= count * 120; 60 | return count; 61 | } 62 | 63 | private: 64 | int m_pendingWheelAngle; 65 | }; 66 | 67 | } // end namespace sv 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /widgets/UnitConverter.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef UNIT_CONVERTER_H 16 | #define UNIT_CONVERTER_H 17 | 18 | #include 19 | 20 | #include "base/PropertyContainer.h" 21 | 22 | class QSpinBox; 23 | class QDoubleSpinBox; 24 | class QComboBox; 25 | class QLabel; 26 | 27 | namespace sv { 28 | 29 | class UnitConverter : public QDialog 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | UnitConverter(QWidget *parent = 0); 35 | virtual ~UnitConverter(); 36 | 37 | private slots: 38 | void freqChanged(); 39 | void midiChanged(); 40 | void noteChanged(); 41 | void octaveChanged(); 42 | void centsChanged(); 43 | 44 | void samplesChanged(); 45 | void periodChanged(); 46 | void bpmChanged(); 47 | void tempofreqChanged(); 48 | void samplerateChanged(); 49 | 50 | void preferenceChanged(PropertyContainer::PropertyName); 51 | 52 | private: 53 | QDoubleSpinBox *m_freq; 54 | QSpinBox *m_midi; 55 | QComboBox *m_note; 56 | QSpinBox *m_octave; 57 | QDoubleSpinBox *m_cents; 58 | QLabel *m_pitchPrefsLabel; 59 | void updatePitchesFromFreq(); 60 | void updatePitchPrefsLabel(); 61 | 62 | QDoubleSpinBox *m_samples; 63 | QDoubleSpinBox *m_period; 64 | QDoubleSpinBox *m_bpm; 65 | QDoubleSpinBox *m_tempofreq; 66 | QComboBox *m_samplerate; 67 | void updateTempiFromSamples(); 68 | 69 | double getSampleRate(); 70 | 71 | void setTo(QSpinBox *, int); 72 | void setTo(QDoubleSpinBox *, double); 73 | }; 74 | 75 | } // end namespace sv 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /widgets/ColourMapComboBox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2016 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ColourMapComboBox.h" 17 | 18 | #include "layer/ColourMapper.h" 19 | 20 | #include "base/Debug.h" 21 | 22 | #include 23 | 24 | #include 25 | 26 | using namespace std; 27 | 28 | namespace sv { 29 | 30 | ColourMapComboBox::ColourMapComboBox(bool includeSwatches, QWidget *parent) : 31 | NotifyingComboBox(parent), 32 | m_includeSwatches(includeSwatches) 33 | { 34 | setEditable(false); 35 | rebuild(); 36 | 37 | connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); 38 | 39 | if (count() < 20 && count() > maxVisibleItems()) { 40 | setMaxVisibleItems(count()); 41 | } 42 | } 43 | 44 | void 45 | ColourMapComboBox::comboActivated(int index) 46 | { 47 | emit colourMapChanged(index); 48 | } 49 | 50 | void 51 | ColourMapComboBox::rebuild() 52 | { 53 | blockSignals(true); 54 | 55 | int ix = currentIndex(); 56 | 57 | clear(); 58 | 59 | int size = (QFontMetrics(QFont()).height() * 2) / 3; 60 | if (size < 12) size = 12; 61 | 62 | for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) { 63 | QString name = ColourMapper::getColourMapLabel(i); 64 | if (m_includeSwatches) { 65 | ColourMapper mapper(i, false, 0.0, 1.0); 66 | addItem(mapper.getExamplePixmap(QSize(size * 2, size)), name); 67 | } else { 68 | addItem(name); 69 | } 70 | } 71 | 72 | setCurrentIndex(ix); 73 | 74 | blockSignals(false); 75 | } 76 | 77 | } // end namespace sv 78 | 79 | -------------------------------------------------------------------------------- /widgets/PluginParameterBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PLUGIN_PARAMETER_BOX_H 17 | #define SV_PLUGIN_PARAMETER_BOX_H 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | class QDoubleSpinBox; 26 | class QCheckBox; 27 | class QGridLayout; 28 | class QComboBox; 29 | 30 | namespace sv { 31 | 32 | class AudioDial; 33 | 34 | class PluginParameterBox : public QFrame 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | PluginParameterBox(std::shared_ptr, 40 | QWidget *parent = 0); 41 | ~PluginParameterBox(); 42 | 43 | std::shared_ptr getPlugin() { return m_plugin; } 44 | 45 | signals: 46 | void pluginConfigurationChanged(QString); 47 | 48 | protected slots: 49 | void dialChanged(int); 50 | void spinBoxChanged(double); 51 | void checkBoxChanged(int); 52 | void programComboChanged(const QString &); 53 | 54 | protected: 55 | void populate(); 56 | void updateProgramCombo(); 57 | 58 | QGridLayout *m_layout; 59 | std::shared_ptr m_plugin; 60 | 61 | struct ParamRec { 62 | AudioDial *dial; 63 | QDoubleSpinBox *spin; 64 | QCheckBox *check; 65 | QComboBox *combo; 66 | Vamp::PluginBase::ParameterDescriptor param; 67 | }; 68 | 69 | QComboBox *m_programCombo; 70 | 71 | std::map m_params; 72 | std::map m_nameMap; 73 | Vamp::PluginBase::ProgramList m_programs; 74 | }; 75 | 76 | } // end namespace sv 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /widgets/WidgetScale.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_WIDGET_SCALE_H 16 | #define SV_WIDGET_SCALE_H 17 | 18 | #include 19 | #include 20 | 21 | #include "base/Debug.h" 22 | 23 | namespace sv { 24 | 25 | class WidgetScale 26 | { 27 | public: 28 | /** 29 | * Take a "design pixel" size and scale it for the actual 30 | * display. This is relevant to hi-dpi systems that do not do 31 | * pixel doubling (i.e. Windows and Linux rather than OS/X). 32 | */ 33 | static int scalePixelSize(int pixels) { 34 | 35 | static double ratio = 0.0; 36 | if (ratio == 0.0) { 37 | double baseEm; 38 | #ifdef Q_OS_MAC 39 | baseEm = 17.0; 40 | #else 41 | baseEm = 15.0; 42 | #endif 43 | double em = QFontMetrics(QFont()).height(); 44 | ratio = em / baseEm; 45 | SVDEBUG << "WidgetScale::scalePixelSize: baseEm = " << baseEm 46 | << ", platform default font height = " << em 47 | << ", resulting scale factor = " << ratio << endl; 48 | if (ratio < 1.0) { 49 | SVDEBUG << "WidgetScale::scalePixelSize: rounding up to 1.0" 50 | << endl; 51 | ratio = 1.0; 52 | } 53 | } 54 | 55 | int scaled = int(pixels * ratio + 0.5); 56 | if (pixels != 0 && scaled == 0) scaled = 1; 57 | return scaled; 58 | } 59 | 60 | static QSize scaleQSize(QSize size) { 61 | return QSize(scalePixelSize(size.width()), 62 | scalePixelSize(size.height())); 63 | } 64 | }; 65 | 66 | } // end namespace sv 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /view/AlignmentView.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2014 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef ALIGNMENT_VIEW_H 17 | #define ALIGNMENT_VIEW_H 18 | 19 | #include "View.h" 20 | 21 | namespace sv { 22 | 23 | class AlignmentView : public View 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | AlignmentView(QWidget *parent = 0); 29 | QString getPropertyContainerIconName() const override { return "alignment"; } 30 | 31 | void setAboveView(View *view); 32 | void setBelowView(View *view); 33 | void setReferenceView(View *view); 34 | 35 | public slots: 36 | void globalCentreFrameChanged(sv_frame_t) override; 37 | void viewCentreFrameChanged(View *, sv_frame_t) override; 38 | 39 | virtual void viewAboveZoomLevelChanged(ZoomLevel, bool); 40 | virtual void viewBelowZoomLevelChanged(ZoomLevel, bool); 41 | 42 | void viewManagerPlaybackFrameChanged(sv_frame_t) override; 43 | 44 | void keyFramesChanged(); 45 | 46 | protected: 47 | void paintEvent(QPaintEvent *e) override; 48 | bool shouldLabelSelections() const override { return false; } 49 | 50 | void buildMaps(); 51 | 52 | std::vector getKeyFrames(View *, sv_frame_t &resolution); 53 | std::vector getDefaultKeyFrames(); 54 | 55 | ModelId getSalientModel(View *); 56 | 57 | void reconnectModels(); 58 | 59 | View *m_above; 60 | View *m_below; 61 | View *m_reference; 62 | 63 | QMutex m_mapsMutex; 64 | std::multimap m_fromAboveMap; 65 | std::multimap m_fromReferenceMap; 66 | sv_frame_t m_leftmostAbove; 67 | sv_frame_t m_rightmostAbove; 68 | }; 69 | 70 | } // end namespace sv 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /widgets/ColourComboBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2016 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_COLOUR_COMBO_BOX_H 17 | #define SV_COLOUR_COMBO_BOX_H 18 | 19 | #include "NotifyingComboBox.h" 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Colour-picker combo box with swatches, optionally including "Add 25 | * New Colour..." entry to invoke a QColorDialog/ColourNameDialog 26 | */ 27 | class ColourComboBox : public NotifyingComboBox 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | ColourComboBox(bool withAddNewColourEntry, QWidget *parent = 0); 33 | 34 | /** 35 | * Add an entry at the top of the combo for "no colour selected", 36 | * with the given label. 37 | */ 38 | void includeUnsetEntry(QString label); 39 | 40 | /** 41 | * Get the current colour index. This is the same as 42 | * QComboBox::currentIndex() if there is no unset entry, or 1 less 43 | * than it if includeUnsetEntry() has been used. So if there is an 44 | * unset entry, and it is selected, this returns -1. 45 | */ 46 | int getCurrentColourIndex() const { 47 | int index = currentIndex(); 48 | if (m_unsetEntry == "") { 49 | return index; 50 | } else { 51 | return index - 1; 52 | } 53 | } 54 | 55 | signals: 56 | /** 57 | * Emitted when the current index is changed. The argument is the 58 | * value returned by getCurrentColourIndex() 59 | */ 60 | void colourChanged(int colourIndex); 61 | 62 | private slots: 63 | void rebuild(); 64 | void comboActivated(int); 65 | 66 | private: 67 | bool m_withAddNewColourEntry; 68 | QString m_unsetEntry; 69 | }; 70 | 71 | } // end namespace sv 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /widgets/ModelDataTableDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_MODEL_DATA_TABLE_DIALOG_H 17 | #define SV_MODEL_DATA_TABLE_DIALOG_H 18 | 19 | #include 20 | 21 | #include "base/BaseTypes.h" 22 | 23 | #include "data/model/Model.h" 24 | 25 | class QTableView; 26 | class QModelIndex; 27 | class QToolBar; 28 | class QLineEdit; 29 | 30 | namespace sv { 31 | 32 | class ModelDataTableModel; 33 | class Command; 34 | 35 | class ModelDataTableDialog : public QMainWindow 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | ModelDataTableDialog(ModelId tabularModelId, 41 | QString title, QWidget *parent =0); 42 | ~ModelDataTableDialog(); 43 | 44 | QToolBar *getPlayToolbar() { return m_playToolbar; } 45 | 46 | signals: 47 | void scrollToFrame(sv_frame_t frame); 48 | 49 | public slots: 50 | void userScrolledToFrame(sv_frame_t frame); 51 | void playbackScrolledToFrame(sv_frame_t frame); 52 | void addCommand(Command *); 53 | 54 | protected slots: 55 | void viewClicked(const QModelIndex &); 56 | void viewPressed(const QModelIndex &); 57 | void currentChanged(const QModelIndex &, const QModelIndex &); 58 | void currentChangedThroughResort(const QModelIndex &); 59 | void searchTextChanged(const QString &); 60 | void searchRepeated(); 61 | 62 | void insertRow(); 63 | void deleteRows(); 64 | void editRow(); 65 | void togglePlayTracking(); 66 | 67 | void modelRemoved(); 68 | 69 | protected: 70 | void makeCurrent(int row); 71 | ModelDataTableModel *m_table; 72 | QToolBar *m_playToolbar; 73 | QTableView *m_tableView; 74 | QLineEdit *m_find; 75 | int m_currentRow; 76 | bool m_trackPlayback; 77 | }; 78 | 79 | } // end namespace sv 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /widgets/PluginPathConfigurator.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_PLUGIN_PATH_CONFIGURATOR_H 16 | #define SV_PLUGIN_PATH_CONFIGURATOR_H 17 | 18 | #include 19 | #include 20 | 21 | class QLabel; 22 | class QWidget; 23 | class QListWidget; 24 | class QPushButton; 25 | class QGridLayout; 26 | class QComboBox; 27 | class QCheckBox; 28 | 29 | #include "plugin/PluginPathSetter.h" 30 | 31 | namespace sv { 32 | 33 | class PluginPathConfigurator : public QFrame 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | PluginPathConfigurator(QWidget *parent = 0); 39 | ~PluginPathConfigurator(); 40 | 41 | void setPaths(PluginPathSetter::Paths paths); 42 | PluginPathSetter::Paths getPaths() const { return m_paths; } 43 | 44 | signals: 45 | void pathsChanged(); 46 | 47 | private slots: 48 | void upClicked(); 49 | void downClicked(); 50 | void addClicked(); 51 | void deleteClicked(); 52 | void resetClicked(); 53 | void currentTypeChanged(QString); 54 | void currentLocationChanged(int); 55 | void envOverrideChanged(int); 56 | void seePluginsClicked(); 57 | 58 | private: 59 | QGridLayout *m_layout; 60 | QLabel *m_header; 61 | QComboBox *m_pluginTypeSelector; 62 | QListWidget *m_list; 63 | QPushButton *m_seePlugins; 64 | QPushButton *m_up; 65 | QPushButton *m_down; 66 | QPushButton *m_add; 67 | QPushButton *m_delete; 68 | QPushButton *m_reset; 69 | QCheckBox *m_envOverride; 70 | 71 | PluginPathSetter::Paths m_paths; 72 | PluginPathSetter::Paths m_defaultPaths; 73 | 74 | void populate(); 75 | void populateFor(PluginPathSetter::TypeKey, int makeCurrent); 76 | 77 | QString getLabelFor(PluginPathSetter::TypeKey); 78 | PluginPathSetter::TypeKey getKeyForLabel(QString label); 79 | }; 80 | 81 | } // end namespace sv 82 | 83 | #endif 84 | 85 | 86 | -------------------------------------------------------------------------------- /layer/VerticalBinLayer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2016 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef VERTICAL_BIN_LAYER_H 17 | #define VERTICAL_BIN_LAYER_H 18 | 19 | #include "SliceableLayer.h" 20 | 21 | namespace sv { 22 | 23 | /** 24 | * Interface for layers in which the Y axis corresponds to bin number 25 | * rather than scale value. Colour3DPlotLayer and SpectrogramLayer are 26 | * obvious examples. Conceptually these are always SliceableLayers as 27 | * well, and this subclasses from SliceableLayer to avoid a big 28 | * inheritance mess. 29 | */ 30 | class VerticalBinLayer : public SliceableLayer 31 | { 32 | public: 33 | /** 34 | * Return the y coordinate at which the given bin "starts" 35 | * (i.e. at the bottom of the bin, if the given bin is an integer 36 | * and the vertical scale is the usual way up). Bin number may be 37 | * fractional, to obtain a position part-way through a bin. 38 | */ 39 | virtual double getYForBin(const LayerGeometryProvider *, double bin) const = 0; 40 | 41 | /** 42 | * As getYForBin, but rounding to integer values. 43 | */ 44 | virtual int getIYForBin(const LayerGeometryProvider *v, int bin) const { 45 | return int(round(getYForBin(v, bin))); 46 | } 47 | 48 | /** 49 | * Return the bin number, possibly fractional, at the given y 50 | * coordinate. Note that the whole numbers occur at the positions 51 | * at which the bins "start" (i.e. the bottom of the visible bin, 52 | * if the vertical scale is the usual way up). 53 | */ 54 | virtual double getBinForY(const LayerGeometryProvider *, double y) const = 0; 55 | 56 | /** 57 | * As getBinForY, but rounding to integer values. 58 | */ 59 | virtual int getIBinForY(const LayerGeometryProvider *v, int y) const { 60 | return int(floor(getBinForY(v, y))); 61 | } 62 | }; 63 | 64 | } // end namespace sv 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /widgets/MIDIFileImportDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #include "MIDIFileImportDialog.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace sv { 21 | 22 | MIDIFileImportDialog::MIDIFileImportDialog(QWidget *parent) : 23 | m_parent(parent) 24 | { 25 | } 26 | 27 | MIDIFileImportDialog::TrackPreference 28 | MIDIFileImportDialog::getTrackImportPreference(QStringList displayNames, 29 | bool haveSomePercussion, 30 | QString &singleTrack) const 31 | { 32 | QStringList available; 33 | 34 | QString allTracks = tr("Merge all tracks"); 35 | QString allNonPercussion = tr("Merge all non-percussion tracks"); 36 | 37 | singleTrack = ""; 38 | 39 | available << allTracks; 40 | 41 | if (haveSomePercussion) { 42 | available << allNonPercussion; 43 | } 44 | 45 | available << displayNames; 46 | 47 | bool ok = false; 48 | QString selected = QInputDialog::getItem 49 | (nullptr, tr("Select track or tracks to import"), 50 | tr("Select track to import

You can only import this file as a single annotation layer, but the file contains more than one track, or notes on more than one channel.

Please select the track or merged tracks you wish to import:"), 51 | available, 0, false, &ok); 52 | 53 | if (!ok || selected.isEmpty()) return ImportNothing; 54 | 55 | TrackPreference pref; 56 | if (selected == allTracks) pref = MergeAllTracks; 57 | else if (selected == allNonPercussion) pref = MergeAllNonPercussionTracks; 58 | else { 59 | singleTrack = selected; 60 | pref = ImportSingleTrack; 61 | } 62 | 63 | return pref; 64 | } 65 | 66 | void 67 | MIDIFileImportDialog::showError(QString error) 68 | { 69 | QMessageBox::critical(nullptr, tr("Error in MIDI file import"), error); 70 | } 71 | 72 | } // end namespace sv 73 | 74 | -------------------------------------------------------------------------------- /widgets/PropertyStack.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PROPERTY_STACK_H 17 | #define SV_PROPERTY_STACK_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace sv { 24 | 25 | class Layer; 26 | class View; 27 | class PropertyBox; 28 | class PropertyContainer; 29 | 30 | class PropertyStack : public QTabWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | PropertyStack(QWidget *parent, View *client); 36 | virtual ~PropertyStack(); 37 | 38 | View *getClient() { return m_client; } 39 | bool containsContainer(PropertyContainer *container) const; 40 | int getContainerIndex(PropertyContainer *container) const; 41 | 42 | signals: 43 | void viewSelected(View *client); 44 | void propertyContainerSelected(View *client, PropertyContainer *container); 45 | void propertyContainerContextMenuRequested(View *client, 46 | PropertyContainer *container, 47 | QPoint pos); 48 | void contextHelpChanged(const QString &); 49 | 50 | public slots: 51 | void propertyContainerAdded(PropertyContainer *); 52 | void propertyContainerRemoved(PropertyContainer *); 53 | void propertyContainerPropertyChanged(PropertyContainer *); 54 | void propertyContainerPropertyRangeChanged(PropertyContainer *); 55 | void propertyContainerNameChanged(PropertyContainer *); 56 | 57 | void showLayer(bool); 58 | 59 | void mouseEnteredTabBar(); 60 | void mouseLeftTabBar(); 61 | void activeTabClicked(); 62 | void tabBarContextMenuRequested(const QPoint &); 63 | 64 | protected slots: 65 | void selectedContainerChanged(int); 66 | 67 | protected: 68 | View *m_client; 69 | std::vector m_boxes; 70 | 71 | void repopulate(); 72 | void updateValues(PropertyContainer *); 73 | }; 74 | 75 | } // end namespace sv 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /widgets/Fader.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef FADER_H 16 | #define FADER_H 17 | 18 | /** 19 | * Horizontal audio fader and meter widget. 20 | * Based on the vertical fader and meter widget from: 21 | * 22 | * Hydrogen 23 | * Copyright(c) 2002-2005 by Alex >Comix< Cominu [comix@users.sourceforge.net] 24 | * http://www.hydrogen-music.org 25 | */ 26 | 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "base/Debug.h" 38 | 39 | namespace sv { 40 | 41 | class Fader : public QWidget 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | Fader(QWidget *parent, bool withoutKnob = false); 47 | ~Fader(); 48 | 49 | void setValue(float newValue); 50 | float getValue(); 51 | 52 | void setPeakLeft(float); 53 | float getPeakLeft() { return m_peakLeft; } 54 | 55 | void setPeakRight(float); 56 | float getPeakRight() { return m_peakRight; } 57 | 58 | signals: 59 | void valueChanged(float); // 0.0 -> 1.0 60 | 61 | void mouseEntered(); 62 | void mouseLeft(); 63 | 64 | protected: 65 | void mousePressEvent(QMouseEvent *ev) override; 66 | void mouseDoubleClickEvent(QMouseEvent *ev) override; 67 | void mouseMoveEvent(QMouseEvent *ev) override; 68 | void mouseReleaseEvent(QMouseEvent *ev) override; 69 | void wheelEvent( QWheelEvent *ev ) override; 70 | void paintEvent(QPaintEvent *ev) override; 71 | void enterEvent(QEnterEvent *) override; 72 | void leaveEvent(QEvent *) override; 73 | 74 | int getMaxX() const; 75 | 76 | bool m_withoutKnob; 77 | float m_value; 78 | float m_peakLeft; 79 | float m_peakRight; 80 | 81 | bool m_mousePressed; 82 | int m_mousePressX; 83 | float m_mousePressValue; 84 | 85 | QPixmap m_back; 86 | QPixmap m_leds; 87 | QPixmap m_knob; 88 | QPixmap m_clip; 89 | }; 90 | 91 | } 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /widgets/TipDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_TIP_DIALOG_H 17 | #define SV_TIP_DIALOG_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "base/Debug.h" 26 | 27 | class QLabel; 28 | class QXmlInputSource; 29 | 30 | namespace sv { 31 | 32 | class TipDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | TipDialog(QWidget *parent = 0); 38 | virtual ~TipDialog(); 39 | 40 | bool isOK() { return !m_tips.empty(); } 41 | 42 | protected slots: 43 | void previous(); 44 | void next(); 45 | 46 | protected: 47 | int m_tipNumber; 48 | QLabel *m_label; 49 | QString m_caption; 50 | 51 | std::vector m_tips; 52 | 53 | void readTips(); 54 | void showTip(); 55 | 56 | class TipFileParser : public QXmlDefaultHandler 57 | { 58 | public: 59 | TipFileParser(TipDialog *dialog); 60 | virtual ~TipFileParser(); 61 | 62 | void parse(QXmlInputSource &source); 63 | 64 | bool startElement(const QString &namespaceURI, 65 | const QString &localName, 66 | const QString &qName, 67 | const QXmlAttributes& atts) override; 68 | 69 | bool characters(const QString &) override; 70 | 71 | bool endElement(const QString &namespaceURI, 72 | const QString &localName, 73 | const QString &qName) override; 74 | 75 | bool error(const QXmlParseException &exception) override; 76 | bool fatalError(const QXmlParseException &exception) override; 77 | 78 | protected: 79 | TipDialog *m_dialog; 80 | 81 | bool m_inTip; 82 | bool m_inText; 83 | bool m_inHtml; 84 | }; 85 | }; 86 | 87 | } // end namespace sv 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /view/Overview.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_OVERVIEW_H 17 | #define SV_OVERVIEW_H 18 | 19 | #include "View.h" 20 | 21 | #include 22 | #include 23 | 24 | class QWidget; 25 | class QPaintEvent; 26 | namespace sv { 27 | 28 | class Layer; 29 | class View; 30 | 31 | #include 32 | 33 | class Overview : public View 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | Overview(QWidget *parent = 0); 39 | 40 | void registerView(View *view); 41 | void unregisterView(View *view); 42 | 43 | QString getPropertyContainerIconName() const override { return "panner"; } 44 | 45 | public slots: 46 | void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame) override; 47 | void modelReplaced() override; 48 | 49 | void globalCentreFrameChanged(sv_frame_t) override; 50 | void viewCentreFrameChanged(View *, sv_frame_t) override; 51 | void viewZoomLevelChanged(View *, ZoomLevel, bool) override; 52 | void viewManagerPlaybackFrameChanged(sv_frame_t) override; 53 | 54 | virtual void setBoxColour(QColor); 55 | 56 | protected: 57 | void paintEvent(QPaintEvent *e) override; 58 | void mousePressEvent(QMouseEvent *e) override; 59 | void mouseReleaseEvent(QMouseEvent *e) override; 60 | void mouseMoveEvent(QMouseEvent *e) override; 61 | void mouseDoubleClickEvent(QMouseEvent *e) override; 62 | void enterEvent(QEnterEvent *) override; 63 | void leaveEvent(QEvent *) override; 64 | bool shouldLabelSelections() const override { return false; } 65 | 66 | QColor getFillWithin() const; 67 | QColor getFillWithout() const; 68 | 69 | QPoint m_clickPos; 70 | QPoint m_mousePos; 71 | bool m_clickedInRange; 72 | sv_frame_t m_dragCentreFrame; 73 | QElapsedTimer m_modelTestTimer; 74 | QColor m_boxColour; 75 | 76 | typedef std::set ViewSet; 77 | ViewSet m_views; 78 | }; 79 | 80 | } // end namespace sv 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /layer/HorizontalFrequencyScale.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "HorizontalFrequencyScale.h" 17 | #include "HorizontalScaleProvider.h" 18 | #include "LayerGeometryProvider.h" 19 | 20 | #include "base/ScaleTickIntervals.h" 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace sv { 27 | 28 | int 29 | HorizontalFrequencyScale::getHeight(LayerGeometryProvider *, 30 | QPainter &paint) 31 | { 32 | return paint.fontMetrics().height() + 10; 33 | } 34 | 35 | void 36 | HorizontalFrequencyScale::paintScale(LayerGeometryProvider *v, 37 | const HorizontalScaleProvider *p, 38 | QPainter &paint, 39 | QRect r, 40 | bool logarithmic) 41 | { 42 | int x0 = r.x(), y0 = r.y(), x1 = r.x() + r.width(), y1 = r.y() + r.height(); 43 | 44 | paint.drawLine(x0, y0, x1, y0); 45 | 46 | double f0 = p->getFrequencyForX(v, x0 ? x0 : 1); 47 | double f1 = p->getFrequencyForX(v, x1); 48 | 49 | int n = 20; 50 | 51 | auto ticks = 52 | logarithmic ? 53 | ScaleTickIntervals::logarithmic({ f0, f1, n }) : 54 | ScaleTickIntervals::linear({ f0, f1, n }); 55 | 56 | n = int(ticks.size()); 57 | 58 | int marginx = -1; 59 | 60 | for (int i = 0; i < n; ++i) { 61 | 62 | double val = ticks[i].value; 63 | QString label = QString::fromStdString(ticks[i].label); 64 | int tw = paint.fontMetrics().horizontalAdvance(label); 65 | 66 | int x = int(round(p->getXForFrequency(v, val))); 67 | 68 | if (x < marginx) continue; 69 | 70 | //!!! todo: pixel scaling (here & elsewhere in these classes) 71 | 72 | paint.drawLine(x, y0, x, y1); 73 | 74 | paint.drawText(x + 5, y0 + paint.fontMetrics().ascent() + 5, label); 75 | 76 | marginx = x + tw + 10; 77 | } 78 | } 79 | 80 | } // end namespace sv 81 | 82 | -------------------------------------------------------------------------------- /widgets/LEDButton.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | /* 16 | This is a modified version of a source file from the KDE 17 | libraries. Copyright (c) 1998-2004 Joerg Habenicht, Richard J 18 | Moore and others, distributed under the GNU Lesser General Public 19 | License. 20 | 21 | Ported to Qt4 by Chris Cannam. 22 | 23 | The original KDE widget comes in round and rectangular and flat, 24 | raised, and sunken variants. This version retains only the round 25 | sunken variant. This version also implements a simple button API. 26 | */ 27 | 28 | #ifndef SV_LED_BUTTON_H 29 | #define SV_LED_BUTTON_H 30 | 31 | #include 32 | #include "base/Debug.h" 33 | 34 | class QColor; 35 | 36 | namespace sv { 37 | 38 | class LEDButton : public QWidget 39 | { 40 | Q_OBJECT 41 | Q_PROPERTY(QColor color READ color WRITE setColor) 42 | Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) 43 | 44 | public: 45 | LEDButton(QWidget *parent = 0); 46 | LEDButton(const QColor &col, QWidget *parent = 0); 47 | LEDButton(const QColor& col, bool state, QWidget *parent = 0); 48 | ~LEDButton(); 49 | 50 | bool state() const; 51 | QColor color() const; 52 | int darkFactor() const; 53 | 54 | QSize sizeHint() const override; 55 | QSize minimumSizeHint() const override; 56 | 57 | signals: 58 | void stateChanged(bool); 59 | 60 | void mouseEntered(); 61 | void mouseLeft(); 62 | 63 | public slots: 64 | void toggle(); 65 | void on(); 66 | void off(); 67 | 68 | void setState(bool); 69 | void toggleState(); 70 | void setColor(const QColor& color); 71 | void setDarkFactor(int darkfactor); 72 | 73 | protected: 74 | void paintEvent(QPaintEvent *) override; 75 | void mousePressEvent(QMouseEvent *) override; 76 | void enterEvent(QEnterEvent *) override; 77 | void leaveEvent(QEvent *) override; 78 | 79 | bool led_state; 80 | QColor led_color; 81 | 82 | class LEDButtonPrivate; 83 | LEDButtonPrivate *d; 84 | }; 85 | 86 | } // end namespace sv 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /layer/TimeRulerLayer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_TIME_RULER_H 17 | #define SV_TIME_RULER_H 18 | 19 | #include "SingleColourLayer.h" 20 | 21 | #include 22 | #include 23 | 24 | class QPainter; 25 | 26 | namespace sv { 27 | 28 | class View; 29 | class Model; 30 | 31 | class TimeRulerLayer : public SingleColourLayer 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | TimeRulerLayer(); 37 | 38 | void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override; 39 | 40 | void setModel(ModelId); 41 | ModelId getModel() const override { return m_model; } 42 | 43 | enum LabelHeight { LabelTop, LabelMiddle, LabelBottom }; 44 | void setLabelHeight(LabelHeight h) { m_labelHeight = h; } 45 | LabelHeight getLabelHeight() const { return m_labelHeight; } 46 | 47 | bool snapToFeatureFrame(LayerGeometryProvider *, sv_frame_t &, int &, 48 | SnapType, int) const override; 49 | 50 | ColourSignificance getLayerColourSignificance() const override { 51 | return ColourIrrelevant; 52 | } 53 | 54 | ScaleExtents getVerticalExtents() const override { 55 | return NO_VERTICAL_EXTENTS; 56 | } 57 | 58 | QString getLayerPresentationName() const override; 59 | 60 | int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const override { return 0; } 61 | 62 | void toXml(QTextStream &stream, QString indent = "", 63 | QString extraAttributes = "") const override; 64 | 65 | void setProperties(const LayerAttributes &attributes) override; 66 | 67 | bool canExistWithoutModel() const override { return true; } 68 | 69 | protected: 70 | ModelId m_model; 71 | LabelHeight m_labelHeight; 72 | 73 | int getDefaultColourHint(bool dark, bool &impose) override; 74 | 75 | int64_t getMajorTickUSec(LayerGeometryProvider *, bool &quarterTicks) const; 76 | int getXForUSec(LayerGeometryProvider *, double usec) const; 77 | }; 78 | 79 | } // end namespace sv 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /layer/LinearNumericalScale.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LinearNumericalScale.h" 17 | #include "LayerGeometryProvider.h" 18 | #include "CoordinateScale.h" 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "base/ScaleTickIntervals.h" 25 | 26 | namespace sv { 27 | 28 | int 29 | LinearNumericalScale::getWidth(LayerDimensionProvider *, 30 | QPainter &paint) 31 | { 32 | return paint.fontMetrics().horizontalAdvance("-000.00") + 10; 33 | } 34 | 35 | void 36 | LinearNumericalScale::paintVertical(LayerDimensionProvider *v, 37 | const CoordinateScale &scale, 38 | QPainter &paint, 39 | int x0) 40 | { 41 | int n = 10; 42 | double minf = scale.getDisplayMinimum(); 43 | double maxf = scale.getDisplayMaximum(); 44 | auto ticks = ScaleTickIntervals::linear({ minf, maxf, n }); 45 | n = int(ticks.size()); 46 | 47 | int w = getWidth(v, paint) + x0; 48 | 49 | int prevy = -1; 50 | 51 | for (int i = 0; i < n; ++i) { 52 | 53 | int y, ty; 54 | bool drawText = true; 55 | 56 | if (i == n-1 && 57 | v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { 58 | if (scale.getUnit() != "") drawText = false; 59 | } 60 | 61 | double val = ticks[i].value; 62 | QString label = QString::fromStdString(ticks[i].label); 63 | 64 | y = scale.getCoordForValueRounded(v, val); 65 | 66 | ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; 67 | 68 | if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { 69 | continue; 70 | } 71 | 72 | paint.drawLine(w - 5, y, w, y); 73 | 74 | if (drawText) { 75 | paint.drawText(w - paint.fontMetrics().horizontalAdvance(label) - 6, 76 | ty, label); 77 | } 78 | 79 | prevy = y; 80 | } 81 | } 82 | } // end namespace sv 83 | 84 | -------------------------------------------------------------------------------- /layer/LogNumericalScale.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2018 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LogNumericalScale.h" 17 | #include "LayerGeometryProvider.h" 18 | #include "CoordinateScale.h" 19 | 20 | #include "base/LogRange.h" 21 | #include "base/ScaleTickIntervals.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace sv { 28 | 29 | int 30 | LogNumericalScale::getWidth(LayerDimensionProvider *, 31 | QPainter &paint) 32 | { 33 | return paint.fontMetrics().horizontalAdvance("-000.00") + 10; 34 | } 35 | 36 | void 37 | LogNumericalScale::paintVertical(LayerDimensionProvider *v, 38 | const CoordinateScale &scale, 39 | QPainter &paint, 40 | int x0) 41 | { 42 | int n = 10; 43 | double minf = scale.getDisplayMinimum(); 44 | double maxf = scale.getDisplayMaximum(); 45 | auto ticks = ScaleTickIntervals::logarithmic({ minf, maxf, n }); 46 | n = int(ticks.size()); 47 | 48 | int w = getWidth(v, paint) + x0; 49 | 50 | int prevy = -1; 51 | 52 | for (int i = 0; i < n; ++i) { 53 | 54 | int y, ty; 55 | bool drawText = true; 56 | 57 | if (i == n-1 && 58 | v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { 59 | if (scale.getUnit() != "") drawText = false; 60 | } 61 | 62 | double val = ticks[i].value; 63 | QString label = QString::fromStdString(ticks[i].label); 64 | 65 | y = scale.getCoordForValueRounded(v, val); 66 | 67 | ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; 68 | 69 | if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { 70 | continue; 71 | } 72 | 73 | paint.drawLine(w - 5, y, w, y); 74 | 75 | if (drawText) { 76 | paint.drawText(w - paint.fontMetrics().horizontalAdvance(label) - 6, 77 | ty, label); 78 | } 79 | 80 | prevy = y; 81 | } 82 | } 83 | 84 | } // end namespace sv 85 | 86 | -------------------------------------------------------------------------------- /widgets/InteractiveFileFinder.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_INTERACTIVE_FILE_FINDER_H 17 | #define SV_INTERACTIVE_FILE_FINDER_H 18 | 19 | #include "data/fileio/FileFinder.h" 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace sv { 26 | 27 | class InteractiveFileFinder : public QObject, 28 | public FileFinder 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | virtual ~InteractiveFileFinder(); 34 | 35 | /// Specify the extension for this application's session files 36 | /// (without the dot) 37 | void setApplicationSessionExtension(QString extension); 38 | 39 | QString getApplicationSessionExtension() const { 40 | return m_sessionExtension; 41 | } 42 | 43 | QString getOpenFileName(FileType type, 44 | QString fallbackLocation = "") override; 45 | 46 | QStringList getOpenFileNames(FileType type, 47 | QString fallbackLocation = "") override; 48 | 49 | QString getSaveFileName(FileType type, 50 | QString fallbackLocation = "") override; 51 | 52 | void registerLastOpenedFilePath(FileType type, 53 | QString path) override; 54 | 55 | QString find(FileType type, 56 | QString location, 57 | QString lastKnownLocation = "") override; 58 | 59 | static void setParentWidget(QWidget *); 60 | 61 | static InteractiveFileFinder *getInstance() { return &m_instance; } 62 | 63 | protected: 64 | InteractiveFileFinder(); 65 | static InteractiveFileFinder m_instance; 66 | 67 | QString findRelative(QString location, QString relativeTo); 68 | QString locateInteractive(FileType type, QString thing); 69 | 70 | QStringList getOpenFileNames(FileType type, 71 | QString fallbackLocation, 72 | bool multiple); 73 | 74 | QString m_sessionExtension; 75 | QString m_lastLocatedLocation; 76 | 77 | QWidget *m_parent; 78 | }; 79 | 80 | } // end namespace sv 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /widgets/SubdividingMenu.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_SUBDIVIDING_MENU_H 17 | #define SV_SUBDIVIDING_MENU_H 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace sv { 26 | 27 | /** 28 | * A menu that divides its entries into submenus, alphabetically. For 29 | * menus that may contain a very large or small number of named items 30 | * (e.g. plugins). 31 | * 32 | * The menu needs to be told, before any of the actions are added, 33 | * what the set of entry strings will be, so it can determine a 34 | * reasonable categorisation. Do this by calling the setEntries() 35 | * method. If it isn't practical to do this in advance, then add the 36 | * entries and call entriesAdded() afterwards instead. 37 | */ 38 | 39 | class SubdividingMenu : public QMenu 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | SubdividingMenu(int lowerLimit = 0, int upperLimit = 0, 45 | QWidget *parent = 0); 46 | SubdividingMenu(const QString &title, int lowerLimit = 0, 47 | int upperLimit = 0, QWidget *parent = 0); 48 | virtual ~SubdividingMenu(); 49 | 50 | void setEntries(const std::set &entries); 51 | void entriesAdded(); 52 | 53 | // Action names and strings passed to addAction and addMenu must 54 | // appear in the set previously given to setEntries. If you want 55 | // to use a different string, use the two-argument method and pass 56 | // the entry string (used to determine which submenu the action 57 | // ends up on) as the first argument. 58 | 59 | virtual void addAction(QAction *); 60 | virtual QAction *addAction(const QString &); 61 | virtual void addAction(const QString &entry, QAction *); 62 | 63 | virtual void addMenu(QMenu *); 64 | virtual QMenu *addMenu(const QString &); 65 | virtual void addMenu(const QString &entry, QMenu *); 66 | 67 | protected: 68 | std::map m_nameToChunkMenuMap; 69 | 70 | int m_lowerLimit; 71 | int m_upperLimit; 72 | 73 | bool m_entriesSet; 74 | std::map m_pendingEntries; 75 | }; 76 | 77 | } // end namespace sv 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /widgets/ActivityLog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2009 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ActivityLog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "base/Debug.h" 29 | 30 | namespace sv { 31 | 32 | using std::cerr; 33 | using std::endl; 34 | 35 | //#ifndef NO_PRINT_ACTIVITY 36 | //#define PRINT_ACTIVITY 1 37 | //#endif 38 | 39 | ActivityLog::ActivityLog() : QDialog() 40 | { 41 | setWindowTitle(tr("Activity Log")); 42 | 43 | QGridLayout *layout = new QGridLayout; 44 | setLayout(layout); 45 | 46 | layout->addWidget(new QLabel(tr("

Activity Log lists your interactions and other events within %1.

").arg(QApplication::applicationName())), 0, 0); 47 | 48 | m_listView = new QListView; 49 | m_model = new QStringListModel; 50 | m_listView->setModel(m_model); 51 | layout->addWidget(m_listView, 1, 0); 52 | layout->setRowStretch(1, 10); 53 | 54 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); 55 | connect(bb, SIGNAL(rejected()), this, SLOT(hide())); 56 | layout->addWidget(bb, 2, 0); 57 | } 58 | 59 | ActivityLog::~ActivityLog() 60 | { 61 | } 62 | 63 | void 64 | ActivityLog::activityHappened(QString name) 65 | { 66 | name = name.replace("&", ""); 67 | 68 | #ifdef PRINT_ACTIVITY 69 | SVDEBUG << "ActivityLog: " << name; 70 | if (name == m_prevName) { 71 | SVDEBUG << " (duplicate)"; 72 | } 73 | SVDEBUG << endl; 74 | #endif 75 | 76 | if (name == m_prevName) { 77 | return; 78 | } 79 | m_prevName = name; 80 | int row = m_model->rowCount(); 81 | name = tr("%1: %2").arg(QTime::currentTime().toString()).arg(name); 82 | m_model->insertRows(row, 1); 83 | QModelIndex ix = m_model->index(row, 0); 84 | m_model->setData(ix, name); 85 | if (isVisible()) m_listView->scrollTo(ix); 86 | } 87 | 88 | void 89 | ActivityLog::scrollToEnd() 90 | { 91 | if (m_model->rowCount() == 0 || !isVisible()) return; 92 | QModelIndex ix = m_model->index(m_model->rowCount()-1, 0); 93 | m_listView->scrollTo(ix); 94 | } 95 | 96 | 97 | } // end namespace sv 98 | 99 | -------------------------------------------------------------------------------- /widgets/LevelPanToolButton.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef LEVEL_PAN_TOOLBUTTON_H 16 | #define LEVEL_PAN_TOOLBUTTON_H 17 | 18 | #include 19 | 20 | class QMenu; 21 | 22 | namespace sv { 23 | 24 | class LevelPanWidget; 25 | 26 | class LevelPanToolButton : public QToolButton 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | LevelPanToolButton(QWidget *parent = 0); 32 | ~LevelPanToolButton(); 33 | 34 | /// Return level as a gain value in the range [0,1] 35 | float getLevel() const; 36 | 37 | /// Return pan as a value in the range [-1,1] 38 | float getPan() const; 39 | 40 | /// Discover whether the level range includes muting or not 41 | bool includesMute() const; 42 | 43 | void setImageSize(int pixels); 44 | 45 | /// Specify whether a right-click context menu is provided 46 | void setProvideContextMenu(bool); 47 | 48 | void setBigImageSize(int pixels); 49 | 50 | public slots: 51 | /// Set level in the range [0,1] -- will be rounded 52 | void setLevel(float); 53 | 54 | /// Set pan in the range [-1,1] -- will be rounded 55 | void setPan(float); 56 | 57 | /// Set left and right peak monitoring levels in the range [0,1] 58 | void setMonitoringLevels(float, float); 59 | 60 | /// Specify whether the level range should include muting or not 61 | void setIncludeMute(bool); 62 | 63 | void setEnabled(bool enabled); 64 | 65 | protected slots: 66 | void contextMenuRequested(const QPoint &); 67 | 68 | signals: 69 | void levelChanged(float); 70 | void panChanged(float); 71 | 72 | void mouseEntered(); 73 | void mouseLeft(); 74 | 75 | private slots: 76 | void selfLevelChanged(float); 77 | void selfClicked(); 78 | 79 | protected: 80 | void paintEvent(QPaintEvent *) override; 81 | void enterEvent(QEnterEvent *) override; 82 | void leaveEvent(QEvent *) override; 83 | void mousePressEvent(QMouseEvent *) override; 84 | void wheelEvent(QWheelEvent *e) override; 85 | 86 | LevelPanWidget *m_lpw; 87 | int m_pixels; 88 | int m_pixelsBig; 89 | bool m_muted; 90 | float m_savedLevel; 91 | bool m_provideContextMenu; 92 | QMenu *m_lastContextMenu; 93 | }; 94 | 95 | } // end namespace sv 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /widgets/PropertyBox.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PROPERTY_BOX_H 17 | #define SV_PROPERTY_BOX_H 18 | 19 | #include "base/PropertyContainer.h" 20 | 21 | #include 22 | #include 23 | 24 | class QLayout; 25 | class QWidget; 26 | class QGridLayout; 27 | class QVBoxLayout; 28 | class QLabel; 29 | class QToolButton; 30 | class QMenu; 31 | 32 | namespace sv { 33 | 34 | class LEDButton; 35 | class NotifyingPushButton; 36 | 37 | class PropertyBox : public QFrame 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | PropertyBox(PropertyContainer *); 43 | ~PropertyBox(); 44 | 45 | PropertyContainer *getContainer() { return m_container; } 46 | 47 | signals: 48 | void showLayer(bool); 49 | void contextHelpChanged(const QString &); 50 | 51 | public slots: 52 | void propertyContainerPropertyChanged(PropertyContainer *); 53 | void propertyContainerPropertyRangeChanged(PropertyContainer *); 54 | void playClipChanged(QString); 55 | void layerVisibilityChanged(bool); 56 | 57 | protected slots: 58 | void propertyControllerChanged(int); 59 | void propertyControllerChanged(bool); 60 | void propertyControllerResetRequested(); 61 | 62 | void playAudibleChanged(bool); 63 | void playAudibleButtonChanged(bool); 64 | void playGainControlChanged(float); 65 | void playPanControlChanged(float); 66 | 67 | void populateViewPlayFrame(); 68 | 69 | void unitDatabaseChanged(); 70 | 71 | void editPlayParameters(); 72 | 73 | void mouseEnteredWidget(); 74 | void mouseLeftWidget(); 75 | 76 | void contextMenuRequested(const QPoint &); 77 | 78 | protected: 79 | void updatePropertyEditor(PropertyContainer::PropertyName, 80 | bool rangeChanged = false); 81 | void updateContextHelp(QObject *o); 82 | 83 | QLabel *m_nameWidget; 84 | QWidget *m_mainWidget; 85 | QGridLayout *m_layout; 86 | PropertyContainer *m_container; 87 | QFrame *m_viewPlayFrame; 88 | QVBoxLayout *m_mainBox; 89 | LEDButton *m_showButton; 90 | QToolButton *m_playButton; 91 | QMenu *m_lastContextMenu; 92 | QObject *m_contextMenuOn; 93 | std::map m_groupLayouts; 94 | std::map m_propertyControllers; 95 | }; 96 | 97 | } // end namespace sv 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /widgets/LabelCounterInputDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LabelCounterInputDialog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace sv { 25 | 26 | LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller, 27 | QWidget *parent) : 28 | QDialog(parent), 29 | m_labeller(labeller) 30 | { 31 | setWindowTitle(tr("Set Counters")); 32 | 33 | QGridLayout *layout = new QGridLayout(this); 34 | 35 | QLabel *label = new QLabel(tr("Fine counter (beats):")); 36 | layout->addWidget(label, 1, 0); 37 | 38 | label = new QLabel(tr("Coarse counter (bars):")); 39 | layout->addWidget(label, 0, 0); 40 | 41 | QSpinBox *counter = new QSpinBox; 42 | counter->setMinimum(-10); 43 | counter->setMaximum(10000); 44 | counter->setSingleStep(1); 45 | m_origSecondCounter = m_labeller->getSecondLevelCounterValue(); 46 | counter->setValue(m_origSecondCounter); 47 | connect(counter, SIGNAL(valueChanged(int)), 48 | this, SLOT(secondCounterChanged(int))); 49 | layout->addWidget(counter, 0, 1); 50 | 51 | counter = new QSpinBox; 52 | counter->setMinimum(-10); 53 | counter->setMaximum(10000); 54 | counter->setSingleStep(1); 55 | m_origCounter = m_labeller->getCounterValue(); 56 | counter->setValue(m_origCounter); 57 | connect(counter, SIGNAL(valueChanged(int)), 58 | this, SLOT(counterChanged(int))); 59 | layout->addWidget(counter, 1, 1); 60 | 61 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | 62 | QDialogButtonBox::Cancel); 63 | layout->addWidget(bb, 2, 0, 1, 2); 64 | connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 65 | connect(bb, SIGNAL(rejected()), this, SLOT(cancelClicked())); 66 | } 67 | 68 | LabelCounterInputDialog::~LabelCounterInputDialog() 69 | { 70 | } 71 | 72 | void 73 | LabelCounterInputDialog::counterChanged(int value) 74 | { 75 | m_labeller->setCounterValue(value); 76 | } 77 | 78 | void 79 | LabelCounterInputDialog::secondCounterChanged(int value) 80 | { 81 | m_labeller->setSecondLevelCounterValue(value); 82 | } 83 | 84 | void 85 | LabelCounterInputDialog::cancelClicked() 86 | { 87 | m_labeller->setCounterValue(m_origCounter); 88 | m_labeller->setSecondLevelCounterValue(m_origSecondCounter); 89 | reject(); 90 | } 91 | 92 | } // end namespace sv 93 | 94 | -------------------------------------------------------------------------------- /widgets/CSVFormatDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_CSV_FORMAT_DIALOG_H 17 | #define SV_CSV_FORMAT_DIALOG_H 18 | 19 | #include "data/fileio/CSVFormat.h" 20 | 21 | class QTableWidget; 22 | class QComboBox; 23 | class QLabel; 24 | class QFrame; 25 | class QCheckBox; 26 | 27 | #include 28 | 29 | namespace sv { 30 | 31 | class CSVFormatDialog : public QDialog 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | CSVFormatDialog(QWidget *parent, 37 | CSVFormat initialFormat, 38 | int maxDisplayCols); 39 | 40 | CSVFormatDialog(QWidget *parent, 41 | QString csvFilePath, // to guess format of 42 | sv_samplerate_t referenceSampleRate, 43 | int maxDisplayCols); 44 | 45 | ~CSVFormatDialog(); 46 | 47 | CSVFormat getFormat() const; 48 | 49 | protected slots: 50 | void headerChanged(bool); 51 | void separatorChanged(QString); 52 | void timingTypeChanged(int type); 53 | void sampleRateChanged(QString); 54 | void incrementChanged(QString); 55 | void columnPurposeChanged(int purpose); 56 | 57 | void updateFormatFromDialog(); 58 | void updateModelLabel(); 59 | 60 | void accepted(); 61 | 62 | protected: 63 | QString m_csvFilePath; 64 | sv_samplerate_t m_referenceSampleRate; 65 | CSVFormat m_format; 66 | int m_maxDisplayCols; 67 | 68 | enum TimingOption { 69 | TimingExplicitSeconds = 0, 70 | TimingExplicitMsec, 71 | TimingExplicitSamples, 72 | TimingImplicit 73 | }; 74 | std::map m_timingLabels; 75 | TimingOption m_initialTimingOption; 76 | 77 | void init(); 78 | void repopulate(); 79 | void columnPurposeChangedForAnnotationType(QComboBox *, int purpose); 80 | void updateComboVisibility(); 81 | void applyStartTimePurpose(); 82 | void removeStartTimePurpose(); 83 | 84 | QString m_tabText; 85 | QString m_whitespaceText; 86 | 87 | QFrame *m_exampleFrame; 88 | int m_exampleFrameRow; 89 | 90 | QCheckBox *m_headerCheckBox; 91 | QComboBox *m_separatorCombo; 92 | QComboBox *m_timingTypeCombo; 93 | QLabel *m_sampleRateLabel; 94 | QComboBox *m_sampleRateCombo; 95 | QLabel *m_incrementLabel; 96 | QComboBox *m_incrementCombo; 97 | QLabel *m_modelLabel; 98 | 99 | QList m_columnPurposeCombos; 100 | int m_fuzzyColumn; 101 | }; 102 | 103 | } // end namespace sv 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /layer/LinearColourScale.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LinearColourScale.h" 17 | #include "ColourScaleLayer.h" 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include "LayerGeometryProvider.h" 24 | 25 | namespace sv { 26 | 27 | int 28 | LinearColourScale::getWidth(LayerGeometryProvider *, 29 | QPainter &paint) 30 | { 31 | return paint.fontMetrics().horizontalAdvance("-000.00") + 15; 32 | } 33 | 34 | void 35 | LinearColourScale::paintVertical(LayerGeometryProvider *v, 36 | const ColourScaleLayer *layer, 37 | QPainter &paint, 38 | int /* x0 */, 39 | double min, 40 | double max) 41 | { 42 | int h = v->getPaintHeight(); 43 | 44 | int n = 10; 45 | 46 | double val = min; 47 | double inc = (max - val) / n; 48 | 49 | const int buflen = 40; 50 | char buffer[buflen]; 51 | 52 | int boxx = 5, boxy = 5; 53 | if (layer->getScaleUnits() != "") { 54 | boxy += paint.fontMetrics().height(); 55 | } 56 | int boxw = 10, boxh = h - boxy - 5; 57 | 58 | int tx = 5 + boxx + boxw; 59 | paint.drawRect(boxx, boxy, boxw, boxh); 60 | 61 | paint.save(); 62 | for (int y = 0; y < boxh; ++y) { 63 | double val = ((boxh - y) * (max - min)) / boxh + min; 64 | paint.setPen(layer->getColourForValue(v, val)); 65 | paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); 66 | } 67 | paint.restore(); 68 | 69 | // double round = 1.f; 70 | int dp = 0; 71 | if (inc > 0) { 72 | int prec = int(trunc(log10(inc))); 73 | prec -= 1; 74 | if (prec < 0) dp = -prec; 75 | // round = powf(10.f, prec); 76 | //#ifdef DEBUG_TIME_VALUE_LAYER 77 | // cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << endl; 78 | //#endif 79 | } 80 | 81 | for (int i = 0; i < n; ++i) { 82 | 83 | int y, ty; 84 | 85 | y = boxy + int(boxh - ((val - min) * boxh) / (max - min)); 86 | 87 | ty = y - paint.fontMetrics().height() + 88 | paint.fontMetrics().ascent() + 2; 89 | 90 | snprintf(buffer, buflen, "%.*f", dp, val); 91 | QString label = QString(buffer); 92 | 93 | paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); 94 | paint.drawText(tx, ty, label); 95 | 96 | val += inc; 97 | } 98 | } 99 | } // end namespace sv 100 | 101 | -------------------------------------------------------------------------------- /layer/LogColourScale.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2013 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LogColourScale.h" 17 | #include "ColourScaleLayer.h" 18 | 19 | #include "base/LogRange.h" 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include "LayerGeometryProvider.h" 26 | 27 | namespace sv { 28 | 29 | int 30 | LogColourScale::getWidth(LayerGeometryProvider *, 31 | QPainter &paint) 32 | { 33 | return paint.fontMetrics().horizontalAdvance("-000.00") + 15; 34 | } 35 | 36 | void 37 | LogColourScale::paintVertical(LayerGeometryProvider *v, 38 | const ColourScaleLayer *layer, 39 | QPainter &paint, 40 | int /* x0 */, 41 | double minlog, 42 | double maxlog) 43 | { 44 | int h = v->getPaintHeight(); 45 | 46 | int n = 10; 47 | 48 | double val = minlog; 49 | double inc = (maxlog - val) / n; 50 | 51 | const int buflen = 40; 52 | char buffer[buflen]; 53 | 54 | int boxx = 5, boxy = 5; 55 | if (layer->getScaleUnits() != "") { 56 | boxy += paint.fontMetrics().height(); 57 | } 58 | int boxw = 10, boxh = h - boxy - 5; 59 | 60 | int tx = 5 + boxx + boxw; 61 | paint.drawRect(boxx, boxy, boxw, boxh); 62 | 63 | paint.save(); 64 | for (int y = 0; y < boxh; ++y) { 65 | double val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog; 66 | paint.setPen(layer->getColourForValue(v, LogRange::unmap(val))); 67 | paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); 68 | } 69 | paint.restore(); 70 | 71 | int dp = 0; 72 | if (inc > 0) { 73 | int prec = int(trunc(log10(inc))); 74 | prec -= 1; 75 | if (prec < 0) dp = -prec; 76 | } 77 | 78 | for (int i = 0; i < n; ++i) { 79 | 80 | int y, ty; 81 | 82 | y = boxy + int(boxh - ((val - minlog) * boxh) / (maxlog - minlog)); 83 | 84 | ty = y - paint.fontMetrics().height() + 85 | paint.fontMetrics().ascent() + 2; 86 | 87 | double dv = LogRange::unmap(val); 88 | int digits = int(trunc(log10(dv))); 89 | int sf = dp + (digits > 0 ? digits : 0); 90 | if (sf < 2) sf = 2; 91 | snprintf(buffer, buflen, "%.*g", sf, dv); 92 | 93 | QString label = QString(buffer); 94 | 95 | paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); 96 | paint.drawText(tx, ty, label); 97 | 98 | val += inc; 99 | } 100 | } 101 | } // end namespace sv 102 | 103 | -------------------------------------------------------------------------------- /widgets/ListInputDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ListInputDialog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace sv { 27 | 28 | ListInputDialog::ListInputDialog(QWidget *parent, const QString &title, 29 | const QString &labelText, const QStringList &list, 30 | int current) : 31 | QDialog(parent), 32 | m_strings(list) 33 | { 34 | setWindowTitle(title); 35 | 36 | QVBoxLayout *vbox = new QVBoxLayout(this); 37 | 38 | QLabel *label = new QLabel(labelText, this); 39 | vbox->addWidget(label); 40 | vbox->addStretch(1); 41 | 42 | int count = 0; 43 | for (QStringList::const_iterator i = list.begin(); i != list.end(); ++i) { 44 | QRadioButton *radio = new QRadioButton(*i); 45 | if (current == count++) radio->setChecked(true); 46 | m_radioButtons.push_back(radio); 47 | vbox->addWidget(radio); 48 | } 49 | 50 | vbox->addStretch(1); 51 | 52 | m_footnote = new QLabel; 53 | vbox->addWidget(m_footnote); 54 | m_footnote->hide(); 55 | 56 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | 57 | QDialogButtonBox::Cancel); 58 | vbox->addWidget(bb); 59 | connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 60 | connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 61 | } 62 | 63 | ListInputDialog::~ListInputDialog() 64 | { 65 | } 66 | 67 | QString 68 | ListInputDialog::getCurrentString() const 69 | { 70 | for (size_t i = 0; i < m_radioButtons.size(); ++i) { 71 | if (m_radioButtons[i]->isChecked()) { 72 | return m_strings[int(i)]; 73 | } 74 | } 75 | return ""; 76 | } 77 | 78 | void 79 | ListInputDialog::setItemAvailability(int item, bool available) 80 | { 81 | m_radioButtons[item]->setEnabled(available); 82 | } 83 | 84 | void 85 | ListInputDialog::setFootnote(QString footnote) 86 | { 87 | m_footnote->setText(footnote); 88 | m_footnote->show(); 89 | } 90 | 91 | QString 92 | ListInputDialog::getItem(QWidget *parent, const QString &title, 93 | const QString &label, const QStringList &list, 94 | int current, bool *ok) 95 | { 96 | ListInputDialog dialog(parent, title, label, list, current); 97 | 98 | bool accepted = (dialog.exec() == QDialog::Accepted); 99 | if (ok) *ok = accepted; 100 | 101 | return dialog.getCurrentString(); 102 | } 103 | 104 | } // end namespace sv 105 | 106 | -------------------------------------------------------------------------------- /widgets/Thumbwheel.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_THUMBWHEEL_H 17 | #define SV_THUMBWHEEL_H 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "WheelCounter.h" 25 | 26 | class QMenu; 27 | 28 | namespace sv { 29 | 30 | class RangeMapper; 31 | 32 | class Thumbwheel : public QWidget 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | Thumbwheel(Qt::Orientation orientation, QWidget *parent = 0); 38 | virtual ~Thumbwheel(); 39 | 40 | int getMinimumValue() const; 41 | int getMaximumValue() const; 42 | int getDefaultValue() const; 43 | float getSpeed() const; 44 | bool getTracking() const; 45 | bool getShowScale() const; 46 | int getValue() const; 47 | 48 | void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete 49 | const RangeMapper *getRangeMapper() const { return m_rangeMapper; } 50 | double getMappedValue() const; 51 | 52 | void setShowToolTip(bool show); 53 | void setProvideContextMenu(bool provide); 54 | 55 | QSize sizeHint() const override; 56 | 57 | signals: 58 | void valueChanged(int); 59 | 60 | void mouseEntered(); 61 | void mouseLeft(); 62 | 63 | public slots: 64 | void setMinimumValue(int min); 65 | void setMaximumValue(int max); 66 | void setDefaultValue(int deft); 67 | void setSpeed(float speed); 68 | void setTracking(bool tracking); 69 | void setShowScale(bool show); 70 | void setValue(int value); 71 | void setMappedValue(double mappedValue); 72 | void scroll(bool up); 73 | void resetToDefault(); 74 | void edit(); 75 | 76 | protected slots: 77 | void updateMappedValue(int value); 78 | void updateTitle(); 79 | void contextMenuRequested(const QPoint &); 80 | 81 | protected: 82 | void mousePressEvent(QMouseEvent *e) override; 83 | void mouseDoubleClickEvent(QMouseEvent *e) override; 84 | void mouseMoveEvent(QMouseEvent *e) override; 85 | void mouseReleaseEvent(QMouseEvent *e) override; 86 | void wheelEvent(QWheelEvent *e) override; 87 | void paintEvent(QPaintEvent *e) override; 88 | void enterEvent(QEnterEvent *) override; 89 | void leaveEvent(QEvent *) override; 90 | 91 | int m_min; 92 | int m_max; 93 | int m_default; 94 | int m_value; 95 | double m_mappedValue; 96 | bool m_noMappedUpdate; 97 | float m_rotation; 98 | Qt::Orientation m_orientation; 99 | float m_speed; 100 | bool m_tracking; 101 | bool m_showScale; 102 | bool m_clicked; 103 | bool m_atDefault; 104 | QPoint m_clickPos; 105 | float m_clickRotation; 106 | bool m_showTooltip; 107 | bool m_provideContextMenu; 108 | QString m_title; 109 | QMenu *m_lastContextMenu; 110 | RangeMapper *m_rangeMapper; 111 | QImage m_cache; 112 | WheelCounter m_wheelCounter; 113 | }; 114 | 115 | } // end namespace sv 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /widgets/ProgressDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ProgressDialog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace sv { 23 | 24 | ProgressDialog::ProgressDialog(QString message, 25 | bool cancellable, 26 | int timeBeforeShow, 27 | QWidget *parent, 28 | Qt::WindowModality modality) : 29 | m_showTimer(nullptr), 30 | m_timerElapsed(false), 31 | m_cancelled(false) 32 | { 33 | m_dialog = new QProgressDialog(message, cancellable ? tr("Cancel") : nullptr, 34 | 0, 100, parent); 35 | m_dialog->setMinimumDuration(3600000); // we want to control visibility 36 | m_dialog->setWindowModality(modality); 37 | m_dialog->reset(); 38 | 39 | if (timeBeforeShow > 0) { 40 | m_dialog->hide(); 41 | m_showTimer = new QTimer; 42 | connect(m_showTimer, SIGNAL(timeout()), this, SLOT(showTimerElapsed())); 43 | m_showTimer->setSingleShot(true); 44 | m_showTimer->start(timeBeforeShow); 45 | } else { 46 | m_dialog->show(); 47 | m_dialog->raise(); 48 | m_timerElapsed = true; 49 | } 50 | 51 | if (cancellable) { 52 | connect(m_dialog, SIGNAL(canceled()), this, SLOT(canceled())); 53 | } 54 | } 55 | 56 | ProgressDialog::~ProgressDialog() 57 | { 58 | delete m_showTimer; 59 | delete m_dialog; 60 | } 61 | 62 | bool 63 | ProgressDialog::isDefinite() const 64 | { 65 | return (m_dialog->maximum() > 0); 66 | } 67 | 68 | void 69 | ProgressDialog::setDefinite(bool definite) 70 | { 71 | if (definite) m_dialog->setMaximum(100); 72 | else m_dialog->setMaximum(0); 73 | } 74 | 75 | void 76 | ProgressDialog::setMessage(QString text) 77 | { 78 | m_dialog->setLabelText(text); 79 | } 80 | 81 | void 82 | ProgressDialog::canceled() 83 | { 84 | m_cancelled = true; 85 | emit cancelled(); 86 | } 87 | 88 | bool 89 | ProgressDialog::wasCancelled() const 90 | { 91 | return m_cancelled; 92 | } 93 | 94 | void 95 | ProgressDialog::showTimerElapsed() 96 | { 97 | m_timerElapsed = true; 98 | if (m_dialog->value() > 0) { 99 | emit showing(); 100 | m_dialog->show(); 101 | } 102 | qApp->processEvents(); 103 | } 104 | 105 | void 106 | ProgressDialog::setProgress(int percentage) 107 | { 108 | if (percentage > m_dialog->value()) { 109 | if (percentage >= 100 && isDefinite()) { 110 | m_dialog->hide(); 111 | } else if (m_timerElapsed && !m_dialog->isVisible()) { 112 | emit showing(); 113 | m_dialog->show(); 114 | m_dialog->raise(); 115 | } 116 | m_dialog->setValue(percentage); // processes event loop when modal 117 | if (!m_dialog->isModal()) qApp->processEvents(); 118 | } 119 | } 120 | } // end namespace sv 121 | 122 | -------------------------------------------------------------------------------- /widgets/ColourNameDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ColourNameDialog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace sv { 28 | 29 | ColourNameDialog::ColourNameDialog(QString title, QString message, 30 | QColor colour, QString defaultName, 31 | QWidget *parent) : 32 | QDialog(parent), 33 | m_colour(colour) 34 | { 35 | setWindowTitle(title); 36 | 37 | QGridLayout *layout = new QGridLayout(this); 38 | 39 | QLabel *label = new QLabel(message, this); 40 | layout->addWidget(label, 0, 0, 1, 2); 41 | 42 | m_colourLabel = new QLabel(this); 43 | layout->addWidget(m_colourLabel, 1, 1); 44 | 45 | m_textField = new QLineEdit(defaultName, this); 46 | layout->addWidget(m_textField, 1, 0); 47 | 48 | connect(m_textField, SIGNAL(textChanged(const QString &)), 49 | this, SLOT(textChanged(const QString &))); 50 | 51 | m_darkBackground = new QCheckBox(this); 52 | layout->addWidget(m_darkBackground, 2, 0); 53 | m_darkBackground->setChecked 54 | (colour.red() + colour.green() + colour.blue() > 384); 55 | fillColourLabel(); 56 | 57 | connect(m_darkBackground, SIGNAL(stateChanged(int)), 58 | this, SLOT(darkBackgroundChanged(int))); 59 | 60 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | 61 | QDialogButtonBox::Cancel); 62 | layout->addWidget(bb, 3, 0, 1, 2); 63 | connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 64 | connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 65 | m_okButton = bb->button(QDialogButtonBox::Ok); 66 | m_okButton->setEnabled(defaultName != ""); 67 | } 68 | 69 | void 70 | ColourNameDialog::showDarkBackgroundCheckbox(QString text) 71 | { 72 | m_darkBackground->setText(text); 73 | m_darkBackground->show(); 74 | } 75 | 76 | bool 77 | ColourNameDialog::isDarkBackgroundChecked() const 78 | { 79 | return m_darkBackground->isChecked(); 80 | } 81 | 82 | void 83 | ColourNameDialog::darkBackgroundChanged(int) 84 | { 85 | fillColourLabel(); 86 | } 87 | 88 | void 89 | ColourNameDialog::textChanged(const QString &text) 90 | { 91 | m_okButton->setEnabled(text != ""); 92 | } 93 | 94 | void 95 | ColourNameDialog::fillColourLabel() 96 | { 97 | QPixmap pmap(20, 20); 98 | pmap.fill(m_darkBackground->isChecked() ? Qt::black : Qt::white); 99 | QPainter paint(&pmap); 100 | paint.setPen(m_colour); 101 | paint.setBrush(m_colour); 102 | paint.drawRect(2, 2, 15, 15); 103 | m_colourLabel->setPixmap(pmap); 104 | } 105 | 106 | QString 107 | ColourNameDialog::getColourName() const 108 | { 109 | return m_textField->text(); 110 | } 111 | } // end namespace sv 112 | 113 | -------------------------------------------------------------------------------- /widgets/ItemEditDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_ITEM_EDIT_DIALOG_H 17 | #define SV_ITEM_EDIT_DIALOG_H 18 | 19 | #include 20 | #include 21 | 22 | #include "base/RealTime.h" 23 | 24 | class QSpinBox; 25 | class QDoubleSpinBox; 26 | class QLineEdit; 27 | 28 | namespace sv { 29 | 30 | class ItemEditDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | enum { 36 | ShowTime = 1 << 0, 37 | ShowDuration = 1 << 1, 38 | ShowValue = 1 << 2, 39 | ShowText = 1 << 3, 40 | ShowLevel = 1 << 4 41 | }; 42 | 43 | struct LabelOptions { 44 | LabelOptions(); 45 | QString valueLabel; 46 | QString levelLabel; 47 | QString valueUnits; 48 | QString levelUnits; 49 | }; 50 | 51 | ItemEditDialog(sv_samplerate_t sampleRate, 52 | int options, 53 | LabelOptions labelOptions = {}, 54 | QWidget *parent = 0); 55 | 56 | ItemEditDialog(sv_samplerate_t sampleRate, 57 | int options, 58 | QString scaleUnits, 59 | QWidget *parent = 0); 60 | 61 | void setFrameTime(sv_frame_t frame); 62 | sv_frame_t getFrameTime() const; 63 | 64 | void setRealTime(RealTime rt); 65 | RealTime getRealTime() const; 66 | 67 | void setFrameDuration(sv_frame_t frame); 68 | sv_frame_t getFrameDuration() const; 69 | 70 | void setRealDuration(RealTime rt); 71 | RealTime getRealDuration() const; 72 | 73 | void setValue(float value); 74 | float getValue() const; 75 | 76 | void setLevel(float level); 77 | float getLevel() const; 78 | 79 | void setText(QString text); 80 | QString getText() const; 81 | 82 | protected slots: 83 | void frameTimeChanged(int); // must be int as invoked from int signal 84 | void realTimeSecsChanged(int); 85 | void realTimeUSecsChanged(int); 86 | void frameDurationChanged(int); // must be int as invoked from int signal 87 | void realDurationSecsChanged(int); 88 | void realDurationUSecsChanged(int); 89 | void valueChanged(double); 90 | void levelChanged(double); 91 | void textChanged(QString); 92 | void reset(); 93 | 94 | protected: 95 | sv_samplerate_t m_sampleRate; 96 | sv_frame_t m_defaultFrame; 97 | sv_frame_t m_defaultDuration; 98 | float m_defaultValue; 99 | float m_defaultLevel; 100 | QString m_defaultText; 101 | QSpinBox *m_frameTimeSpinBox; 102 | QSpinBox *m_realTimeSecsSpinBox; 103 | QSpinBox *m_realTimeUSecsSpinBox; 104 | QSpinBox *m_frameDurationSpinBox; 105 | QSpinBox *m_realDurationSecsSpinBox; 106 | QSpinBox *m_realDurationUSecsSpinBox; 107 | QDoubleSpinBox *m_valueSpinBox; 108 | QDoubleSpinBox *m_levelSpinBox; 109 | QLineEdit *m_textField; 110 | QPushButton *m_resetButton; 111 | }; 112 | 113 | } // end namespace sv 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /widgets/LayerTreeDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "LayerTreeDialog.h" 17 | 18 | #include "LayerTree.h" 19 | #include "view/PaneStack.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace sv { 31 | 32 | LayerTreeDialog::LayerTreeDialog(PaneStack *stack, QWidget *parent) : 33 | QDialog(parent), 34 | m_paneStack(stack) 35 | { 36 | setWindowTitle(tr("Layer Summary")); 37 | 38 | QGridLayout *grid = new QGridLayout; 39 | setLayout(grid); 40 | 41 | QGroupBox *modelBox = new QGroupBox; 42 | modelBox->setTitle(tr("Audio Data Sources")); 43 | grid->addWidget(modelBox, 0, 0); 44 | grid->setRowStretch(0, 15); 45 | 46 | QGridLayout *subgrid = new QGridLayout; 47 | modelBox->setLayout(subgrid); 48 | 49 | subgrid->setSpacing(0); 50 | subgrid->setContentsMargins(5, 5, 5, 5); 51 | 52 | m_modelView = new QTableView; 53 | subgrid->addWidget(m_modelView); 54 | 55 | m_modelView->verticalHeader()->hide(); 56 | #if (QT_VERSION >= 0x050000) 57 | m_modelView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); 58 | #else 59 | m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); 60 | #endif 61 | m_modelView->setShowGrid(false); 62 | 63 | m_modelModel = new ModelMetadataModel(m_paneStack, true); 64 | m_modelView->setModel(m_modelModel); 65 | 66 | QGroupBox *layerBox = new QGroupBox; 67 | layerBox->setTitle(tr("Panes and Layers")); 68 | grid->addWidget(layerBox, 1, 0); 69 | grid->setRowStretch(1, 20); 70 | 71 | subgrid = new QGridLayout; 72 | layerBox->setLayout(subgrid); 73 | 74 | subgrid->setSpacing(0); 75 | subgrid->setContentsMargins(5, 5, 5, 5); 76 | 77 | m_layerView = new QTreeView; 78 | #if (QT_VERSION >= 0x050000) 79 | m_layerView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); 80 | #else 81 | m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents); 82 | #endif 83 | subgrid->addWidget(m_layerView); 84 | 85 | m_layerModel = new LayerTreeModel(m_paneStack); 86 | m_layerView->setModel(m_layerModel); 87 | m_layerView->expandAll(); 88 | 89 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); 90 | connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 91 | grid->addWidget(bb, 2, 0); 92 | grid->setRowStretch(2, 0); 93 | 94 | QScreen *screen = QGuiApplication::primaryScreen(); 95 | QRect available = screen->availableGeometry(); 96 | 97 | int width = available.width() / 2; 98 | int height = available.height() / 3; 99 | if (height < 370) { 100 | if (available.height() > 500) height = 370; 101 | } 102 | if (width < 500) { 103 | if (available.width() > 650) width = 500; 104 | } 105 | 106 | resize(width, height); 107 | } 108 | 109 | LayerTreeDialog::~LayerTreeDialog() 110 | { 111 | delete m_layerModel; 112 | } 113 | 114 | } // end namespace sv 115 | 116 | -------------------------------------------------------------------------------- /layer/LayerFactory.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_LAYER_FACTORY_H 17 | #define SV_LAYER_FACTORY_H 18 | 19 | #include 20 | #include 21 | 22 | #include "data/model/Model.h" 23 | 24 | namespace sv { 25 | 26 | class Layer; 27 | class Clipboard; 28 | 29 | class LayerFactory 30 | { 31 | public: 32 | enum LayerType { 33 | 34 | // Standard layers 35 | Waveform, 36 | Spectrogram, 37 | TimeRuler, 38 | TimeInstants, 39 | TimeValues, 40 | Notes, 41 | FlexiNotes, 42 | Regions, 43 | Boxes, 44 | Text, 45 | Image, 46 | Colour3DPlot, 47 | Spectrum, 48 | Slice, 49 | 50 | // Layers with different initial parameters 51 | MelodicRangeSpectrogram, 52 | PeakFrequencySpectrogram, 53 | 54 | // Not-a-layer-type 55 | UnknownLayer = 255 56 | }; 57 | 58 | static LayerFactory *getInstance(); 59 | 60 | virtual ~LayerFactory(); 61 | 62 | typedef std::set LayerTypeSet; 63 | LayerTypeSet getValidLayerTypes(ModelId modelId); 64 | 65 | /** 66 | * Return the set of layer types that an end user should be 67 | * allowed to create, empty, for subsequent editing. 68 | */ 69 | LayerTypeSet getValidEmptyLayerTypes(); 70 | 71 | LayerType getLayerType(const Layer *); 72 | 73 | Layer *createLayer(LayerType type); 74 | 75 | /** 76 | * Set the default properties of a layer, from the XML string 77 | * contained in the LayerDefaults settings group for the given 78 | * layer type. Leave unchanged any properties not mentioned in the 79 | * settings. 80 | */ 81 | void setLayerDefaultProperties(LayerType type, Layer *layer); 82 | 83 | /** 84 | * Set the properties of a layer, from the XML string 85 | * provided. Leave unchanged any properties not mentioned. 86 | */ 87 | void setLayerProperties(Layer *layer, QString xmlString); 88 | 89 | QString getLayerPresentationName(LayerType type); 90 | 91 | bool isLayerSliceable(const Layer *); 92 | 93 | void setModel(Layer *layer, ModelId model); 94 | std::shared_ptr createEmptyModel(LayerType type, ModelId baseModel); 95 | 96 | int getChannel(Layer *layer); 97 | void setChannel(Layer *layer, int channel); 98 | 99 | QString getLayerIconName(LayerType); 100 | QString getLayerTypeName(LayerType); 101 | LayerType getLayerTypeForName(QString); 102 | 103 | LayerType getLayerTypeForClipboardContents(const Clipboard &); 104 | 105 | protected: 106 | template 107 | bool trySetModel(Layer *layerBase, ModelId modelId) { 108 | LayerClass *layer = dynamic_cast(layerBase); 109 | if (!layer) return false; 110 | if (!modelId.isNone()) { 111 | auto model = ModelById::getAs(modelId); 112 | if (!model) return false; 113 | } 114 | layer->setModel(modelId); 115 | return true; 116 | } 117 | 118 | static LayerFactory *m_instance; 119 | }; 120 | 121 | } // end namespace sv 122 | 123 | #endif 124 | 125 | -------------------------------------------------------------------------------- /layer/SingleColourLayer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_SINGLE_COLOUR_LAYER_H 17 | #define SV_SINGLE_COLOUR_LAYER_H 18 | 19 | #include "Layer.h" 20 | #include 21 | #include 22 | #include 23 | 24 | namespace sv { 25 | 26 | class SingleColourLayer : public Layer 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | /** 32 | * Set the colour used to draw primary items in the layer. The 33 | * colour value is a colour database index as returned by 34 | * ColourDatabase::getColourIndex(). 35 | */ 36 | virtual void setBaseColour(int); 37 | 38 | /** 39 | * Retrieve the current primary drawing colour, as a 40 | * ColourDatabase index value. 41 | */ 42 | virtual int getBaseColour() const; 43 | 44 | /** 45 | * Return true if the layer currently has a dark colour on a light 46 | * background, false if it has a light colour on a dark 47 | * background. 48 | */ 49 | bool hasLightBackground() const override; 50 | 51 | /** 52 | * Implements Layer::getLayerColourSignificance() 53 | */ 54 | ColourSignificance getLayerColourSignificance() const override { 55 | return ColourDistinguishes; 56 | } 57 | 58 | QPixmap getLayerPresentationPixmap(QSize size) const override; 59 | 60 | PropertyList getProperties() const override; 61 | QString getPropertyLabel(const PropertyName &) const override; 62 | PropertyType getPropertyType(const PropertyName &) const override; 63 | QString getPropertyGroupName(const PropertyName &) const override; 64 | int getPropertyRangeAndValue(const PropertyName &, 65 | int *min, int *max, int *deflt) const override; 66 | QString getPropertyValueLabel(const PropertyName &, 67 | int value) const override; 68 | RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override; 69 | void setProperty(const PropertyName &, int value) override; 70 | 71 | void toXml(QTextStream &stream, QString indent = "", 72 | QString extraAttributes = "") const override; 73 | 74 | void setProperties(const LayerAttributes &attributes) override; 75 | 76 | virtual void setDefaultColourFor(LayerGeometryProvider *v); 77 | 78 | protected: 79 | SingleColourLayer(); 80 | virtual ~SingleColourLayer(); 81 | 82 | virtual QColor getBaseQColor() const; 83 | virtual QColor getBackgroundQColor(LayerGeometryProvider *v) const; 84 | virtual QColor getForegroundQColor(LayerGeometryProvider *v) const; 85 | std::vector getPartialShades(LayerGeometryProvider *v) const; 86 | 87 | virtual void flagBaseColourChanged() { } 88 | virtual int getDefaultColourHint(bool /* darkBackground */, 89 | bool & /* impose */) { return -1; } 90 | 91 | typedef std::map ColourRefCount; 92 | static ColourRefCount m_colourRefCount; 93 | 94 | int m_colour; 95 | bool m_colourExplicitlySet; 96 | bool m_defaultColourSet; 97 | 98 | private: 99 | void refColor(); 100 | void unrefColor(); 101 | }; 102 | 103 | } // end namespace sv 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /layer/ImageRegionFinder.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ImageRegionFinder.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace sv { 24 | 25 | ImageRegionFinder::ImageRegionFinder() 26 | { 27 | } 28 | 29 | ImageRegionFinder::~ImageRegionFinder() 30 | { 31 | } 32 | 33 | QRect 34 | ImageRegionFinder::findRegionExtents(QImage *image, QPoint origin) const 35 | { 36 | int w = image->width(), h = image->height(); 37 | 38 | QImage visited(w, h, QImage::Format_Mono); 39 | visited.fill(0); 40 | 41 | std::stack s; 42 | s.push(origin); 43 | 44 | int xmin = origin.x(); 45 | int xmax = xmin; 46 | int ymin = origin.y(); 47 | int ymax = ymin; 48 | 49 | QRgb opix = image->pixel(origin); 50 | 51 | while (!s.empty()) { 52 | 53 | QPoint p = s.top(); 54 | s.pop(); 55 | 56 | visited.setPixel(p, 1); 57 | 58 | int x = p.x(), y = p.y(); 59 | 60 | if (x < xmin) xmin = x; 61 | if (x > xmax) xmax = x; 62 | 63 | if (y < ymin) ymin = y; 64 | if (y > ymax) ymax = y; 65 | 66 | std::stack neighbours; 67 | 68 | int similarNeighbourCount = 0; 69 | 70 | for (int dx = -1; dx <= 1; ++dx) { 71 | for (int dy = -1; dy <= 1; ++dy) { 72 | 73 | if ((dx != 0 && dy != 0) || 74 | (dx == 0 && dy == 0)) 75 | continue; 76 | 77 | if (x + dx < 0 || x + dx >= w || 78 | y + dy < 0 || y + dy >= h) 79 | continue; 80 | 81 | if (visited.pixelIndex(x + dx, y + dy) != 0) 82 | continue; 83 | 84 | if (!similar(opix, image->pixel(x + dx, y + dy))) 85 | continue; 86 | 87 | neighbours.push(QPoint(x + dx, y + dy)); 88 | ++similarNeighbourCount; 89 | } 90 | } 91 | 92 | if (similarNeighbourCount >= 2) { 93 | while (!neighbours.empty()) { 94 | s.push(neighbours.top()); 95 | neighbours.pop(); 96 | } 97 | } 98 | } 99 | 100 | return QRect(xmin, ymin, xmax - xmin, ymax - ymin); 101 | } 102 | 103 | bool 104 | ImageRegionFinder::similar(QRgb a, QRgb b) const 105 | { 106 | if (b == qRgb(0, 0, 0) || b == qRgb(255, 255, 255)) { 107 | // black and white are boundary cases, don't compare similar 108 | // to anything -- not even themselves 109 | return false; 110 | } 111 | 112 | float ar = float(qRed(a)) / 255.f; 113 | float ag = float(qGreen(a)) / 255.f; 114 | float ab = float(qBlue(a)) / 255.f; 115 | float amag = sqrtf(ar * ar + ag * ag + ab * ab); 116 | float thresh = amag / 2; 117 | 118 | float dr = float(qRed(a) - qRed(b)) / 255.f; 119 | float dg = float(qGreen(a) - qGreen(b)) / 255.f; 120 | float db = float(qBlue(a) - qBlue(b)) / 255.f; 121 | float dist = sqrtf(dr * dr + dg * dg + db * db); 122 | 123 | // cerr << "thresh=" << thresh << ", dist=" << dist << endl; 124 | 125 | return (dist < thresh); 126 | } 127 | 128 | } // end namespace sv 129 | 130 | -------------------------------------------------------------------------------- /widgets/RangeInputDialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "RangeInputDialog.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace sv { 26 | 27 | RangeInputDialog::RangeInputDialog(QString title, QString message, 28 | QString unit, float min, float max, 29 | QWidget *parent) : 30 | QDialog(parent) 31 | { 32 | QGridLayout *grid = new QGridLayout; 33 | setLayout(grid); 34 | 35 | setWindowTitle(title); 36 | 37 | QLabel *messageLabel = new QLabel; 38 | messageLabel->setText(message); 39 | grid->addWidget(messageLabel, 0, 0, 1, 5); 40 | 41 | m_rangeStart = new QDoubleSpinBox; 42 | m_rangeStart->setDecimals(4); 43 | m_rangeStart->setMinimum(min); 44 | m_rangeStart->setMaximum(max); 45 | m_rangeStart->setSuffix(unit); 46 | grid->addWidget(m_rangeStart, 1, 1); 47 | connect(m_rangeStart, SIGNAL(valueChanged(double)), 48 | this, SLOT(rangeStartChanged(double))); 49 | 50 | grid->addWidget(new QLabel(tr(" to ")), 1, 2); 51 | 52 | m_rangeEnd = new QDoubleSpinBox; 53 | m_rangeEnd->setDecimals(4); 54 | m_rangeEnd->setMinimum(min); 55 | m_rangeEnd->setMaximum(max); 56 | m_rangeEnd->setSuffix(unit); 57 | grid->addWidget(m_rangeEnd, 1, 3); 58 | connect(m_rangeEnd, SIGNAL(valueChanged(double)), 59 | this, SLOT(rangeEndChanged(double))); 60 | 61 | QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | 62 | QDialogButtonBox::Cancel); 63 | grid->addWidget(bb, 2, 0, 1, 5); 64 | connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 65 | connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 66 | } 67 | 68 | RangeInputDialog::~RangeInputDialog() 69 | { 70 | } 71 | 72 | void 73 | RangeInputDialog::getRange(float &min, float &max) 74 | { 75 | min = float(m_rangeStart->value()); 76 | max = float(m_rangeEnd->value()); 77 | 78 | if (min > max) { 79 | float tmp = min; 80 | min = max; 81 | max = tmp; 82 | } 83 | } 84 | 85 | void 86 | RangeInputDialog::setRange(float start, float end) 87 | { 88 | if (start > end) { 89 | float tmp = start; 90 | start = end; 91 | end = tmp; 92 | } 93 | 94 | blockSignals(true); 95 | m_rangeStart->setValue(start); 96 | m_rangeEnd->setValue(end); 97 | blockSignals(false); 98 | } 99 | 100 | void 101 | RangeInputDialog::rangeStartChanged(double min) 102 | { 103 | double max = m_rangeEnd->value(); 104 | if (min > max) { 105 | double tmp = min; 106 | min = max; 107 | max = tmp; 108 | } 109 | emit rangeChanged(float(min), float(max)); 110 | } 111 | 112 | 113 | void 114 | RangeInputDialog::rangeEndChanged(double max) 115 | { 116 | double min = m_rangeStart->value(); 117 | if (min > max) { 118 | double tmp = min; 119 | min = max; 120 | max = tmp; 121 | } 122 | emit rangeChanged(float(min), float(max)); 123 | } 124 | 125 | } // end namespace sv 126 | 127 | -------------------------------------------------------------------------------- /widgets/WindowTypeSelector.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "WindowTypeSelector.h" 17 | 18 | #include "WindowShapePreview.h" 19 | 20 | #include 21 | #include 22 | 23 | #include "base/Preferences.h" 24 | 25 | namespace sv { 26 | 27 | WindowTypeSelector::WindowTypeSelector(WindowType defaultType) 28 | { 29 | init(defaultType); 30 | } 31 | 32 | WindowTypeSelector::WindowTypeSelector() 33 | { 34 | Preferences *prefs = Preferences::getInstance(); 35 | int min = 0, max = 0, deflt = 0; 36 | WindowType type = 37 | WindowType(prefs->getPropertyRangeAndValue("Window Type", &min, &max, 38 | &deflt)); 39 | init(type); 40 | } 41 | 42 | void 43 | WindowTypeSelector::init(WindowType defaultType) 44 | { 45 | QVBoxLayout *layout = new QVBoxLayout; 46 | layout->setContentsMargins(0, 0, 0, 0); 47 | setLayout(layout); 48 | 49 | // The WindowType enum is in rather a ragbag order -- reorder it here 50 | // in a more sensible order 51 | m_windows = new WindowType[9]; 52 | m_windows[0] = HanningWindow; 53 | m_windows[1] = HammingWindow; 54 | m_windows[2] = BlackmanWindow; 55 | m_windows[3] = BlackmanHarrisWindow; 56 | m_windows[4] = NuttallWindow; 57 | m_windows[5] = GaussianWindow; 58 | m_windows[6] = ParzenWindow; 59 | m_windows[7] = BartlettWindow; 60 | m_windows[8] = RectangularWindow; 61 | 62 | Preferences *prefs = Preferences::getInstance(); 63 | 64 | m_windowShape = new WindowShapePreview; 65 | 66 | m_windowCombo = new QComboBox; 67 | int window = int(defaultType); 68 | int index = 0; 69 | 70 | for (int i = 0; i <= 8; ++i) { 71 | m_windowCombo->addItem(prefs->getPropertyValueLabel("Window Type", 72 | m_windows[i])); 73 | if (m_windows[i] == window) index = i; 74 | } 75 | 76 | m_windowCombo->setCurrentIndex(index); 77 | 78 | layout->addWidget(m_windowShape); 79 | layout->addWidget(m_windowCombo); 80 | 81 | connect(m_windowCombo, SIGNAL(currentIndexChanged(int)), 82 | this, SLOT(windowIndexChanged(int))); 83 | 84 | m_windowType = defaultType; 85 | m_windowShape->setWindowType(m_windowType); 86 | } 87 | 88 | WindowTypeSelector::~WindowTypeSelector() 89 | { 90 | delete[] m_windows; 91 | } 92 | 93 | WindowType 94 | WindowTypeSelector::getWindowType() const 95 | { 96 | return m_windowType; 97 | } 98 | 99 | void 100 | WindowTypeSelector::setWindowType(WindowType type) 101 | { 102 | if (type == m_windowType) return; 103 | int index; 104 | for (index = 0; index <= 8; ++index) { 105 | if (m_windows[index] == type) break; 106 | } 107 | if (index <= 8) m_windowCombo->setCurrentIndex(index); 108 | m_windowType = type; 109 | m_windowShape->setWindowType(m_windowType); 110 | } 111 | 112 | void 113 | WindowTypeSelector::windowIndexChanged(int index) 114 | { 115 | WindowType type = m_windows[index]; 116 | if (type == m_windowType) return; 117 | m_windowType = type; 118 | m_windowShape->setWindowType(m_windowType); 119 | emit windowTypeChanged(type); 120 | } 121 | 122 | } // end namespace sv 123 | 124 | -------------------------------------------------------------------------------- /widgets/ColourComboBox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2007-2016 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "ColourComboBox.h" 17 | 18 | #include "ColourNameDialog.h" 19 | 20 | #include "layer/ColourDatabase.h" 21 | 22 | #include "base/Debug.h" 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | using namespace std; 30 | 31 | namespace sv { 32 | 33 | ColourComboBox::ColourComboBox(bool withAddNewColourEntry, QWidget *parent) : 34 | NotifyingComboBox(parent), 35 | m_withAddNewColourEntry(withAddNewColourEntry) 36 | { 37 | setEditable(false); 38 | rebuild(); 39 | 40 | connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); 41 | connect(ColourDatabase::getInstance(), SIGNAL(colourDatabaseChanged()), 42 | this, SLOT(rebuild())); 43 | } 44 | 45 | void 46 | ColourComboBox::includeUnsetEntry(QString entry) 47 | { 48 | m_unsetEntry = entry; 49 | 50 | rebuild(); 51 | 52 | blockSignals(true); 53 | int ix = currentIndex(); 54 | setCurrentIndex(ix + 1); 55 | blockSignals(false); 56 | } 57 | 58 | void 59 | ColourComboBox::comboActivated(int comboIndex) 60 | { 61 | int index = comboIndex; 62 | if (m_unsetEntry != "") { 63 | index = comboIndex - 1; // so index is the colour index 64 | } 65 | 66 | if (!m_withAddNewColourEntry || 67 | index < int(ColourDatabase::getInstance()->getColourCount())) { 68 | emit colourChanged(index); 69 | return; 70 | } 71 | 72 | QColor newColour = QColorDialog::getColor(); 73 | if (!newColour.isValid()) return; 74 | 75 | ColourNameDialog dialog(tr("Name New Colour"), 76 | tr("Enter a name for the new colour:"), 77 | newColour, newColour.name(), this); 78 | dialog.showDarkBackgroundCheckbox(tr("Prefer black background for this colour")); 79 | if (dialog.exec() == QDialog::Accepted) { 80 | //!!! command 81 | ColourDatabase *db = ColourDatabase::getInstance(); 82 | int index = db->addColour(newColour, dialog.getColourName()); 83 | db->setUseDarkBackground(index, dialog.isDarkBackgroundChecked()); 84 | // addColour will have called back on rebuild(), and the new 85 | // colour will be at the index previously occupied by Add New 86 | // Colour, which is our current index 87 | emit colourChanged(currentIndex()); 88 | } 89 | } 90 | 91 | void 92 | ColourComboBox::rebuild() 93 | { 94 | blockSignals(true); 95 | 96 | int ix = currentIndex(); 97 | 98 | clear(); 99 | 100 | if (m_unsetEntry != "") { 101 | addItem(m_unsetEntry); 102 | } 103 | 104 | int size = (QFontMetrics(QFont()).height() * 2) / 3; 105 | if (size < 12) size = 12; 106 | 107 | ColourDatabase *db = ColourDatabase::getInstance(); 108 | for (int i = 0; i < db->getColourCount(); ++i) { 109 | QString name = db->getColourName(i); 110 | addItem(db->getExamplePixmap(i, QSize(size, size)), name); 111 | } 112 | 113 | if (m_withAddNewColourEntry) { 114 | addItem(tr("Add New Colour...")); 115 | } 116 | 117 | setCurrentIndex(ix); 118 | 119 | if (count() < 18) { 120 | setMaxVisibleItems(count()); 121 | } else { 122 | setMaxVisibleItems(10); 123 | } 124 | 125 | blockSignals(false); 126 | } 127 | 128 | } // end namespace sv 129 | 130 | -------------------------------------------------------------------------------- /widgets/CSVExportDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef SV_CSV_EXPORT_DIALOG_H 16 | #define SV_CSV_EXPORT_DIALOG_H 17 | 18 | #include 19 | #include 20 | 21 | class QComboBox; 22 | class QCheckBox; 23 | class QRadioButton; 24 | 25 | namespace sv { 26 | 27 | class CSVExportDialog : public QDialog 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | struct Configuration { 33 | Configuration() : 34 | layerName(""), 35 | fileExtension("csv"), 36 | isDense(false), 37 | haveView(false), 38 | haveSelection(false) { } 39 | 40 | /** 41 | * Presentation name of the layer being exported. 42 | */ 43 | QString layerName; 44 | 45 | /** 46 | * Extension of file being exported into. 47 | */ 48 | QString fileExtension; 49 | 50 | /** 51 | * True if the model is a dense type for which timestamps are 52 | * not written by default. 53 | */ 54 | bool isDense; 55 | 56 | /** 57 | * True if we have a view that provides a vertical scale 58 | * range, so we may want to offer a choice between exporting 59 | * only the visible range or exporting full height. This 60 | * choice happens to be offered only if isDense is also true. 61 | */ 62 | bool haveView; 63 | 64 | /** 65 | * True if there is a selection current that the user may want 66 | * to constrain export to. 67 | */ 68 | bool haveSelection; 69 | }; 70 | 71 | CSVExportDialog(Configuration config, QWidget *parent); 72 | 73 | /** 74 | * Return the column delimiter to use in the exported file. Either 75 | * the default for the supplied file extension, or some other 76 | * option chosen by the user. 77 | */ 78 | QString getDelimiter() const; 79 | 80 | /** 81 | * Return true if we should include a header row at the top of the 82 | * exported file. 83 | */ 84 | bool shouldIncludeHeader() const; 85 | 86 | /** 87 | * Return true if we should write a timestamp column. This is 88 | * always true for non-dense models, but is a user option for 89 | * dense ones. 90 | */ 91 | bool shouldIncludeTimestamps() const; 92 | 93 | /** 94 | * Return true if we should use sample frames rather than seconds 95 | * for the timestamp column (and duration where present). 96 | */ 97 | bool shouldWriteTimeInFrames() const; 98 | 99 | /** 100 | * Return true if we should constrain the vertical range to the 101 | * visible area only. Otherwise we should export the full vertical 102 | * range of the model. 103 | */ 104 | bool shouldConstrainToViewHeight() const; 105 | 106 | /** 107 | * Return true if we should export the selected time range(s) 108 | * only. Otherwise we should export the full length of the model. 109 | */ 110 | bool shouldConstrainToSelection() const; 111 | 112 | private: 113 | Configuration m_config; 114 | 115 | QComboBox *m_separatorCombo; 116 | QCheckBox *m_header; 117 | QCheckBox *m_timestamps; 118 | QRadioButton *m_seconds; 119 | QRadioButton *m_frames; 120 | QRadioButton *m_selectionOnly; 121 | QRadioButton *m_viewOnly; 122 | 123 | private slots: 124 | void timestampsToggled(bool); 125 | }; 126 | 127 | } // end namespace sv 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /layer/RenderTimer.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef RENDER_TIMER_H 16 | #define RENDER_TIMER_H 17 | 18 | #include 19 | 20 | namespace sv { 21 | 22 | class RenderTimer 23 | { 24 | public: 25 | enum Type { 26 | /// A normal rendering operation with normal responsiveness demands 27 | FastRender, 28 | 29 | /// An operation that the user might accept being slower 30 | SlowRender, 31 | 32 | /// An operation that should always complete, i.e. as if there 33 | /// were no RenderTimer in use, but without having to change 34 | /// client code structurally 35 | NoTimeout 36 | }; 37 | 38 | /** 39 | * Create a new RenderTimer and start timing. Make one of these 40 | * before rendering, and then call outOfTime() regularly during 41 | * rendering. If outOfTime() returns true, abandon rendering! and 42 | * schedule the rest for after some user responsiveness has 43 | * happened. 44 | */ 45 | RenderTimer(Type t) : 46 | m_start(std::chrono::steady_clock::now()), 47 | m_haveLimits(true), 48 | m_minFraction(0.15), 49 | m_almostFraction(0.65), 50 | m_softLimit(0.1), 51 | m_hardLimit(0.2), 52 | m_softLimitOverridden(false) { 53 | 54 | if (t == NoTimeout) { 55 | m_haveLimits = false; 56 | } else if (t == SlowRender) { 57 | m_softLimit = 0.2; 58 | m_hardLimit = 0.4; 59 | } 60 | } 61 | 62 | 63 | /** 64 | * Return true if we have run out of time and should suspend 65 | * rendering and handle user events instead. Call this regularly 66 | * during rendering work: fractionComplete should be an estimate 67 | * of how much of the work has been done as of this call, as a 68 | * number between 0.0 (none of it) and 1.0 (all of it). 69 | */ 70 | bool outOfTime(double fractionComplete) { 71 | 72 | if (!m_haveLimits || fractionComplete < m_minFraction) { 73 | return false; 74 | } 75 | 76 | auto t = std::chrono::steady_clock::now(); 77 | double elapsed = std::chrono::duration(t - m_start).count(); 78 | 79 | if (elapsed > m_hardLimit) { 80 | return true; 81 | } else if (!m_softLimitOverridden && elapsed > m_softLimit) { 82 | if (fractionComplete > m_almostFraction) { 83 | // If we're "almost done" by the time we reach the 84 | // soft limit, ignore it (though always respect the 85 | // hard limit, above). Otherwise respect the soft 86 | // limit and report out of time now. 87 | m_softLimitOverridden = true; 88 | } else { 89 | return true; 90 | } 91 | } 92 | 93 | return false; 94 | } 95 | 96 | double secondsPerItem(int itemsRendered) const { 97 | 98 | if (itemsRendered == 0) return 0.0; 99 | 100 | auto t = std::chrono::steady_clock::now(); 101 | double elapsed = std::chrono::duration(t - m_start).count(); 102 | 103 | return elapsed / itemsRendered; 104 | } 105 | 106 | private: 107 | std::chrono::time_point m_start; 108 | bool m_haveLimits; 109 | double m_minFraction; // proportion, 0.0 -> 1.0 110 | double m_almostFraction; // proportion, 0.0 -> 1.0 111 | double m_softLimit; // seconds 112 | double m_hardLimit; // seconds 113 | bool m_softLimitOverridden; 114 | }; 115 | 116 | } // end namespace sv 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /widgets/LevelPanWidget.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #ifndef LEVEL_PAN_WIDGET_H 16 | #define LEVEL_PAN_WIDGET_H 17 | 18 | #include 19 | 20 | #include "WheelCounter.h" 21 | 22 | namespace sv { 23 | 24 | /** 25 | * A simple widget for coarse level and pan control. 26 | */ 27 | 28 | class LevelPanWidget : public QWidget 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | LevelPanWidget(QWidget *parent = 0); 34 | ~LevelPanWidget(); 35 | 36 | /// Return level as a gain value. The basic level range is [0,1] but the 37 | /// gain scale may go up to 4.0 38 | float getLevel() const; 39 | 40 | /// Return pan as a value in the range [-1,1] 41 | float getPan() const; 42 | 43 | /// Find out whether the widget is editable 44 | bool isEditable() const; 45 | 46 | /// Discover whether the level range includes muting or not 47 | bool includesMute() const; 48 | 49 | /// Draw a suitably sized copy of the widget's contents to the given device 50 | void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const; 51 | 52 | QSize sizeHint() const override; 53 | 54 | public slots: 55 | /// Set level. The basic level range is [0,1] but the scale may go 56 | /// higher. The value will be rounded. 57 | void setLevel(float); 58 | 59 | /// Set pan in the range [-1,1]. The value will be rounded 60 | void setPan(float); 61 | 62 | /// Set left and right peak monitoring levels in the range [0,1] 63 | void setMonitoringLevels(float, float); 64 | 65 | /// Specify whether the widget is editable or read-only (default editable) 66 | void setEditable(bool); 67 | 68 | /// Specify whether the level range should include muting or not 69 | void setIncludeMute(bool); 70 | 71 | /// Reset to default values 72 | void setToDefault(); 73 | 74 | // public so it can be called from LevelPanToolButton (ew) 75 | void wheelEvent(QWheelEvent *ev) override; 76 | 77 | signals: 78 | void levelChanged(float); // range [0,1] 79 | void panChanged(float); // range [-1,1] 80 | 81 | void mouseEntered(); 82 | void mouseLeft(); 83 | 84 | protected: 85 | void mousePressEvent(QMouseEvent *ev) override; 86 | void mouseMoveEvent(QMouseEvent *ev) override; 87 | void mouseReleaseEvent(QMouseEvent *ev) override; 88 | void paintEvent(QPaintEvent *ev) override; 89 | void enterEvent(QEnterEvent *) override; 90 | void leaveEvent(QEvent *) override; 91 | 92 | void emitLevelChanged(); 93 | void emitPanChanged(); 94 | 95 | int m_minNotch; 96 | int m_maxNotch; 97 | int m_notch; 98 | int m_pan; 99 | float m_monitorLeft; 100 | float m_monitorRight; 101 | bool m_editable; 102 | bool m_editing; 103 | bool m_includeMute; 104 | bool m_includeHalfSteps; 105 | 106 | WheelCounter m_wheelCounter; 107 | 108 | int clampNotch(int notch) const; 109 | int clampPan(int pan) const; 110 | 111 | int audioLevelToNotch(float audioLevel) const; 112 | float notchToAudioLevel(int notch) const; 113 | 114 | int audioPanToPan(float audioPan) const; 115 | float panToAudioPan(int pan) const; 116 | 117 | int coordsToNotch(QRectF rect, QPointF pos) const; 118 | int coordsToPan(QRectF rect, QPointF pos) const; 119 | 120 | QColor cellToColour(int cell) const; 121 | 122 | QSizeF cellSize(QRectF) const; 123 | QPointF cellCentre(QRectF, int row, int col) const; 124 | QSizeF cellLightSize(QRectF) const; 125 | QRectF cellLightRect(QRectF, int row, int col) const; 126 | QRectF cellOutlineRect(QRectF, int row, int col) const; 127 | double thinLineWidth(QRectF) const; 128 | double cornerRadius(QRectF) const; 129 | }; 130 | 131 | } // end namespace sv 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /widgets/PluginParameterDialog.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_PLUGIN_PARAMETER_DIALOG_H 17 | #define SV_PLUGIN_PARAMETER_DIALOG_H 18 | 19 | #include 20 | 21 | #include "base/Window.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | class QWidget; 28 | class QPushButton; 29 | class QLabel; 30 | class QGroupBox; 31 | class QComboBox; 32 | class QCheckBox; 33 | 34 | namespace sv { 35 | 36 | class PluginParameterBox; 37 | 38 | /** 39 | * A dialog for editing the parameters of a given plugin, using a 40 | * PluginParameterBox. This dialog does not contain any mechanism for 41 | * selecting the plugin in the first place. Note that the dialog 42 | * directly modifies the parameters of the plugin, so they will remain 43 | * modified even if the dialog is then cancelled. 44 | */ 45 | 46 | class PluginParameterDialog : public QDialog 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | PluginParameterDialog(std::shared_ptr plugin, 52 | QWidget *parent = 0); 53 | ~PluginParameterDialog(); 54 | 55 | void setChannelArrangement(int sourceChannels, 56 | int targetChannels, 57 | int defaultChannel); 58 | 59 | void setOutputLabel(QString output, QString description); 60 | 61 | void setMoreInfoUrl(QString url); 62 | 63 | void setShowProcessingOptions(bool showWindowSize, 64 | bool showFrequencyDomainOptions); 65 | 66 | void setCandidateInputModels(const QStringList &names, 67 | QString defaultName); 68 | void setShowSelectionOnlyOption(bool show); 69 | 70 | std::shared_ptr getPlugin() { return m_plugin; } 71 | 72 | int getChannel() const { return m_channel; } 73 | 74 | QString getInputModel() const; 75 | bool getSelectionOnly() const; 76 | 77 | //!!! merge with PluginTransform::ExecutionContext 78 | 79 | void getProcessingParameters(int &blockSize) const; 80 | void getProcessingParameters(int &stepSize, int &blockSize, 81 | WindowType &windowType) const; 82 | 83 | int exec() override; 84 | 85 | signals: 86 | void pluginConfigurationChanged(QString); 87 | void inputModelChanged(QString); 88 | 89 | protected slots: 90 | void channelComboChanged(int); 91 | void blockSizeComboChanged(const QString &); 92 | void incrementComboChanged(const QString &); 93 | void windowTypeChanged(WindowType type); 94 | void advancedToggled(); 95 | void moreInfo(); 96 | void setAdvancedVisible(bool); 97 | void inputModelComboChanged(int); 98 | void selectionOnlyChanged(int); 99 | void dialogAccepted(); 100 | 101 | protected: 102 | std::shared_ptr m_plugin; 103 | 104 | int m_channel; 105 | int m_stepSize; 106 | int m_blockSize; 107 | 108 | WindowType m_windowType; 109 | PluginParameterBox *m_parameterBox; 110 | 111 | QLabel *m_outputLabel; 112 | QLabel *m_outputValue; 113 | QLabel *m_outputDescription; 114 | QLabel *m_outputSpacer; 115 | 116 | QPushButton *m_moreInfo; 117 | QString m_moreInfoUrl; 118 | 119 | QGroupBox *m_channelBox; 120 | bool m_haveChannelBoxData; 121 | 122 | QGroupBox *m_windowBox; 123 | bool m_haveWindowBoxData; 124 | 125 | QGroupBox *m_inputModelBox; 126 | QComboBox *m_inputModels; 127 | QCheckBox *m_selectionOnly; 128 | QStringList m_inputModelList; 129 | QString m_currentInputModel; 130 | bool m_currentSelectionOnly; 131 | 132 | QPushButton *m_advancedButton; 133 | QWidget *m_advanced; 134 | bool m_advancedVisible; 135 | }; 136 | 137 | } // end namespace sv 138 | 139 | #endif 140 | 141 | -------------------------------------------------------------------------------- /widgets/LayerTree.h: -------------------------------------------------------------------------------- 1 | 2 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 3 | 4 | /* 5 | Sonic Visualiser 6 | An audio file viewer and annotation editor. 7 | Centre for Digital Music, Queen Mary, University of London. 8 | This file copyright 2006 Chris Cannam. 9 | 10 | This program is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU General Public License as 12 | published by the Free Software Foundation; either version 2 of the 13 | License, or (at your option) any later version. See the file 14 | COPYING included with this distribution for more information. 15 | */ 16 | 17 | #ifndef SV_LAYER_TREE_H 18 | #define SV_LAYER_TREE_H 19 | 20 | #include 21 | 22 | #include "data/model/Model.h" 23 | 24 | #include 25 | 26 | namespace sv { 27 | 28 | class PaneStack; 29 | class View; 30 | class Pane; 31 | class Layer; 32 | class PropertyContainer; 33 | 34 | class ModelMetadataModel : public QAbstractItemModel 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | ModelMetadataModel(PaneStack *stack, bool waveModelsOnly, QObject *parent = 0); 40 | virtual ~ModelMetadataModel(); 41 | 42 | QVariant data(const QModelIndex &index, int role) const override; 43 | 44 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; 45 | 46 | Qt::ItemFlags flags(const QModelIndex &index) const override; 47 | 48 | QVariant headerData(int section, Qt::Orientation orientation, 49 | int role = Qt::DisplayRole) const override; 50 | 51 | QModelIndex index(int row, int column, 52 | const QModelIndex &parent = QModelIndex()) const override; 53 | 54 | QModelIndex parent(const QModelIndex &index) const override; 55 | 56 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 57 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; 58 | 59 | protected slots: 60 | void paneAdded(); 61 | void paneDeleted(); 62 | void propertyContainerAdded(PropertyContainer *); 63 | void propertyContainerRemoved(PropertyContainer *); 64 | void propertyContainerSelected(PropertyContainer *); 65 | void propertyContainerPropertyChanged(PropertyContainer *); 66 | void playParametersAudibilityChanged(bool); 67 | void paneLayerModelChanged(); 68 | void rebuildModelSet(); 69 | 70 | protected: 71 | PaneStack *m_stack; 72 | bool m_waveModelsOnly; 73 | int m_modelTypeColumn; 74 | int m_modelNameColumn; 75 | int m_modelMakerColumn; 76 | int m_modelSourceColumn; 77 | int m_columnCount; 78 | 79 | std::set m_models; 80 | }; 81 | 82 | class LayerTreeModel : public QAbstractItemModel 83 | { 84 | Q_OBJECT 85 | 86 | public: 87 | LayerTreeModel(PaneStack *stack, QObject *parent = 0); 88 | virtual ~LayerTreeModel(); 89 | 90 | QVariant data(const QModelIndex &index, int role) const override; 91 | 92 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; 93 | 94 | Qt::ItemFlags flags(const QModelIndex &index) const override; 95 | 96 | QVariant headerData(int section, Qt::Orientation orientation, 97 | int role = Qt::DisplayRole) const override; 98 | 99 | QModelIndex index(int row, int column, 100 | const QModelIndex &parent = QModelIndex()) const override; 101 | 102 | QModelIndex parent(const QModelIndex &index) const override; 103 | 104 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 105 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; 106 | 107 | protected slots: 108 | void paneAdded(); 109 | void paneAboutToBeDeleted(Pane *); 110 | void propertyContainerAdded(PropertyContainer *); 111 | void propertyContainerRemoved(PropertyContainer *); 112 | void propertyContainerSelected(PropertyContainer *); 113 | void propertyContainerPropertyChanged(PropertyContainer *); 114 | void paneLayerModelChanged(); 115 | void playParametersAudibilityChanged(bool); 116 | 117 | protected: 118 | PaneStack *m_stack; 119 | std::set m_deletedPanes; 120 | int m_layerNameColumn; 121 | int m_layerVisibleColumn; 122 | int m_layerPlayedColumn; 123 | int m_modelNameColumn; 124 | int m_columnCount; 125 | }; 126 | 127 | } // end namespace sv 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /widgets/SelectableLabel.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2008 QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #include "SelectableLabel.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace sv { 22 | 23 | SelectableLabel::SelectableLabel(QWidget *p) : 24 | QLabel(p), 25 | m_selected(false) 26 | { 27 | setTextFormat(Qt::RichText); 28 | // setLineWidth(2); 29 | // setFixedWidth(480); 30 | setupStyle(); 31 | setOpenExternalLinks(true); 32 | } 33 | 34 | SelectableLabel::~SelectableLabel() 35 | { 36 | } 37 | 38 | void 39 | SelectableLabel::setUnselectedText(QString text) 40 | { 41 | if (m_unselectedText == text) return; 42 | m_unselectedText = text; 43 | if (!m_selected) { 44 | setText(m_unselectedText); 45 | resize(sizeHint()); 46 | } 47 | } 48 | 49 | void 50 | SelectableLabel::setSelectedText(QString text) 51 | { 52 | if (m_selectedText == text) return; 53 | m_selectedText = text; 54 | if (m_selected) { 55 | setText(m_selectedText); 56 | resize(sizeHint()); 57 | } 58 | } 59 | 60 | void 61 | SelectableLabel::setupStyle() 62 | { 63 | QPalette palette = QApplication::palette(); 64 | 65 | setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | 66 | Qt::LinksAccessibleByMouse | 67 | Qt::TextSelectableByMouse); 68 | 69 | if (m_selected) { 70 | setWordWrap(true); 71 | setStyleSheet 72 | (QString("QLabel:hover { background: %1; color: %3; } " 73 | "QLabel:!hover { background: %2; color: %3 } " 74 | "QLabel { padding: 7px }") 75 | .arg(palette.mid().color().lighter(120).name()) 76 | .arg(palette.mid().color().lighter(140).name()) 77 | .arg(palette.text().color().name())); 78 | } else { 79 | setWordWrap(false); 80 | setStyleSheet 81 | (QString("QLabel:hover { background: %1; color: %3; } " 82 | "QLabel:!hover { background: %2; color: %3 } " 83 | "QLabel { padding: 7px }") 84 | .arg(palette.button().color().name()) 85 | .arg(palette.light().color().name()) 86 | .arg(palette.text().color().name())); 87 | } 88 | } 89 | 90 | void 91 | SelectableLabel::setSelected(bool s) 92 | { 93 | if (m_selected == s) return; 94 | m_selected = s; 95 | if (m_selected) { 96 | setText(m_selectedText); 97 | } else { 98 | setText(m_unselectedText); 99 | } 100 | setupStyle(); 101 | parentWidget()->resize(parentWidget()->sizeHint()); 102 | } 103 | 104 | void 105 | SelectableLabel::toggle() 106 | { 107 | setSelected(!m_selected); 108 | } 109 | 110 | void 111 | SelectableLabel::mousePressEvent(QMouseEvent *e) 112 | { 113 | m_swallowRelease = !m_selected; 114 | setSelected(true); 115 | QLabel::mousePressEvent(e); 116 | emit selectionChanged(); 117 | } 118 | 119 | void 120 | SelectableLabel::mouseDoubleClickEvent(QMouseEvent *e) 121 | { 122 | QLabel::mouseDoubleClickEvent(e); 123 | emit doubleClicked(); 124 | } 125 | 126 | void 127 | SelectableLabel::mouseReleaseEvent(QMouseEvent *e) 128 | { 129 | if (!m_swallowRelease) QLabel::mouseReleaseEvent(e); 130 | m_swallowRelease = false; 131 | } 132 | 133 | void 134 | SelectableLabel::enterEvent(QEnterEvent *) 135 | { 136 | // cerr << "enterEvent" << endl; 137 | // QPalette palette = QApplication::palette(); 138 | // palette.setColor(QPalette::Window, Qt::gray); 139 | // setStyleSheet("background: gray"); 140 | // setPalette(palette); 141 | } 142 | 143 | void 144 | SelectableLabel::leaveEvent(QEvent *) 145 | { 146 | // cerr << "leaveEvent" << endl; 147 | // setStyleSheet("background: white"); 148 | // QPalette palette = QApplication::palette(); 149 | // palette.setColor(QPalette::Window, Qt::gray); 150 | // setPalette(palette); 151 | } 152 | } // end namespace sv 153 | 154 | -------------------------------------------------------------------------------- /layer/ScrollableMagRangeCache.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of the 11 | License, or (at your option) any later version. See the file 12 | COPYING included with this distribution for more information. 13 | */ 14 | 15 | #include "ScrollableMagRangeCache.h" 16 | 17 | #include "base/HitCount.h" 18 | #include "base/Debug.h" 19 | 20 | #include 21 | using namespace std; 22 | 23 | //#define DEBUG_SCROLLABLE_MAG_RANGE_CACHE 1 24 | 25 | namespace sv { 26 | 27 | void 28 | ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v, 29 | sv_frame_t newStartFrame) 30 | { 31 | static HitCount count("ScrollableMagRangeCache: scrolling"); 32 | 33 | int dx = (v->getXForFrame(m_startFrame) - 34 | v->getXForFrame(newStartFrame)); 35 | 36 | #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE 37 | SVDEBUG << "ScrollableMagRangeCache::scrollTo: start frame " << m_startFrame 38 | << " -> " << newStartFrame << ", dx = " << dx << endl; 39 | #endif 40 | 41 | if (m_startFrame == newStartFrame) { 42 | // haven't moved 43 | count.hit(); 44 | return; 45 | } 46 | 47 | m_startFrame = newStartFrame; 48 | 49 | if (dx == 0) { 50 | // haven't moved visibly (even though start frame may have changed) 51 | count.hit(); 52 | return; 53 | } 54 | 55 | int w = int(m_ranges.size()); 56 | 57 | if (dx <= -w || dx >= w) { 58 | // scrolled entirely off 59 | invalidate(); 60 | count.miss(); 61 | return; 62 | } 63 | 64 | count.partial(); 65 | 66 | // dx is in range, cache is scrollable 67 | 68 | if (dx < 0) { 69 | // The new start frame is to the left of the old start 70 | // frame. We need to add some empty ranges at the left (start) 71 | // end and clip the right end. Assemble -dx new values, then 72 | // w+dx old values starting at index 0. 73 | 74 | auto newRanges = vector(-dx); 75 | newRanges.insert(newRanges.end(), 76 | m_ranges.begin(), m_ranges.begin() + (w + dx)); 77 | m_ranges = newRanges; 78 | 79 | } else { 80 | // The new start frame is to the right of the old start 81 | // frame. We want to clip the left (start) end and add some 82 | // empty ranges at the right end. Assemble w-dx old values 83 | // starting at index dx, then dx new values. 84 | 85 | auto newRanges = vector(dx); 86 | newRanges.insert(newRanges.begin(), 87 | m_ranges.begin() + dx, m_ranges.end()); 88 | m_ranges = newRanges; 89 | } 90 | 91 | #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE 92 | SVDEBUG << "maxes (" << m_ranges.size() << ") now: "; 93 | for (int i = 0; in_range_for(m_ranges, i); ++i) { 94 | SVDEBUG << m_ranges[i].getMax() << " "; 95 | } 96 | SVDEBUG << endl; 97 | #endif 98 | } 99 | 100 | MagnitudeRange 101 | ScrollableMagRangeCache::getRange(int x, int count) const 102 | { 103 | MagnitudeRange r; 104 | #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE 105 | SVDEBUG << "ScrollableMagRangeCache::getRange(" << x << ", " << count << ")" << endl; 106 | #endif 107 | for (int i = 0; i < count; ++i) { 108 | const auto &cr = m_ranges.at(x + i); 109 | if (cr.isSet()) { 110 | r.sample(cr); 111 | } 112 | #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE 113 | SVDEBUG << cr.getMin() << "->" << cr.getMax() << " "; 114 | #endif 115 | } 116 | #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE 117 | SVDEBUG << endl; 118 | #endif 119 | return r; 120 | } 121 | 122 | void 123 | ScrollableMagRangeCache::sampleColumn(int column, const MagnitudeRange &r) 124 | { 125 | if (!in_range_for(m_ranges, column)) { 126 | SVCERR << "ERROR: ScrollableMagRangeCache::sampleColumn: column " << column 127 | << " is out of range for cache of width " << m_ranges.size() 128 | << " (with start frame " << m_startFrame << ")" << endl; 129 | throw logic_error("column out of range"); 130 | } else { 131 | m_ranges[column].sample(r); 132 | } 133 | } 134 | 135 | } // end namespace sv 136 | 137 | -------------------------------------------------------------------------------- /layer/ColourMapper.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2007 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_COLOUR_MAPPER_H 17 | #define SV_COLOUR_MAPPER_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace sv { 25 | 26 | /** 27 | * A class for mapping intensity values onto various colour maps. 28 | */ 29 | class ColourMapper 30 | { 31 | public: 32 | ColourMapper(int map, 33 | bool inverted, 34 | double minValue, 35 | double maxValue); 36 | ~ColourMapper(); 37 | 38 | ColourMapper(const ColourMapper &) =default; 39 | ColourMapper &operator=(const ColourMapper &) =default; 40 | 41 | enum ColourMap { 42 | Green, 43 | Sunset, 44 | WhiteOnBlack, 45 | BlackOnWhite, 46 | Cherry, 47 | Wasp, 48 | Ice, 49 | FruitSalad, 50 | Banded, 51 | Highlight, 52 | Printer, 53 | HighGain, 54 | BlueOnBlack, 55 | Cividis, 56 | Magma 57 | }; 58 | 59 | int getMap() const { return m_map; } 60 | bool isInverted() const { return m_inverted; } 61 | double getMinValue() const { return m_min; } 62 | double getMaxValue() const { return m_max; } 63 | 64 | /** 65 | * Return the number of known colour maps. 66 | */ 67 | static int getColourMapCount(); 68 | 69 | /** 70 | * Return a human-readable label for the colour map with the given 71 | * index. This may have been subject to translation. 72 | */ 73 | static QString getColourMapLabel(int n); 74 | 75 | /** 76 | * Return a machine-readable id string for the colour map with the 77 | * given index. This is not translated and is intended for use in 78 | * file I/O. 79 | */ 80 | static QString getColourMapId(int n); 81 | 82 | /** 83 | * Return the index for the colour map with the given 84 | * machine-readable id string, or -1 if the id is not recognised. 85 | */ 86 | static int getColourMapById(QString id); 87 | 88 | /** 89 | * Older versions of colour-handling code save and reload colour 90 | * maps by numerical index and can't properly handle situations in 91 | * which the index order changes between releases, or new indices 92 | * are added. So when we save a colour map by id, we should also 93 | * save a compatibility value that can be re-read by such 94 | * code. This value is an index into the series of colours used by 95 | * pre-3.2 SV code, namely (Default/Green, Sunset, WhiteOnBlack, 96 | * BlackOnWhite, RedOnBlue, YellowOnBlack, BlueOnBlack, 97 | * FruitSalad, Banded, Highlight, Printer, HighGain). It should 98 | * represent the closest equivalent to the current colour scheme 99 | * available in that set. This function returns that index. 100 | */ 101 | static int getBackwardCompatibilityColourMap(int n); 102 | 103 | /** 104 | * Map the given value to a colour. The value will be clamped to 105 | * the range minValue to maxValue (where both are drawn from the 106 | * constructor arguments). 107 | */ 108 | QColor map(double value) const; 109 | 110 | /** 111 | * Return a colour that contrasts somewhat with the colours in the 112 | * map, so as to be used for cursors etc. 113 | */ 114 | QColor getContrastingColour() const; 115 | 116 | /** 117 | * Return true if the colour map is intended to be placed over a 118 | * light background, false otherwise. This is typically true if 119 | * the colours corresponding to higher values are darker than 120 | * those corresponding to lower values. 121 | */ 122 | bool hasLightBackground() const; 123 | 124 | /** 125 | * Return a pixmap of the given size containing a preview swatch 126 | * for the colour map. 127 | */ 128 | QPixmap getExamplePixmap(QSize size) const; 129 | 130 | protected: 131 | int m_map; 132 | bool m_inverted; 133 | double m_min; 134 | double m_max; 135 | }; 136 | 137 | } // end namespace sv 138 | 139 | #endif 140 | 141 | -------------------------------------------------------------------------------- /widgets/TextAbbrev.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Sonic Visualiser 5 | An audio file viewer and annotation editor. 6 | Centre for Digital Music, Queen Mary, University of London. 7 | This file copyright 2006-2007 Chris Cannam and QMUL. 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License as 11 | published by the Free Software Foundation; either version 2 of the 12 | License, or (at your option) any later version. See the file 13 | COPYING included with this distribution for more information. 14 | */ 15 | 16 | #ifndef SV_TEXT_ABBREV_H 17 | #define SV_TEXT_ABBREV_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class QFontMetrics; 24 | 25 | namespace sv { 26 | 27 | class TextAbbrev 28 | { 29 | public: 30 | enum Policy { 31 | ElideEnd, 32 | ElideEndAndCommonPrefixes, 33 | ElideStart, 34 | ElideMiddle 35 | }; 36 | 37 | /** 38 | * Abbreviate the given text to the given maximum length 39 | * (including ellipsis), using the given abbreviation policy. If 40 | * fuzzy is true, the text will be left alone if it is "not much 41 | * more than" the maximum length. 42 | * 43 | * If ellipsis is non-empty, it will be used to show elisions in 44 | * preference to the default (which is "..."). 45 | */ 46 | static QString abbreviate(QString text, int maxLength, 47 | Policy policy = ElideEnd, 48 | bool fuzzy = true, 49 | QString ellipsis = ""); 50 | 51 | /** 52 | * Abbreviate the given text to the given maximum painted width, 53 | * using the given abbreviation policy. maxWidth is also modified 54 | * so as to return the painted width of the abbreviated text. 55 | * 56 | * If ellipsis is non-empty, it will be used to show elisions in 57 | * preference to the default (which is tr("...")). 58 | */ 59 | static QString abbreviate(QString text, 60 | const QFontMetrics &metrics, 61 | int &maxWidth, 62 | Policy policy = ElideEnd, 63 | QString ellipsis = ""); 64 | 65 | /** 66 | * Abbreviate all of the given texts to the given maximum length, 67 | * using the given abbreviation policy. If fuzzy is true, texts 68 | * that are "not much more than" the maximum length will be left 69 | * alone. 70 | * 71 | * If ellipsis is non-empty, it will be used to show elisions in 72 | * preference to the default (which is tr("...")). 73 | */ 74 | static QStringList abbreviate(const QStringList &texts, int maxLength, 75 | Policy policy = ElideEndAndCommonPrefixes, 76 | bool fuzzy = true, 77 | QString ellipsis = ""); 78 | 79 | /** 80 | * Abbreviate all of the given texts to the given maximum painted 81 | * width, using the given abbreviation policy. maxWidth is also 82 | * modified so as to return the maximum painted width of the 83 | * abbreviated texts. 84 | * 85 | * If ellipsis is non-empty, it will be used to show elisions in 86 | * preference to the default (which is tr("...")). 87 | */ 88 | static QStringList abbreviate(const QStringList &texts, 89 | const QFontMetrics &metrics, 90 | int &maxWidth, 91 | Policy policy = ElideEndAndCommonPrefixes, 92 | QString ellipsis = ""); 93 | 94 | protected: 95 | static QString getDefaultEllipsis(); 96 | static int getFuzzLength(QString ellipsis); 97 | static int getFuzzWidth(const QFontMetrics &metrics, QString ellipsis); 98 | static QString abbreviateTo(QString text, int characters, 99 | Policy policy, QString ellipsis); 100 | static QStringList elidePrefixes(const QStringList &texts, 101 | int targetReduction, 102 | QString ellipsis); 103 | static QStringList elidePrefixes(const QStringList &texts, 104 | const QFontMetrics &metrics, 105 | int targetWidthReduction, 106 | QString ellipsis); 107 | static std::set getCommonPrefixes(const QStringList &texts); 108 | }; 109 | 110 | } // end namespace sv 111 | 112 | #endif 113 | 114 | --------------------------------------------------------------------------------