Mercurial > hg > svgui
comparison view/PaneStack.h @ 1526:0f1601d870db
Rework PaneStack so that the options that generally aren't (or can't be) changed after construction are supplied to the constructor instead of being set through setter methods.
This is a more sensible way of doing things in general, but also a workaround for https://code.soundsoftware.ac.uk/issues/1930, a problem that arises when reinitialising hidden property boxes in a context in which they will never be visible at all.
author | Chris Cannam |
---|---|
date | Fri, 04 Oct 2019 13:51:24 +0100 |
parents | 69b7fdd6394f |
children | 01a41a37bd26 |
comparison
equal
deleted
inserted
replaced
1525:284a38c43721 | 1526:0f1601d870db |
---|---|
40 class PaneStack : public QFrame | 40 class PaneStack : public QFrame |
41 { | 41 { |
42 Q_OBJECT | 42 Q_OBJECT |
43 | 43 |
44 public: | 44 public: |
45 /// These options are for things that must be set on construction, | |
46 /// and can't be changed afterwards | |
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 | |
45 PaneStack(QWidget *parent, | 57 PaneStack(QWidget *parent, |
46 ViewManager *viewManager); | 58 ViewManager *viewManager, |
59 Options options = 0); | |
47 | 60 |
48 Pane *addPane(bool suppressPropertyBox = false); // I own the returned value | 61 Pane *addPane(); // I own the returned value |
49 void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers | 62 void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers |
50 | 63 |
51 int getPaneCount() const; // Returns only count of visible panes | 64 int getPaneCount() const; // Returns only count of visible panes |
52 Pane *getPane(int n); // Of visible panes; I own the returned value | 65 Pane *getPane(int n); // Of visible panes; I own the returned value |
53 int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent | 66 int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent |
60 | 73 |
61 void setCurrentPane(Pane *pane); | 74 void setCurrentPane(Pane *pane); |
62 void setCurrentLayer(Pane *pane, Layer *layer); | 75 void setCurrentLayer(Pane *pane, Layer *layer); |
63 Pane *getCurrentPane(); | 76 Pane *getCurrentPane(); |
64 | 77 |
78 /// Runtime-switchable layout style for property stacks | |
65 enum LayoutStyle { | 79 enum LayoutStyle { |
66 NoPropertyStacks = 0, | 80 HiddenPropertyStacksLayout = 0, |
67 SinglePropertyStackLayout = 1, | 81 SinglePropertyStackLayout = 1, |
68 PropertyStackPerPaneLayout = 2 | 82 PropertyStackPerPaneLayout = 2 |
69 }; | 83 }; |
70 | 84 |
71 LayoutStyle getLayoutStyle() const { return m_layoutStyle; } | 85 LayoutStyle getLayoutStyle() const { return m_layoutStyle; } |
72 void setLayoutStyle(LayoutStyle style); | 86 void setLayoutStyle(LayoutStyle style); |
73 | 87 |
74 enum ResizeMode { | |
75 UserResizeable = 0, | |
76 AutoResizeOnly = 1 | |
77 }; | |
78 | |
79 ResizeMode getResizeMode() const { return m_resizeMode; } | |
80 void setResizeMode(ResizeMode); | |
81 | |
82 // Set whether the current-pane indicators and close buttons are | |
83 // shown. The default is true. | |
84 void setShowPaneAccessories(bool show); | |
85 | |
86 // Set whether a close button is shown on the first pane as well | |
87 // as others. (It may be reasonable to omit the close button from | |
88 // what is presumably the main pane in some applications.) The | |
89 // default is true. | |
90 void setShowCloseButtonOnFirstPane(bool); | |
91 | |
92 void setPropertyStackMinWidth(int mw); | 88 void setPropertyStackMinWidth(int mw); |
93 | |
94 void setShowAlignmentViews(bool show); | |
95 | 89 |
96 void sizePanesEqually(); | 90 void sizePanesEqually(); |
97 | 91 |
98 signals: | 92 signals: |
99 void currentPaneChanged(Pane *pane); | 93 void currentPaneChanged(Pane *pane); |
144 }; | 138 }; |
145 | 139 |
146 std::vector<PaneRec> m_panes; | 140 std::vector<PaneRec> m_panes; |
147 std::vector<PaneRec> m_hiddenPanes; | 141 std::vector<PaneRec> m_hiddenPanes; |
148 | 142 |
149 bool m_showAccessories; | 143 int m_options; |
150 bool m_showCloseButtonOnFirstPane; | 144 QSplitter *m_splitter; // constitutes the stack in default mode |
151 bool m_showAlignmentViews; | 145 QWidget *m_autoResizeStack; // constitutes the stack in NoUserResize mode |
152 | |
153 QSplitter *m_splitter; // constitutes the stack in UserResizeable mode | |
154 QWidget *m_autoResizeStack; // constitutes the stack in AutoResizeOnly mode | |
155 QVBoxLayout *m_autoResizeLayout; | 146 QVBoxLayout *m_autoResizeLayout; |
156 | 147 |
157 QStackedWidget *m_propertyStackStack; | 148 QStackedWidget *m_propertyStackStack; |
158 | 149 |
159 ViewManager *m_viewManager; // I don't own this | 150 ViewManager *m_viewManager; // I don't own this |
164 | 155 |
165 void unlinkAlignmentViews(); | 156 void unlinkAlignmentViews(); |
166 void relinkAlignmentViews(); | 157 void relinkAlignmentViews(); |
167 | 158 |
168 LayoutStyle m_layoutStyle; | 159 LayoutStyle m_layoutStyle; |
169 ResizeMode m_resizeMode; | |
170 }; | 160 }; |
171 | 161 |
172 #endif | 162 #endif |
173 | 163 |