PaneStack.h
Go to the documentation of this file.
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_PANESTACK_H
17 #define SV_PANESTACK_H
18 
19 #include <QFrame>
20 
21 #include <map>
22 
23 #include "base/BaseTypes.h"
24 
25 class QWidget;
26 class QLabel;
27 class QStackedWidget;
28 class QVBoxLayout;
29 class QSplitter;
30 class QGridLayout;
31 class QPushButton;
32 class View;
33 class Pane;
34 class Layer;
35 class ViewManager;
36 class PropertyContainer;
37 class PropertyStack;
38 class AlignmentView;
39 
40 class PaneStack : public QFrame
41 {
42  Q_OBJECT
43 
44 public:
47  enum class Option {
48  Default = 0x0,
49  NoUserResize = 0x1, // Suppress resize handles, auto-size only
50  NoPropertyStacks = 0x2, // Never create property stacks
51  NoPaneAccessories = 0x4, // Suppress current-pane and close button
52  NoCloseOnFirstPane = 0x8, // Omit close button from the top pane
53  ShowAlignmentViews = 0x10 // Include AlignmentViews between panes
54  };
55  typedef int Options;
56 
57  PaneStack(QWidget *parent,
58  ViewManager *viewManager,
59  Options options = 0);
60 
61  Pane *addPane(); // I own the returned value
62  void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers
63 
64  int getPaneCount() const; // Returns only count of visible panes
65  Pane *getPane(int n); // Of visible panes; I own the returned value
66  int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent
67 
68  void hidePane(Pane *pane); // Also removes pane from getPane/getPaneCount
69  void showPane(Pane *pane); // Returns pane to getPane/getPaneCount
70 
71  int getHiddenPaneCount() const;
72  Pane *getHiddenPane(int n); // I own the returned value
73 
74  void setCurrentPane(Pane *pane);
75  void setCurrentLayer(Pane *pane, Layer *layer);
77 
79  enum LayoutStyle {
83  };
84 
86  void setLayoutStyle(LayoutStyle style);
87 
88  void setPropertyStackMinWidth(int mw);
89 
90  void sizePanesEqually();
91 
92 signals:
93  void currentPaneChanged(Pane *pane);
94  void currentLayerChanged(Pane *pane, Layer *layer);
95  void paneRightButtonMenuRequested(Pane *pane, QPoint position);
98  void propertyStacksResized(int width);
99  void propertyStacksResized();
100  void contextHelpChanged(const QString &);
101 
102  void paneAdded(Pane *pane);
103  void paneAdded();
104  void paneHidden(Pane *pane);
105  void paneHidden();
106  void paneAboutToBeDeleted(Pane *pane);
107  void paneDeleted();
108 
109  void dropAccepted(Pane *pane, QStringList uriList);
110  void dropAccepted(Pane *pane, QString text);
111 
112  void paneDeleteButtonClicked(Pane *pane);
113 
114  void doubleClickSelectInvoked(sv_frame_t frame);
115 
116 public slots:
117  void propertyContainerAdded(PropertyContainer *);
118  void propertyContainerRemoved(PropertyContainer *);
119  void propertyContainerSelected(View *client, PropertyContainer *);
120  void propertyContainerContextMenuRequested(View *, PropertyContainer *,
121  QPoint);
122  void viewSelected(View *v);
123  void paneInteractedWith();
124  void rightButtonMenuRequested(QPoint);
125  void paneDropAccepted(QStringList);
126  void paneDropAccepted(QString);
128  void indicatorClicked();
129 
130 protected:
132 
133  struct PaneRec
134  {
136  QWidget *propertyStack;
137  QPushButton *xButton;
139  QFrame *frame;
140  QGridLayout *layout;
142  };
143 
144  std::vector<PaneRec> m_panes;
145  std::vector<PaneRec> m_hiddenPanes;
146 
148  QSplitter *m_splitter; // constitutes the stack in default mode
149  QWidget *m_autoResizeStack; // constitutes the stack in NoUserResize mode
150  QVBoxLayout *m_autoResizeLayout;
151 
152  QStackedWidget *m_propertyStackStack;
153 
154  ViewManager *m_viewManager; // I don't own this
156  void sizePropertyStacks();
157 
159 
160  void unlinkAlignmentViews();
161  void relinkAlignmentViews();
162 
163  void resizeEvent(QResizeEvent *) override;
164  void adjustAlignmentViewHeights(int forMyHeight);
165 
167 };
168 
169 #endif
170 
Pane * getHiddenPane(int n)
Definition: PaneStack.cpp:356
Pane * getPane(int n)
Definition: PaneStack.cpp:335
LayoutStyle
Runtime-switchable layout style for property stacks.
Definition: PaneStack.h:79
LayoutStyle getLayoutStyle() const
Definition: PaneStack.h:85
PaneStack(QWidget *parent, ViewManager *viewManager, Options options=0)
Definition: PaneStack.cpp:41
Definition: Pane.h:35
The base class for visual representations of the data found in a Model.
Definition: Layer.h:54
void adjustAlignmentViewHeights(int forMyHeight)
Definition: PaneStack.cpp:253
void hidePane(Pane *pane)
Definition: PaneStack.cpp:467
void propertyStacksResized()
void doubleClickSelectInvoked(sv_frame_t frame)
int m_propertyStackMinWidth
Definition: PaneStack.h:155
void dropAccepted(Pane *pane, QStringList uriList)
AlignmentView * alignmentView
Definition: PaneStack.h:141
void paneHidden()
ViewManager * m_viewManager
Definition: PaneStack.h:154
void sizePanesEqually()
Definition: PaneStack.cpp:753
void paneDeleteButtonClicked()
Definition: PaneStack.cpp:729
void paneRightButtonMenuRequested(Pane *pane, QPoint position)
void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint)
std::vector< PaneRec > m_panes
Definition: PaneStack.h:144
QLabel * currentIndicator
Definition: PaneStack.h:138
int getPaneCount() const
Definition: PaneStack.cpp:455
void paneAdded()
QPushButton * xButton
Definition: PaneStack.h:137
void paneAboutToBeDeleted(Pane *pane)
void rightButtonMenuRequested(QPoint)
Definition: PaneStack.cpp:669
void propertyContainerAdded(PropertyContainer *)
Definition: PaneStack.cpp:604
void resizeEvent(QResizeEvent *) override
Definition: PaneStack.cpp:247
Option
These options are for things that must be set on construction, and can&#39;t be changed afterwards...
Definition: PaneStack.h:47
QSplitter * m_splitter
Definition: PaneStack.h:148
LayoutStyle m_layoutStyle
Definition: PaneStack.h:166
void propertyContainerRemoved(PropertyContainer *)
Definition: PaneStack.cpp:610
Pane * addPane()
Definition: PaneStack.cpp:88
QWidget * propertyStack
Definition: PaneStack.h:136
int getPaneIndex(Pane *pane)
Definition: PaneStack.cpp:345
Pane * getCurrentPane()
Definition: PaneStack.cpp:598
void indicatorClicked()
Definition: PaneStack.cpp:740
QWidget * m_autoResizeStack
Definition: PaneStack.h:149
void relinkAlignmentViews()
Definition: PaneStack.cpp:213
void showOrHidePaneAccessories()
Definition: PaneStack.cpp:433
void propertyContainerContextMenuRequested(View *, PropertyContainer *, QPoint)
Definition: PaneStack.cpp:637
void propertyContainerSelected(View *client, PropertyContainer *)
Definition: PaneStack.cpp:616
void deletePane(Pane *pane)
Definition: PaneStack.cpp:362
QVBoxLayout * m_autoResizeLayout
Definition: PaneStack.h:150
void setLayoutStyle(LayoutStyle style)
Definition: PaneStack.cpp:296
int getHiddenPaneCount() const
Definition: PaneStack.cpp:461
void contextHelpChanged(const QString &)
void paneDeleted()
void panePropertiesRightButtonMenuRequested(Pane *, QPoint)
void setCurrentLayer(Pane *pane, Layer *layer)
Definition: PaneStack.cpp:566
int m_options
Definition: PaneStack.h:147
void setPropertyStackMinWidth(int mw)
Definition: PaneStack.cpp:286
void currentPaneChanged(Pane *pane)
QGridLayout * layout
Definition: PaneStack.h:140
int Options
Definition: PaneStack.h:55
QStackedWidget * m_propertyStackStack
Definition: PaneStack.h:152
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:55
void unlinkAlignmentViews()
Definition: PaneStack.cpp:235
Pane * m_currentPane
Definition: PaneStack.h:131
void setCurrentPane(Pane *pane)
Definition: PaneStack.cpp:526
The ViewManager manages properties that may need to be synchronised between separate Views...
Definition: ViewManager.h:78
void showPane(Pane *pane)
Definition: PaneStack.cpp:501
void viewSelected(View *v)
Definition: PaneStack.cpp:654
void sizePropertyStacks()
Definition: PaneStack.cpp:677
void paneInteractedWith()
Definition: PaneStack.cpp:661
std::vector< PaneRec > m_hiddenPanes
Definition: PaneStack.h:145
void paneDropAccepted(QStringList)
Definition: PaneStack.cpp:715
void currentLayerChanged(Pane *pane, Layer *layer)