diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 3e02c9f8..f5e0a0b8 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -677,7 +677,7 @@ - + 0 @@ -3036,6 +3036,11 @@ QComboBox
noscrollcombobox.h
+ + AdjustingStackedWidget + QStackedWidget +
adjustingstackedwidget.h
+
GraphicsView QGraphicsView diff --git a/include/ui/adjustingstackedwidget.h b/include/ui/adjustingstackedwidget.h new file mode 100644 index 00000000..8de23d11 --- /dev/null +++ b/include/ui/adjustingstackedwidget.h @@ -0,0 +1,25 @@ +#ifndef ADJUSTINGSTACKEDWIDGET_H +#define ADJUSTINGSTACKEDWIDGET_H + +#include + + + +class AdjustingStackedWidget : public QStackedWidget +{ + Q_OBJECT + +public: + AdjustingStackedWidget(QWidget *parent = nullptr) : QStackedWidget(parent) {} + + // override this to allow the stacked widget's current page to dictate size + virtual void setCurrentIndex(int index) { + QStackedWidget::setCurrentIndex(index); + for (int i = 0; i < this->count(); ++i) { + this->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + } + this->widget(index)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + } +}; + +#endif // ADJUSTINGSTACKEDWIDGET_H diff --git a/porymap.pro b/porymap.pro index ad12b9f0..b53d94ae 100644 --- a/porymap.pro +++ b/porymap.pro @@ -119,6 +119,7 @@ HEADERS += include/core/block.h \ include/ui/noscrollcombobox.h \ include/ui/noscrollspinbox.h \ include/ui/montabwidget.h \ + include/ui/adjustingstackedwidget.h \ include/ui/paletteeditor.h \ include/ui/selectablepixmapitem.h \ include/ui/tileseteditor.h \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2a8cbd77..0adc83ab 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,6 +8,7 @@ #include "ui_eventpropertiesframe.h" #include "bordermetatilespixmapitem.h" #include "currentselectedmetatilespixmapitem.h" +#include "adjustingstackedwidget.h" #include #include