# HG changeset patch # User Chris Cannam # Date 1151338137 0 # Node ID 4772fc75ac7c65befad4fdf17040fc3e9686064f # Parent bf196d6e8998116a2d8a3a2eb204eabaac17fd6b * Some work on switching property box layout between one-box-per-pane and one-box-overall layouts. Not enabled in GUI yet. diff -r bf196d6e8998 -r 4772fc75ac7c widgets/PaneStack.cpp --- 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 #include #include +#include +#include #include 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::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); diff -r bf196d6e8998 -r 4772fc75ac7c widgets/PaneStack.h --- a/widgets/PaneStack.h Mon Jun 19 16:14:16 2006 +0000 +++ b/widgets/PaneStack.h Mon Jun 26 16:08:57 2006 +0000 @@ -17,10 +17,13 @@ #ifndef _PANESTACK_H_ #define _PANESTACK_H_ -#include +#include class QWidget; class QLabel; +class QStackedWidget; +class QSplitter; +class QHBoxLayout; class View; class Pane; class Layer; @@ -28,7 +31,7 @@ class PropertyContainer; class PropertyStack; -class PaneStack : public QSplitter +class PaneStack : public QFrame { Q_OBJECT @@ -51,6 +54,14 @@ void setCurrentLayer(Pane *pane, Layer *layer); Pane *getCurrentPane(); + enum LayoutStyle { + SinglePropertyStackLayout = 1, + PropertyStackPerPaneLayout = 2 + }; + + LayoutStyle getLayoutStyle() const { return m_layoutStyle; } + void setLayoutStyle(LayoutStyle style); + signals: void currentPaneChanged(Pane *pane); void currentLayerChanged(Pane *pane, Layer *layer); @@ -68,16 +79,23 @@ struct PaneRec { - Pane *pane; - QWidget *propertyStack; - QLabel *currentIndicator; + Pane *pane; + QWidget *propertyStack; + QLabel *currentIndicator; + QFrame *frame; + QHBoxLayout *layout; }; std::vector m_panes; std::vector m_hiddenPanes; + QSplitter *m_splitter; + QStackedWidget *m_propertyStackStack; + ViewManager *m_viewManager; // I don't own this void sizePropertyStacks(); + + LayoutStyle m_layoutStyle; }; #endif diff -r bf196d6e8998 -r 4772fc75ac7c widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Mon Jun 19 16:14:16 2006 +0000 +++ b/widgets/PropertyBox.cpp Mon Jun 26 16:08:57 2006 +0000 @@ -284,7 +284,7 @@ connect(cb, SIGNAL(stateChanged(int)), this, SLOT(propertyControllerChanged(int))); if (inGroup) { - cb->setToolTip(name); + cb->setToolTip(propertyLabel); m_groupLayouts[groupName]->addWidget(cb); } else { m_layout->addWidget(cb, row, 1, 1, 2); @@ -324,7 +324,7 @@ if (inGroup) { dial->setFixedWidth(24); dial->setFixedHeight(24); - dial->setToolTip(name); + dial->setToolTip(propertyLabel); m_groupLayouts[groupName]->addWidget(dial); } else { dial->setFixedWidth(32); @@ -382,7 +382,7 @@ this, SLOT(propertyControllerChanged(int))); if (inGroup) { - cb->setToolTip(name); + cb->setToolTip(propertyLabel); m_groupLayouts[groupName]->addWidget(cb); } else { m_layout->addWidget(cb, row, 1, 1, 2);