Mercurial > hg > svgui
comparison view/PaneStack.cpp @ 867:99373ca20caf alignment_view
First sketch at alignment view (between panes in stack)
author | Chris Cannam |
---|---|
date | Fri, 17 Oct 2014 14:58:51 +0100 |
parents | 57efeb75880d |
children | 36cddc3de023 |
comparison
equal
deleted
inserted
replaced
866:d854c72dcaa1 | 867:99373ca20caf |
---|---|
19 #include "widgets/PropertyStack.h" | 19 #include "widgets/PropertyStack.h" |
20 #include "widgets/IconLoader.h" | 20 #include "widgets/IconLoader.h" |
21 #include "widgets/ClickableLabel.h" | 21 #include "widgets/ClickableLabel.h" |
22 #include "layer/Layer.h" | 22 #include "layer/Layer.h" |
23 #include "ViewManager.h" | 23 #include "ViewManager.h" |
24 #include "AlignmentView.h" | |
24 | 25 |
25 #include <QApplication> | 26 #include <QApplication> |
26 #include <QHBoxLayout> | 27 #include <QHBoxLayout> |
27 #include <QVBoxLayout> | 28 #include <QVBoxLayout> |
28 #include <QPainter> | 29 #include <QPainter> |
38 | 39 |
39 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : | 40 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : |
40 QFrame(parent), | 41 QFrame(parent), |
41 m_currentPane(0), | 42 m_currentPane(0), |
42 m_showAccessories(true), | 43 m_showAccessories(true), |
44 m_showAlignmentViews(false), | |
43 m_splitter(new QSplitter), | 45 m_splitter(new QSplitter), |
44 m_propertyStackStack(new QStackedWidget), | 46 m_propertyStackStack(new QStackedWidget), |
45 m_viewManager(viewManager), | 47 m_viewManager(viewManager), |
46 m_propertyStackMinWidth(100), | 48 m_propertyStackMinWidth(100), |
47 m_layoutStyle(PropertyStackPerPaneLayout) | 49 m_layoutStyle(PropertyStackPerPaneLayout) |
63 | 65 |
64 void | 66 void |
65 PaneStack::setShowPaneAccessories(bool show) | 67 PaneStack::setShowPaneAccessories(bool show) |
66 { | 68 { |
67 m_showAccessories = show; | 69 m_showAccessories = show; |
70 } | |
71 | |
72 void | |
73 PaneStack::setShowAlignmentViews(bool show) | |
74 { | |
75 m_showAlignmentViews = show; | |
76 foreach (const PaneRec &r, m_panes) { | |
77 r.alignmentView->setVisible(m_showAlignmentViews); | |
78 } | |
68 } | 79 } |
69 | 80 |
70 Pane * | 81 Pane * |
71 PaneStack::addPane(bool suppressPropertyBox) | 82 PaneStack::addPane(bool suppressPropertyBox) |
72 { | 83 { |
109 } else { | 120 } else { |
110 pane->setViewManager(m_viewManager); | 121 pane->setViewManager(m_viewManager); |
111 } | 122 } |
112 layout->addWidget(pane, 0, 1, 2, 1); | 123 layout->addWidget(pane, 0, 1, 2, 1); |
113 layout->setColumnStretch(1, 20); | 124 layout->setColumnStretch(1, 20); |
125 | |
126 AlignmentView *av = new AlignmentView(frame); | |
127 av->setFixedHeight(40);//!!! | |
128 av->setVisible(m_showAlignmentViews); | |
129 av->setViewManager(m_viewManager); | |
130 layout->addWidget(av, 2, 1); | |
114 | 131 |
115 QWidget *properties = 0; | 132 QWidget *properties = 0; |
116 if (suppressPropertyBox) { | 133 if (suppressPropertyBox) { |
117 properties = new QFrame(); | 134 properties = new QFrame(); |
118 } else { | 135 } else { |
137 rec.propertyStack = properties; | 154 rec.propertyStack = properties; |
138 rec.xButton = xButton; | 155 rec.xButton = xButton; |
139 rec.currentIndicator = currentIndicator; | 156 rec.currentIndicator = currentIndicator; |
140 rec.frame = frame; | 157 rec.frame = frame; |
141 rec.layout = layout; | 158 rec.layout = layout; |
159 rec.alignmentView = av; | |
142 m_panes.push_back(rec); | 160 m_panes.push_back(rec); |
143 | 161 |
144 frame->setLayout(layout); | 162 frame->setLayout(layout); |
145 m_splitter->insertWidget(index, frame); | 163 m_splitter->insertWidget(index, frame); |
146 | 164 |
165 if (!m_currentPane) { | 183 if (!m_currentPane) { |
166 setCurrentPane(pane); | 184 setCurrentPane(pane); |
167 } | 185 } |
168 | 186 |
169 showOrHidePaneAccessories(); | 187 showOrHidePaneAccessories(); |
188 relinkAlignmentViews(); | |
170 | 189 |
171 return pane; | 190 return pane; |
191 } | |
192 | |
193 void | |
194 PaneStack::relinkAlignmentViews() | |
195 { | |
196 for (int i = 0; i < (int)m_panes.size(); ++i) { | |
197 m_panes[i].alignmentView->setViewAbove(m_panes[i].pane); | |
198 if (i + 1 < (int)m_panes.size()) { | |
199 m_panes[i].alignmentView->setViewBelow(m_panes[i+1].pane); | |
200 } else { | |
201 m_panes[i].alignmentView->setViewBelow(0); | |
202 } | |
203 } | |
204 } | |
205 | |
206 void | |
207 PaneStack::unlinkAlignmentViews() | |
208 { | |
209 for (int i = 0; i < (int)m_panes.size(); ++i) { | |
210 m_panes[i].alignmentView->setViewAbove(0); | |
211 m_panes[i].alignmentView->setViewBelow(0); | |
212 } | |
172 } | 213 } |
173 | 214 |
174 void | 215 void |
175 PaneStack::setPropertyStackMinWidth(int mw) | 216 PaneStack::setPropertyStackMinWidth(int mw) |
176 { | 217 { |
277 return; | 318 return; |
278 } | 319 } |
279 } | 320 } |
280 | 321 |
281 emit paneAboutToBeDeleted(pane); | 322 emit paneAboutToBeDeleted(pane); |
323 unlinkAlignmentViews(); | |
282 | 324 |
283 cerr << "PaneStack::deletePane: about to delete parent " << pane->parent() << " of pane " << pane << endl; | 325 cerr << "PaneStack::deletePane: about to delete parent " << pane->parent() << " of pane " << pane << endl; |
284 | 326 |
285 // The property stack associated with the parent was initially | 327 // The property stack associated with the parent was initially |
286 // created with the same parent as it, so it would be deleted when | 328 // created with the same parent as it, so it would be deleted when |
301 setCurrentPane(0); | 343 setCurrentPane(0); |
302 } | 344 } |
303 } | 345 } |
304 | 346 |
305 showOrHidePaneAccessories(); | 347 showOrHidePaneAccessories(); |
348 relinkAlignmentViews(); | |
306 | 349 |
307 emit paneDeleted(); | 350 emit paneDeleted(); |
308 } | 351 } |
309 | 352 |
310 void | 353 void |
360 return; | 403 return; |
361 } | 404 } |
362 ++i; | 405 ++i; |
363 } | 406 } |
364 | 407 |
408 relinkAlignmentViews(); | |
409 | |
365 cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << endl; | 410 cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << endl; |
366 } | 411 } |
367 | 412 |
368 void | 413 void |
369 PaneStack::showPane(Pane *pane) | 414 PaneStack::showPane(Pane *pane) |
383 | 428 |
384 return; | 429 return; |
385 } | 430 } |
386 ++i; | 431 ++i; |
387 } | 432 } |
433 | |
434 relinkAlignmentViews(); | |
388 | 435 |
389 cerr << "WARNING: PaneStack::showPane(" << pane << "): Pane not found in hidden panes" << endl; | 436 cerr << "WARNING: PaneStack::showPane(" << pane << "): Pane not found in hidden panes" << endl; |
390 } | 437 } |
391 | 438 |
392 void | 439 void |