annotate view/PaneStack.h @ 1523:1ccb64bfb22b

Make the waveform layer do the expected thing when MergeChannels mode (i.e. butterfly mode) is enabled even if there is only 1 channel. This combination isn't actually available in the UI for SV, but it's useful for Sonic Lineup.
author Chris Cannam
date Wed, 25 Sep 2019 13:42:17 +0100
parents 69b7fdd6394f
children 0f1601d870db
rev   line source
Chris@127 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 2
Chris@127 3 /*
Chris@127 4 Sonic Visualiser
Chris@127 5 An audio file viewer and annotation editor.
Chris@127 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@127 8
Chris@127 9 This program is free software; you can redistribute it and/or
Chris@127 10 modify it under the terms of the GNU General Public License as
Chris@127 11 published by the Free Software Foundation; either version 2 of the
Chris@127 12 License, or (at your option) any later version. See the file
Chris@127 13 COPYING included with this distribution for more information.
Chris@127 14 */
Chris@127 15
Chris@1270 16 #ifndef SV_PANESTACK_H
Chris@1270 17 #define SV_PANESTACK_H
Chris@127 18
Chris@127 19 #include <QFrame>
Chris@127 20
Chris@323 21 #include <map>
Chris@323 22
Chris@908 23 #include "base/BaseTypes.h"
Chris@908 24
Chris@127 25 class QWidget;
Chris@127 26 class QLabel;
Chris@127 27 class QStackedWidget;
Chris@1447 28 class QVBoxLayout;
Chris@127 29 class QSplitter;
Chris@495 30 class QGridLayout;
Chris@605 31 class QPushButton;
Chris@127 32 class View;
Chris@127 33 class Pane;
Chris@127 34 class Layer;
Chris@127 35 class ViewManager;
Chris@127 36 class PropertyContainer;
Chris@127 37 class PropertyStack;
Chris@867 38 class AlignmentView;
Chris@127 39
Chris@127 40 class PaneStack : public QFrame
Chris@127 41 {
Chris@127 42 Q_OBJECT
Chris@127 43
Chris@127 44 public:
Chris@1447 45 PaneStack(QWidget *parent,
Chris@1447 46 ViewManager *viewManager);
Chris@127 47
Chris@127 48 Pane *addPane(bool suppressPropertyBox = false); // I own the returned value
Chris@127 49 void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers
Chris@127 50
Chris@127 51 int getPaneCount() const; // Returns only count of visible panes
Chris@127 52 Pane *getPane(int n); // Of visible panes; I own the returned value
Chris@277 53 int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent
Chris@127 54
Chris@127 55 void hidePane(Pane *pane); // Also removes pane from getPane/getPaneCount
Chris@127 56 void showPane(Pane *pane); // Returns pane to getPane/getPaneCount
Chris@127 57
Chris@127 58 int getHiddenPaneCount() const;
Chris@127 59 Pane *getHiddenPane(int n); // I own the returned value
Chris@127 60
Chris@127 61 void setCurrentPane(Pane *pane);
Chris@127 62 void setCurrentLayer(Pane *pane, Layer *layer);
Chris@127 63 Pane *getCurrentPane();
Chris@127 64
Chris@127 65 enum LayoutStyle {
Chris@179 66 NoPropertyStacks = 0,
Chris@127 67 SinglePropertyStackLayout = 1,
Chris@127 68 PropertyStackPerPaneLayout = 2
Chris@127 69 };
Chris@127 70
Chris@127 71 LayoutStyle getLayoutStyle() const { return m_layoutStyle; }
Chris@127 72 void setLayoutStyle(LayoutStyle style);
Chris@127 73
Chris@1447 74 enum ResizeMode {
Chris@1447 75 UserResizeable = 0,
Chris@1447 76 AutoResizeOnly = 1
Chris@1447 77 };
Chris@1447 78
Chris@1447 79 ResizeMode getResizeMode() const { return m_resizeMode; }
Chris@1447 80 void setResizeMode(ResizeMode);
Chris@1447 81
Chris@1460 82 // Set whether the current-pane indicators and close buttons are
Chris@1460 83 // shown. The default is true.
Chris@1460 84 void setShowPaneAccessories(bool show);
Chris@1460 85
Chris@1460 86 // Set whether a close button is shown on the first pane as well
Chris@1460 87 // as others. (It may be reasonable to omit the close button from
Chris@1460 88 // what is presumably the main pane in some applications.) The
Chris@1460 89 // default is true.
Chris@1460 90 void setShowCloseButtonOnFirstPane(bool);
Chris@1460 91
Chris@235 92 void setPropertyStackMinWidth(int mw);
Chris@235 93
Chris@867 94 void setShowAlignmentViews(bool show);
Chris@867 95
Chris@320 96 void sizePanesEqually();
Chris@320 97
Chris@127 98 signals:
Chris@127 99 void currentPaneChanged(Pane *pane);
Chris@127 100 void currentLayerChanged(Pane *pane, Layer *layer);
Chris@127 101 void rightButtonMenuRequested(Pane *pane, QPoint position);
Chris@363 102 void propertyStacksResized(int width);
Chris@180 103 void propertyStacksResized();
Chris@189 104 void contextHelpChanged(const QString &);
Chris@127 105
Chris@271 106 void paneAdded(Pane *pane);
Chris@271 107 void paneAdded();
Chris@319 108 void paneHidden(Pane *pane);
Chris@319 109 void paneHidden();
Chris@271 110 void paneAboutToBeDeleted(Pane *pane);
Chris@271 111 void paneDeleted();
Chris@271 112
Chris@312 113 void dropAccepted(Pane *pane, QStringList uriList);
Chris@312 114 void dropAccepted(Pane *pane, QString text);
Chris@312 115
Chris@323 116 void paneDeleteButtonClicked(Pane *pane);
Chris@323 117
Chris@908 118 void doubleClickSelectInvoked(sv_frame_t frame);
Chris@716 119
Chris@127 120 public slots:
Chris@127 121 void propertyContainerAdded(PropertyContainer *);
Chris@127 122 void propertyContainerRemoved(PropertyContainer *);
Chris@127 123 void propertyContainerSelected(View *client, PropertyContainer *);
Chris@190 124 void viewSelected(View *v);
Chris@127 125 void paneInteractedWith();
Chris@127 126 void rightButtonMenuRequested(QPoint);
Chris@312 127 void paneDropAccepted(QStringList);
Chris@312 128 void paneDropAccepted(QString);
Chris@323 129 void paneDeleteButtonClicked();
Chris@500 130 void indicatorClicked();
Chris@127 131
Chris@127 132 protected:
Chris@127 133 Pane *m_currentPane;
Chris@127 134
Chris@127 135 struct PaneRec
Chris@127 136 {
Chris@1266 137 Pane *pane;
Chris@1266 138 QWidget *propertyStack;
Chris@867 139 QPushButton *xButton;
Chris@1266 140 QLabel *currentIndicator;
Chris@867 141 QFrame *frame;
Chris@867 142 QGridLayout *layout;
Chris@867 143 AlignmentView *alignmentView;
Chris@127 144 };
Chris@127 145
Chris@127 146 std::vector<PaneRec> m_panes;
Chris@127 147 std::vector<PaneRec> m_hiddenPanes;
Chris@127 148
Chris@712 149 bool m_showAccessories;
Chris@1460 150 bool m_showCloseButtonOnFirstPane;
Chris@867 151 bool m_showAlignmentViews;
Chris@712 152
Chris@1447 153 QSplitter *m_splitter; // constitutes the stack in UserResizeable mode
Chris@1447 154 QWidget *m_autoResizeStack; // constitutes the stack in AutoResizeOnly mode
Chris@1447 155 QVBoxLayout *m_autoResizeLayout;
Chris@1447 156
Chris@127 157 QStackedWidget *m_propertyStackStack;
Chris@127 158
Chris@127 159 ViewManager *m_viewManager; // I don't own this
Chris@235 160 int m_propertyStackMinWidth;
Chris@127 161 void sizePropertyStacks();
Chris@127 162
Chris@605 163 void showOrHidePaneAccessories();
Chris@605 164
Chris@867 165 void unlinkAlignmentViews();
Chris@867 166 void relinkAlignmentViews();
Chris@867 167
Chris@127 168 LayoutStyle m_layoutStyle;
Chris@1447 169 ResizeMode m_resizeMode;
Chris@127 170 };
Chris@127 171
Chris@127 172 #endif
Chris@127 173