From 069d30d9eebb632f75be9b154d39fec52f66bdc9 Mon Sep 17 00:00:00 2001 From: Benjamin Trotter Date: Sun, 20 Aug 2017 11:06:58 -0700 Subject: [PATCH 1/2] Made wang pattern and color view into a tab widget --- src/tiled/wangdock.cpp | 38 ++++++++++++-------------------------- src/tiled/wangdock.h | 6 ++---- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/tiled/wangdock.cpp b/src/tiled/wangdock.cpp index 9c12764819..22af4c97be 100644 --- a/src/tiled/wangdock.cpp +++ b/src/tiled/wangdock.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -198,13 +198,6 @@ WangDock::WangDock(QWidget *parent) connect(mEraseWangIdsButton, &QPushButton::clicked, this, &WangDock::activateErase); - mSwitchTemplateViewButton = new QPushButton(this); - mSwitchTemplateViewButton->setIconSize(Utils::smallIconSize()); - mSwitchTemplateViewButton->setCheckable(false); - - connect(mSwitchTemplateViewButton, &QPushButton::clicked, - this, &WangDock::switchTemplateViewButtonClicked); - //WangSetView widget: QWidget *wangSetWidget = new QWidget; @@ -229,16 +222,16 @@ WangDock::WangDock(QWidget *parent) colorViewVertical->addWidget(mWangColorView); colorViewVertical->addLayout(colorViewHorizontal); - mTemplateAndColorView = new QStackedWidget(); - mTemplateAndColorView->addWidget(mWangTemplateView); - mTemplateAndColorView->addWidget(wangColorWidget); + mTemplateAndColorView = new QTabWidget; + mTemplateAndColorView->setDocumentMode(true); + mTemplateAndColorView->addTab(mWangTemplateView, tr("Patterns")); + mTemplateAndColorView->addTab(wangColorWidget, tr("Colors")); //Template and color widget. mTemplateAndColorWidget = new QWidget; QHBoxLayout *templateAndColorHorizontal = new QHBoxLayout; templateAndColorHorizontal->addWidget(mEraseWangIdsButton); - templateAndColorHorizontal->addWidget(mSwitchTemplateViewButton); QVBoxLayout *templateAndColorVertical = new QVBoxLayout(mTemplateAndColorWidget); templateAndColorVertical->setMargin(0); @@ -290,8 +283,9 @@ void WangDock::setDocument(Document *document) mWangSetToolBar->setVisible(false); mWangColorToolBar->setVisible(false); mEraseWangIdsButton->setVisible(false); - mSwitchTemplateViewButton->setVisible(false); + mTemplateAndColorView->setTabEnabled(0, false); + mTemplateAndColorView->tabBar()->hide(); } else if (auto tilesetDocument = qobject_cast(document)) { TilesetWangSetModel *wangSetModel = tilesetDocument->wangSetModel(); @@ -312,7 +306,9 @@ void WangDock::setDocument(Document *document) mWangSetToolBar->setVisible(true); mWangColorToolBar->setVisible(true); mEraseWangIdsButton->setVisible(true); - mSwitchTemplateViewButton->setVisible(true); + + mTemplateAndColorView->setTabEnabled(0, true); + mTemplateAndColorView->tabBar()->show(); setTemplateView(); /* @@ -357,14 +353,6 @@ void WangDock::changeEvent(QEvent *event) } } -void WangDock::switchTemplateViewButtonClicked() -{ - if (mTemplateAndColorView->currentIndex() == 0) - setColorView(); - else - setTemplateView(); -} - void WangDock::refreshCurrentWangSet() { QItemSelectionModel *selectionModel = mWangSetView->selectionModel(); @@ -560,10 +548,8 @@ void WangDock::retranslateUi() mAddCornerColor->setText(tr("Add Corner Color")); mRemoveColor->setText(tr("Remove Color")); - if (mWangColorView->isVisible()) - mSwitchTemplateViewButton->setText(tr("Switch to Template View")); - else - mSwitchTemplateViewButton->setText(tr("Switch to Color View")); + mTemplateAndColorView->setTabText(0, tr("Patterns")); + mTemplateAndColorView->setTabText(1, tr("Colors")); } QModelIndex WangDock::wangSetIndex(WangSet *wangSet) const diff --git a/src/tiled/wangdock.h b/src/tiled/wangdock.h index faada41435..18e320894d 100644 --- a/src/tiled/wangdock.h +++ b/src/tiled/wangdock.h @@ -29,7 +29,7 @@ class QModelIndex; class QPushButton; class QToolBar; class QTreeView; -class QStackedWidget; +class QTabWidget; namespace Tiled { namespace Internal { @@ -90,7 +90,6 @@ public slots: private slots: void activateErase(); - void switchTemplateViewButtonClicked(); void refreshCurrentWangSet(); void refreshCurrentWangId(); void refreshCurrentWangColor(); @@ -118,7 +117,6 @@ private slots: Document *mDocument; WangSetView *mWangSetView; QPushButton *mEraseWangIdsButton; - QPushButton *mSwitchTemplateViewButton; WangSet *mCurrentWangSet; WangId mCurrentWangId; TilesetDocumentsFilterModel *mTilesetDocumentFilterModel; @@ -128,7 +126,7 @@ private slots: HasChildrenFilterModel *mProxyModel; WangTemplateView *mWangTemplateView; WangTemplateModel *mWangTemplateModel; - QStackedWidget *mTemplateAndColorView; + QTabWidget *mTemplateAndColorView; QWidget *mTemplateAndColorWidget; bool mInitializing; From d942457453691d1f5d2fa686e0ee0afdbf5e8566 Mon Sep 17 00:00:00 2001 From: Benjamin Trotter Date: Sun, 20 Aug 2017 11:12:38 -0700 Subject: [PATCH 2/2] Removed unsed mIsInfinite from WangFiller --- src/tiled/bucketfilltool.cpp | 1 - src/tiled/stampbrush.cpp | 1 - src/tiled/wangfiller.cpp | 2 -- src/tiled/wangfiller.h | 4 +--- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/tiled/bucketfilltool.cpp b/src/tiled/bucketfilltool.cpp index 5512230b73..ef514e86d4 100644 --- a/src/tiled/bucketfilltool.cpp +++ b/src/tiled/bucketfilltool.cpp @@ -413,7 +413,6 @@ void BucketFillTool::wangFill(TileLayer &tileLayerToFill, return; WangFiller wangFiller(mWangSet, - mapDocument()->map()->infinite(), dynamic_cast(mapDocument()->renderer()), mapDocument()->map()->staggerAxis()); diff --git a/src/tiled/stampbrush.cpp b/src/tiled/stampbrush.cpp index 0c5fe81dcb..34e72fc853 100644 --- a/src/tiled/stampbrush.cpp +++ b/src/tiled/stampbrush.cpp @@ -437,7 +437,6 @@ void StampBrush::drawPreviewLayer(const QVector &list) bounds.width(), bounds.height())); WangFiller wangFiller(mWangSet, - mapDocument()->map()->infinite(), dynamic_cast(mapDocument()->renderer()), mapDocument()->map()->staggerAxis()); diff --git a/src/tiled/wangfiller.cpp b/src/tiled/wangfiller.cpp index dde5545931..ee71bf0fd8 100644 --- a/src/tiled/wangfiller.cpp +++ b/src/tiled/wangfiller.cpp @@ -40,11 +40,9 @@ static const QPoint aroundTilePoints[] = { }; WangFiller::WangFiller(WangSet *wangSet, - bool isInfinite, StaggeredRenderer *staggeredRenderer, Map::StaggerAxis staggerAxis) : mWangSet(wangSet) - , mIsInfinite(isInfinite) , mStaggeredRenderer(staggeredRenderer) , mStaggerAxis(staggerAxis) { diff --git a/src/tiled/wangfiller.h b/src/tiled/wangfiller.h index 5d17e80b01..e675f7f9dd 100644 --- a/src/tiled/wangfiller.h +++ b/src/tiled/wangfiller.h @@ -42,8 +42,7 @@ namespace Internal { class WangFiller { public: - explicit WangFiller(WangSet *wangSet, - bool isInfinite, //the map we are filling to is infinite. + explicit WangFiller(WangSet *wangSet, //the map we are filling to is infinite. StaggeredRenderer *staggeredRenderer = nullptr, Map::StaggerAxis staggerAxis = Map::StaggerX); @@ -92,7 +91,6 @@ class WangFiller QPoint point) const; WangSet *mWangSet; - bool mIsInfinite; StaggeredRenderer *mStaggeredRenderer; Map::StaggerAxis mStaggerAxis; };