Mercurial > hg > svgui
comparison widgets/PaneStack.cpp @ 108:4772fc75ac7c
* Some work on switching property box layout between one-box-per-pane
and one-box-overall layouts. Not enabled in GUI yet.
author | Chris Cannam |
---|---|
date | Mon, 26 Jun 2006 16:08:57 +0000 |
parents | 803830f186ef |
children |
comparison
equal
deleted
inserted
replaced
107:bf196d6e8998 | 108:4772fc75ac7c |
---|---|
24 #include <QApplication> | 24 #include <QApplication> |
25 #include <QHBoxLayout> | 25 #include <QHBoxLayout> |
26 #include <QPainter> | 26 #include <QPainter> |
27 #include <QPalette> | 27 #include <QPalette> |
28 #include <QLabel> | 28 #include <QLabel> |
29 #include <QSplitter> | |
30 #include <QStackedWidget> | |
29 | 31 |
30 #include <iostream> | 32 #include <iostream> |
31 | 33 |
32 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : | 34 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : |
33 QSplitter(parent), | 35 QFrame(parent), |
34 m_currentPane(0), | 36 m_currentPane(0), |
35 m_viewManager(viewManager) | 37 m_splitter(new QSplitter), |
36 { | 38 m_propertyStackStack(new QStackedWidget), |
37 setOrientation(Qt::Vertical); | 39 m_viewManager(viewManager), |
38 setOpaqueResize(false); | 40 m_layoutStyle(PropertyStackPerPaneLayout) |
41 { | |
42 QHBoxLayout *layout = new QHBoxLayout; | |
43 layout->setMargin(0); | |
44 layout->setSpacing(0); | |
45 | |
46 m_splitter->setOrientation(Qt::Vertical); | |
47 m_splitter->setOpaqueResize(false); | |
48 | |
49 layout->addWidget(m_splitter); | |
50 layout->setStretchFactor(m_splitter, 1); | |
51 layout->addWidget(m_propertyStackStack); | |
52 m_propertyStackStack->hide(); | |
53 | |
54 setLayout(layout); | |
39 } | 55 } |
40 | 56 |
41 Pane * | 57 Pane * |
42 PaneStack::addPane(bool suppressPropertyBox) | 58 PaneStack::addPane(bool suppressPropertyBox) |
43 { | 59 { |
63 } else { | 79 } else { |
64 properties = new PropertyStack(frame, pane); | 80 properties = new PropertyStack(frame, pane); |
65 connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), | 81 connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), |
66 this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); | 82 this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); |
67 } | 83 } |
68 layout->addWidget(properties); | 84 if (m_layoutStyle == PropertyStackPerPaneLayout) { |
85 layout->addWidget(properties); | |
86 } else { | |
87 properties->setParent(m_propertyStackStack); | |
88 m_propertyStackStack->addWidget(properties); | |
89 } | |
69 layout->setStretchFactor(properties, 1); | 90 layout->setStretchFactor(properties, 1); |
70 | 91 |
71 PaneRec rec; | 92 PaneRec rec; |
72 rec.pane = pane; | 93 rec.pane = pane; |
73 rec.propertyStack = properties; | 94 rec.propertyStack = properties; |
74 rec.currentIndicator = currentIndicator; | 95 rec.currentIndicator = currentIndicator; |
96 rec.frame = frame; | |
97 rec.layout = layout; | |
75 m_panes.push_back(rec); | 98 m_panes.push_back(rec); |
76 | 99 |
77 frame->setLayout(layout); | 100 frame->setLayout(layout); |
78 addWidget(frame); | 101 m_splitter->addWidget(frame); |
79 | 102 |
80 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), | 103 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), |
81 this, SLOT(propertyContainerAdded(PropertyContainer *))); | 104 this, SLOT(propertyContainerAdded(PropertyContainer *))); |
82 connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)), | 105 connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)), |
83 this, SLOT(propertyContainerRemoved(PropertyContainer *))); | 106 this, SLOT(propertyContainerRemoved(PropertyContainer *))); |
91 } | 114 } |
92 | 115 |
93 return pane; | 116 return pane; |
94 } | 117 } |
95 | 118 |
119 void | |
120 PaneStack::setLayoutStyle(LayoutStyle style) | |
121 { | |
122 if (style == m_layoutStyle) return; | |
123 m_layoutStyle = style; | |
124 | |
125 std::vector<PaneRec>::iterator i; | |
126 | |
127 switch (style) { | |
128 | |
129 case SinglePropertyStackLayout: | |
130 | |
131 for (i = m_panes.begin(); i != m_panes.end(); ++i) { | |
132 i->layout->removeWidget(i->propertyStack); | |
133 i->propertyStack->setParent(m_propertyStackStack); | |
134 m_propertyStackStack->addWidget(i->propertyStack); | |
135 } | |
136 m_propertyStackStack->show(); | |
137 break; | |
138 | |
139 case PropertyStackPerPaneLayout: | |
140 | |
141 for (i = m_panes.begin(); i != m_panes.end(); ++i) { | |
142 m_propertyStackStack->removeWidget(i->propertyStack); | |
143 i->propertyStack->setParent(i->frame); | |
144 i->layout->addWidget(i->propertyStack); | |
145 i->propertyStack->show(); | |
146 } | |
147 m_propertyStackStack->hide(); | |
148 break; | |
149 } | |
150 } | |
151 | |
96 Pane * | 152 Pane * |
97 PaneStack::getPane(int n) | 153 PaneStack::getPane(int n) |
98 { | 154 { |
99 return m_panes[n].pane; | 155 return m_panes[n].pane; |
100 } | 156 } |
137 | 193 |
138 delete pane->parent(); | 194 delete pane->parent(); |
139 | 195 |
140 if (m_currentPane == pane) { | 196 if (m_currentPane == pane) { |
141 if (m_panes.size() > 0) { | 197 if (m_panes.size() > 0) { |
142 setCurrentPane(m_panes[0].pane); | 198 setCurrentPane(m_panes[0].pane); |
143 } else { | 199 } else { |
144 setCurrentPane(0); | 200 setCurrentPane(0); |
145 } | 201 } |
146 } | 202 } |
147 } | 203 } |
230 bool found = false; | 286 bool found = false; |
231 | 287 |
232 while (i != m_panes.end()) { | 288 while (i != m_panes.end()) { |
233 if (i->pane == pane) { | 289 if (i->pane == pane) { |
234 i->currentIndicator->setPixmap(selectedMap); | 290 i->currentIndicator->setPixmap(selectedMap); |
291 if (m_layoutStyle == SinglePropertyStackLayout) { | |
292 m_propertyStackStack->setCurrentWidget(i->propertyStack); | |
293 } | |
235 found = true; | 294 found = true; |
236 } else { | 295 } else { |
237 i->currentIndicator->setPixmap(unselectedMap); | 296 i->currentIndicator->setPixmap(unselectedMap); |
238 } | 297 } |
239 ++i; | 298 ++i; |
358 int setWidth = maxMinWidth * 3 / 2; | 417 int setWidth = maxMinWidth * 3 / 2; |
359 #else | 418 #else |
360 int setWidth = maxMinWidth; | 419 int setWidth = maxMinWidth; |
361 #endif | 420 #endif |
362 | 421 |
422 m_propertyStackStack->setMaximumWidth(setWidth + 10); | |
423 | |
363 for (size_t i = 0; i < m_panes.size(); ++i) { | 424 for (size_t i = 0; i < m_panes.size(); ++i) { |
364 if (!m_panes[i].propertyStack) continue; | 425 if (!m_panes[i].propertyStack) continue; |
365 m_panes[i].propertyStack->setMinimumWidth(setWidth); | 426 m_panes[i].propertyStack->setMinimumWidth(setWidth); |
366 } | 427 } |
367 } | 428 } |