Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Wang Pattern and color view into a tab widget #1690

Merged
merged 2 commits into from
Aug 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/tiled/bucketfilltool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ void BucketFillTool::wangFill(TileLayer &tileLayerToFill,
return;

WangFiller wangFiller(mWangSet,
mapDocument()->map()->infinite(),
dynamic_cast<StaggeredRenderer *>(mapDocument()->renderer()),
mapDocument()->map()->staggerAxis());

Expand Down
1 change: 0 additions & 1 deletion src/tiled/stampbrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ void StampBrush::drawPreviewLayer(const QVector<QPoint> &list)
bounds.width(), bounds.height()));

WangFiller wangFiller(mWangSet,
mapDocument()->map()->infinite(),
dynamic_cast<StaggeredRenderer *>(mapDocument()->renderer()),
mapDocument()->map()->staggerAxis());

Expand Down
38 changes: 12 additions & 26 deletions src/tiled/wangdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <QPushButton>
#include <QSortFilterProxyModel>
#include <QSplitter>
#include <QStackedWidget>
#include <QTabWidget>
#include <QToolBar>
#include <QTreeView>
#include <QUndoStack>
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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<TilesetDocument*>(document)) {
TilesetWangSetModel *wangSetModel = tilesetDocument->wangSetModel();

Expand All @@ -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();

/*
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/tiled/wangdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QModelIndex;
class QPushButton;
class QToolBar;
class QTreeView;
class QStackedWidget;
class QTabWidget;

namespace Tiled {
namespace Internal {
Expand Down Expand Up @@ -90,7 +90,6 @@ public slots:

private slots:
void activateErase();
void switchTemplateViewButtonClicked();
void refreshCurrentWangSet();
void refreshCurrentWangId();
void refreshCurrentWangColor();
Expand Down Expand Up @@ -118,7 +117,6 @@ private slots:
Document *mDocument;
WangSetView *mWangSetView;
QPushButton *mEraseWangIdsButton;
QPushButton *mSwitchTemplateViewButton;
WangSet *mCurrentWangSet;
WangId mCurrentWangId;
TilesetDocumentsFilterModel *mTilesetDocumentFilterModel;
Expand All @@ -128,7 +126,7 @@ private slots:
HasChildrenFilterModel *mProxyModel;
WangTemplateView *mWangTemplateView;
WangTemplateModel *mWangTemplateModel;
QStackedWidget *mTemplateAndColorView;
QTabWidget *mTemplateAndColorView;
QWidget *mTemplateAndColorWidget;

bool mInitializing;
Expand Down
2 changes: 0 additions & 2 deletions src/tiled/wangfiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 1 addition & 3 deletions src/tiled/wangfiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -92,7 +91,6 @@ class WangFiller
QPoint point) const;

WangSet *mWangSet;
bool mIsInfinite;
StaggeredRenderer *mStaggeredRenderer;
Map::StaggerAxis mStaggerAxis;
};
Expand Down