annotate view/PaneStack.h @ 1553:76e4302a3fc2

Fix note numbering - ensure stable across whole track (as it used to be, but without scanning all notes in paint in order to do that)
author Chris Cannam
date Fri, 22 Nov 2019 14:12:50 +0000
parents 0f1601d870db
children 01a41a37bd26
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@1526 45 /// These options are for things that must be set on construction,
Chris@1526 46 /// and can't be changed afterwards
Chris@1526 47 enum class Option {
Chris@1526 48 Default = 0x0,
Chris@1526 49 NoUserResize = 0x1, // Suppress resize handles, auto-size only
Chris@1526 50 NoPropertyStacks = 0x2, // Never create property stacks
Chris@1526 51 NoPaneAccessories = 0x4, // Suppress current-pane and close button
Chris@1526 52 NoCloseOnFirstPane = 0x8, // Omit close button from the top pane
Chris@1526 53 ShowAlignmentViews = 0x10 // Include AlignmentViews between panes
Chris@1526 54 };
Chris@1526 55 typedef int Options;
Chris@1526 56
Chris@1447 57 PaneStack(QWidget *parent,
Chris@1526 58 ViewManager *viewManager,
Chris@1526 59 Options options = 0);
Chris@127 60
Chris@1526 61 Pane *addPane(); // I own the returned value
Chris@127 62 void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers
Chris@127 63
Chris@127 64 int getPaneCount() const; // Returns only count of visible panes
Chris@127 65 Pane *getPane(int n); // Of visible panes; I own the returned value
Chris@277 66 int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent
Chris@127 67
Chris@127 68 void hidePane(Pane *pane); // Also removes pane from getPane/getPaneCount
Chris@127 69 void showPane(Pane *pane); // Returns pane to getPane/getPaneCount
Chris@127 70
Chris@127 71 int getHiddenPaneCount() const;
Chris@127 72 Pane *getHiddenPane(int n); // I own the returned value
Chris@127 73
Chris@127 74 void setCurrentPane(Pane *pane);
Chris@127 75 void setCurrentLayer(Pane *pane, Layer *layer);
Chris@127 76 Pane *getCurrentPane();
Chris@127 77
Chris@1526 78 /// Runtime-switchable layout style for property stacks
Chris@127 79 enum LayoutStyle {
Chris@1526 80 HiddenPropertyStacksLayout = 0,
Chris@127 81 SinglePropertyStackLayout = 1,
Chris@127 82 PropertyStackPerPaneLayout = 2
Chris@127 83 };
Chris@127 84
Chris@127 85 LayoutStyle getLayoutStyle() const { return m_layoutStyle; }
Chris@127 86 void setLayoutStyle(LayoutStyle style);
Chris@127 87
Chris@235 88 void setPropertyStackMinWidth(int mw);
Chris@235 89
Chris@320 90 void sizePanesEqually();
Chris@320 91
Chris@127 92 signals:
Chris@127 93 void currentPaneChanged(Pane *pane);
Chris@127 94 void currentLayerChanged(Pane *pane, Layer *layer);
Chris@127 95 void rightButtonMenuRequested(Pane *pane, QPoint position);
Chris@363 96 void propertyStacksResized(int width);
Chris@180 97 void propertyStacksResized();
Chris@189 98 void contextHelpChanged(const QString &);
Chris@127 99
Chris@271 100 void paneAdded(Pane *pane);
Chris@271 101 void paneAdded();
Chris@319 102 void paneHidden(Pane *pane);
Chris@319 103 void paneHidden();
Chris@271 104 void paneAboutToBeDeleted(Pane *pane);
Chris@271 105 void paneDeleted();
Chris@271 106
Chris@312 107 void dropAccepted(Pane *pane, QStringList uriList);
Chris@312 108 void dropAccepted(Pane *pane, QString text);
Chris@312 109
Chris@323 110 void paneDeleteButtonClicked(Pane *pane);
Chris@323 111
Chris@908 112 void doubleClickSelectInvoked(sv_frame_t frame);
Chris@716 113
Chris@127 114 public slots:
Chris@127 115 void propertyContainerAdded(PropertyContainer *);
Chris@127 116 void propertyContainerRemoved(PropertyContainer *);
Chris@127 117 void propertyContainerSelected(View *client, PropertyContainer *);
Chris@190 118 void viewSelected(View *v);
Chris@127 119 void paneInteractedWith();
Chris@127 120 void rightButtonMenuRequested(QPoint);
Chris@312 121 void paneDropAccepted(QStringList);
Chris@312 122 void paneDropAccepted(QString);
Chris@323 123 void paneDeleteButtonClicked();
Chris@500 124 void indicatorClicked();
Chris@127 125
Chris@127 126 protected:
Chris@127 127 Pane *m_currentPane;
Chris@127 128
Chris@127 129 struct PaneRec
Chris@127 130 {
Chris@1266 131 Pane *pane;
Chris@1266 132 QWidget *propertyStack;
Chris@867 133 QPushButton *xButton;
Chris@1266 134 QLabel *currentIndicator;
Chris@867 135 QFrame *frame;
Chris@867 136 QGridLayout *layout;
Chris@867 137 AlignmentView *alignmentView;
Chris@127 138 };
Chris@127 139
Chris@127 140 std::vector<PaneRec> m_panes;
Chris@127 141 std::vector<PaneRec> m_hiddenPanes;
Chris@127 142
Chris@1526 143 int m_options;
Chris@1526 144 QSplitter *m_splitter; // constitutes the stack in default mode
Chris@1526 145 QWidget *m_autoResizeStack; // constitutes the stack in NoUserResize mode
Chris@1447 146 QVBoxLayout *m_autoResizeLayout;
Chris@1447 147
Chris@127 148 QStackedWidget *m_propertyStackStack;
Chris@127 149
Chris@127 150 ViewManager *m_viewManager; // I don't own this
Chris@235 151 int m_propertyStackMinWidth;
Chris@127 152 void sizePropertyStacks();
Chris@127 153
Chris@605 154 void showOrHidePaneAccessories();
Chris@605 155
Chris@867 156 void unlinkAlignmentViews();
Chris@867 157 void relinkAlignmentViews();
Chris@867 158
Chris@127 159 LayoutStyle m_layoutStyle;
Chris@127 160 };
Chris@127 161
Chris@127 162 #endif
Chris@127 163