26 #include <QApplication> 27 #include <QHBoxLayout> 28 #include <QVBoxLayout> 32 #include <QPushButton> 34 #include <QStackedWidget> 35 #include <QResizeEvent> 45 m_currentPane(nullptr),
48 m_autoResizeStack(nullptr),
49 m_propertyStackStack(new QStackedWidget),
50 m_viewManager(viewManager),
51 m_propertyStackMinWidth(100),
52 m_layoutStyle(PropertyStackPerPaneLayout)
54 QHBoxLayout *layout =
new QHBoxLayout;
56 layout->setSpacing(0);
90 QFrame *frame =
new QFrame;
92 QGridLayout *layout =
new QGridLayout;
99 layout->setVerticalSpacing(0);
103 av->setVisible(
false);
104 layout->addWidget(av, 0, 1);
109 QPushButton *xButton =
new QPushButton(frame);
111 xButton->setFixedSize(QSize(16, 16));
112 xButton->setFlat(
true);
115 xButton->setVisible(
false);
117 layout->addWidget(xButton, 1, 0);
121 connect(currentIndicator, SIGNAL(clicked()),
this, SLOT(
indicatorClicked()));
122 layout->addWidget(currentIndicator, 2, 0);
123 layout->setRowStretch(2, 20);
124 currentIndicator->setMinimumWidth(16);
125 currentIndicator->setMinimumHeight(16);
126 currentIndicator->setScaledContents(
true);
129 sv_frame_t initialCentreFrame = -1;
131 initialCentreFrame =
m_panes[0].pane->getCentreFrame();
135 if (initialCentreFrame >= 0) {
140 layout->addWidget(pane, 1, 1, 2, 1);
141 layout->setColumnStretch(1, 20);
143 QWidget *properties =
nullptr;
145 properties =
new QFrame();
158 layout->addWidget(properties, 1, 2, 2, 1);
163 layout->setColumnStretch(2, 0);
175 frame->setLayout(layout);
216 auto av =
m_panes[0].alignmentView;
218 for (
int i = 1; in_range_for(
m_panes, i); ++i) {
224 av->setAboveView(
m_panes[i-1].pane);
225 av->setBelowView(
m_panes[i].pane);
226 av->setReferenceView(
m_panes[0].pane);
237 for (
int i = 0; in_range_for(
m_panes, i); ++i) {
238 auto av =
m_panes[i].alignmentView;
240 av->setAboveView(
nullptr);
241 av->setBelowView(
nullptr);
242 av->setReferenceView(
nullptr);
257 if (!isVisible())
return;
260 int heightPerPane = forMyHeight / int(
m_panes.size());
262 SVCERR <<
"heightPerPane = " << heightPerPane <<
" (" 263 << forMyHeight <<
"/" <<
m_panes.size() <<
")" << endl;
265 int roomForAlignmentView = heightPerPane / 4;
268 int alignmentHeight = roomForAlignmentView;
269 if (alignmentHeight < min) {
270 alignmentHeight = min;
272 if (alignmentHeight > max) {
273 alignmentHeight = max;
276 SVCERR <<
"alignmentHeight = " << alignmentHeight << endl;
278 for (
int i = 0; in_range_for(
m_panes, i); ++i) {
279 auto av =
m_panes[i].alignmentView;
281 av->setFixedHeight(alignmentHeight);
288 for (std::vector<PaneRec>::iterator i =
m_panes.begin();
290 i->propertyStack->setMinimumWidth(mw);
299 SVCERR <<
"NOTE: PaneStack::setLayoutStyle called on PaneStack with NoPropertyStacks option set - this does nothing, its style is always equivalent to HiddenPropertyStacksLayout" << endl;
306 std::vector<PaneRec>::iterator i;
314 i->layout->removeWidget(i->propertyStack);
325 i->propertyStack->setParent(i->frame);
326 i->layout->addWidget(i->propertyStack, 1, 2, 2, 1);
327 i->propertyStack->show();
364 #ifdef DEBUG_PANE_STACK 365 SVCERR <<
"PaneStack::deletePane(" << pane <<
")" << endl;
368 std::vector<PaneRec>::iterator i;
371 QWidget *stack =
nullptr;
374 if (i->pane == pane) {
375 stack = i->propertyStack;
385 if (i->pane == pane) {
386 stack = i->propertyStack;
394 cerr <<
"WARNING: PaneStack::deletePane(" << pane <<
"): Pane not found in visible or hidden panes, not deleting" << endl;
402 #ifdef DEBUG_PANE_STACK 403 SVCERR <<
"PaneStack::deletePane: about to delete parent " << pane->parent() <<
" of pane " << pane << endl;
416 delete pane->parent();
435 #ifdef DEBUG_PANE_STACK 436 SVCERR <<
"PaneStack::showOrHidePaneAccessories: count == " <<
getPaneCount() << endl;
440 for (std::vector<PaneRec>::iterator i =
m_panes.begin();
443 bool xvisible = visible;
449 i->xButton->setVisible(xvisible);
450 i->currentIndicator->setVisible(visible);
469 std::vector<PaneRec>::iterator i =
m_panes.begin();
472 if (i->pane == pane) {
477 QWidget *pw =
dynamic_cast<QWidget *
>(pane->parent());
497 SVCERR <<
"WARNING: PaneStack::hidePane(" << pane <<
"): Pane not found in visible panes" << endl;
506 if (i->pane == pane) {
509 QWidget *pw =
dynamic_cast<QWidget *
>(pane->parent());
522 SVCERR <<
"WARNING: PaneStack::showPane(" << pane <<
"): Pane not found in hidden panes" << endl;
530 std::vector<PaneRec>::iterator i =
m_panes.begin();
536 QPixmap selectedMap(1, 1);
537 selectedMap.fill(QApplication::palette().color(QPalette::Foreground));
539 QPixmap unselectedMap(1, 1);
540 unselectedMap.fill(QApplication::palette().color(QPalette::Background));
545 if (i->pane == pane) {
546 i->currentIndicator->setPixmap(selectedMap);
552 i->currentIndicator->setPixmap(unselectedMap);
557 if (found || pane ==
nullptr) {
561 SVCERR <<
"WARNING: PaneStack::setCurrentPane(" << pane <<
"): pane is not a visible pane in this stack" << endl;
572 std::vector<PaneRec>::iterator i =
m_panes.begin();
576 if (i->pane == pane) {
584 stack->setCurrentIndex
618 std::vector<PaneRec>::iterator i =
m_panes.begin();
638 PropertyContainer *pc,
641 Pane *pane =
dynamic_cast<Pane *
>(client);
663 Pane *pane =
dynamic_cast<Pane *
>(sender());
671 Pane *pane =
dynamic_cast<Pane *
>(sender());
683 for (
int i = 0; i < (int)
m_panes.size(); ++i) {
684 if (!
m_panes[i].propertyStack)
continue;
685 #ifdef DEBUG_PANE_STACK 686 SVDEBUG <<
"PaneStack::sizePropertyStacks: " << i <<
": min " 687 <<
m_panes[i].propertyStack->minimumSizeHint().width() <<
", hint " 688 <<
m_panes[i].propertyStack->sizeHint().width() <<
", current " 689 <<
m_panes[i].propertyStack->width() << endl;
692 if (
m_panes[i].propertyStack->sizeHint().width() > maxMinWidth) {
693 maxMinWidth =
m_panes[i].propertyStack->sizeHint().width();
697 #ifdef DEBUG_PANE_STACK 698 SVDEBUG <<
"PaneStack::sizePropertyStacks: max min width " << maxMinWidth << endl;
701 int setWidth = maxMinWidth;
705 for (
int i = 0; i < (int)
m_panes.size(); ++i) {
706 if (!
m_panes[i].propertyStack)
continue;
707 m_panes[i].propertyStack->setMinimumWidth(setWidth);
717 Pane *pane =
dynamic_cast<Pane *
>(sender());
724 Pane *pane =
dynamic_cast<Pane *
>(sender());
731 QObject *s = sender();
732 for (
int i = 0; i < (int)
m_panes.size(); ++i) {
742 QObject *s = sender();
744 for (
int i = 0; i < (int)
m_panes.size(); ++i) {
745 if (
m_panes[i].currentIndicator == s) {
760 if (sizes.empty())
return;
762 int count = sizes.size();
764 int fixed = 0, variable = 0, total = 0;
767 for (
int i = 0; i < count; ++i) {
773 for (
int i = 0; i < count; ++i) {
774 int minh =
m_panes[i].pane->minimumSize().height();
775 if (minh ==
m_panes[i].pane->maximumSize().height()) {
783 if (total == 0)
return;
787 int each = (varicount > 0 ? (variable / varicount) : 0);
788 int remaining = total;
790 for (
int i = 0; i < count; ++i) {
791 if (i == count - 1) {
792 sizes.push_back(remaining);
794 int minh =
m_panes[i].pane->minimumSize().height();
795 if (minh ==
m_panes[i].pane->maximumSize().height()) {
796 sizes.push_back(minh);
799 sizes.push_back(each);
Pane * getHiddenPane(int n)
LayoutStyle
Runtime-switchable layout style for property stacks.
PaneStack(QWidget *parent, ViewManager *viewManager, Options options=0)
virtual const PropertyContainer * getPropertyContainer(int i) const
The base class for visual representations of the data found in a Model.
void adjustAlignmentViewHeights(int forMyHeight)
void hidePane(Pane *pane)
void propertyStacksResized()
void doubleClickSelectInvoked(sv_frame_t frame)
int m_propertyStackMinWidth
void dropAccepted(Pane *pane, QStringList uriList)
AlignmentView * alignmentView
ViewManager * m_viewManager
static int scalePixelSize(int pixels)
Take a "design pixel" size and scale it for the actual display.
int getContainerIndex(PropertyContainer *container) const
void paneDeleteButtonClicked()
void paneRightButtonMenuRequested(Pane *pane, QPoint position)
void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint)
std::vector< PaneRec > m_panes
QLabel * currentIndicator
void paneAboutToBeDeleted(Pane *pane)
void rightButtonMenuRequested(QPoint)
void propertyContainerAdded(PropertyContainer *)
void resizeEvent(QResizeEvent *) override
virtual void setViewManager(ViewManager *m)
LayoutStyle m_layoutStyle
bool containsContainer(PropertyContainer *container) const
void propertyContainerRemoved(PropertyContainer *)
int getPaneIndex(Pane *pane)
QWidget * m_autoResizeStack
void relinkAlignmentViews()
void showOrHidePaneAccessories()
void propertyContainerContextMenuRequested(View *, PropertyContainer *, QPoint)
void propertyContainerSelected(View *client, PropertyContainer *)
void deletePane(Pane *pane)
QVBoxLayout * m_autoResizeLayout
void setLayoutStyle(LayoutStyle style)
int getHiddenPaneCount() const
void contextHelpChanged(const QString &)
void panePropertiesRightButtonMenuRequested(Pane *, QPoint)
void setCurrentLayer(Pane *pane, Layer *layer)
void setPropertyStackMinWidth(int mw)
void currentPaneChanged(Pane *pane)
QStackedWidget * m_propertyStackStack
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
void unlinkAlignmentViews()
void setCurrentPane(Pane *pane)
The ViewManager manages properties that may need to be synchronised between separate Views...
void showPane(Pane *pane)
void viewSelected(View *v)
void sizePropertyStacks()
void paneInteractedWith()
std::vector< PaneRec > m_hiddenPanes
void paneDropAccepted(QStringList)
void currentLayerChanged(Pane *pane, Layer *layer)