Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/widgets/PaneStack.cpp Mon Jun 19 16:14:16 2006 +0000 +++ b/widgets/PaneStack.cpp Mon Jun 26 16:08:57 2006 +0000 @@ -26,16 +26,32 @@ #include <QPainter> #include <QPalette> #include <QLabel> +#include <QSplitter> +#include <QStackedWidget> #include <iostream> PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : - QSplitter(parent), + QFrame(parent), m_currentPane(0), - m_viewManager(viewManager) + m_splitter(new QSplitter), + m_propertyStackStack(new QStackedWidget), + m_viewManager(viewManager), + m_layoutStyle(PropertyStackPerPaneLayout) { - setOrientation(Qt::Vertical); - setOpaqueResize(false); + QHBoxLayout *layout = new QHBoxLayout; + layout->setMargin(0); + layout->setSpacing(0); + + m_splitter->setOrientation(Qt::Vertical); + m_splitter->setOpaqueResize(false); + + layout->addWidget(m_splitter); + layout->setStretchFactor(m_splitter, 1); + layout->addWidget(m_propertyStackStack); + m_propertyStackStack->hide(); + + setLayout(layout); } Pane * @@ -65,17 +81,24 @@ connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); } - layout->addWidget(properties); + if (m_layoutStyle == PropertyStackPerPaneLayout) { + layout->addWidget(properties); + } else { + properties->setParent(m_propertyStackStack); + m_propertyStackStack->addWidget(properties); + } layout->setStretchFactor(properties, 1); PaneRec rec; rec.pane = pane; rec.propertyStack = properties; rec.currentIndicator = currentIndicator; + rec.frame = frame; + rec.layout = layout; m_panes.push_back(rec); frame->setLayout(layout); - addWidget(frame); + m_splitter->addWidget(frame); connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), this, SLOT(propertyContainerAdded(PropertyContainer *))); @@ -93,6 +116,39 @@ return pane; } +void +PaneStack::setLayoutStyle(LayoutStyle style) +{ + if (style == m_layoutStyle) return; + m_layoutStyle = style; + + std::vector<PaneRec>::iterator i; + + switch (style) { + + case SinglePropertyStackLayout: + + for (i = m_panes.begin(); i != m_panes.end(); ++i) { + i->layout->removeWidget(i->propertyStack); + i->propertyStack->setParent(m_propertyStackStack); + m_propertyStackStack->addWidget(i->propertyStack); + } + m_propertyStackStack->show(); + break; + + case PropertyStackPerPaneLayout: + + for (i = m_panes.begin(); i != m_panes.end(); ++i) { + m_propertyStackStack->removeWidget(i->propertyStack); + i->propertyStack->setParent(i->frame); + i->layout->addWidget(i->propertyStack); + i->propertyStack->show(); + } + m_propertyStackStack->hide(); + break; + } +} + Pane * PaneStack::getPane(int n) { @@ -139,7 +195,7 @@ if (m_currentPane == pane) { if (m_panes.size() > 0) { - setCurrentPane(m_panes[0].pane); + setCurrentPane(m_panes[0].pane); } else { setCurrentPane(0); } @@ -232,6 +288,9 @@ while (i != m_panes.end()) { if (i->pane == pane) { i->currentIndicator->setPixmap(selectedMap); + if (m_layoutStyle == SinglePropertyStackLayout) { + m_propertyStackStack->setCurrentWidget(i->propertyStack); + } found = true; } else { i->currentIndicator->setPixmap(unselectedMap); @@ -360,6 +419,8 @@ int setWidth = maxMinWidth; #endif + m_propertyStackStack->setMaximumWidth(setWidth + 10); + for (size_t i = 0; i < m_panes.size(); ++i) { if (!m_panes[i].propertyStack) continue; m_panes[i].propertyStack->setMinimumWidth(setWidth);