mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-25 03:40:40 +00:00
Brush history menu
This commit is contained in:
parent
d2cf764a46
commit
1c79d5311c
@ -54,9 +54,11 @@ void CSVRender::TerrainTextureMode::activate(CSVWidget::SceneToolbar* toolbar)
|
|||||||
connect(mTextureBrushScenetool->mTextureBrushWindow, SIGNAL(passBrushSize(int)), this, SLOT(setBrushSize(int)));
|
connect(mTextureBrushScenetool->mTextureBrushWindow, SIGNAL(passBrushSize(int)), this, SLOT(setBrushSize(int)));
|
||||||
connect(mTextureBrushScenetool->mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setBrushShape(int)));
|
connect(mTextureBrushScenetool->mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setBrushShape(int)));
|
||||||
connect(mTextureBrushScenetool->mTextureBrushWindow->mSizeSliders->mBrushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int)));
|
connect(mTextureBrushScenetool->mTextureBrushWindow->mSizeSliders->mBrushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int)));
|
||||||
|
connect(mTextureBrushScenetool, SIGNAL(passTextureId(std::string)), this, SLOT(setBrushTexture(std::string)));
|
||||||
|
|
||||||
connect(mTextureBrushScenetool, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*)));
|
connect(mTextureBrushScenetool, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*)));
|
||||||
connect(this, SIGNAL(passBrushTexture(std::string)), mTextureBrushScenetool->mTextureBrushWindow, SLOT(setBrushTexture(std::string)));
|
connect(this, SIGNAL(passBrushTexture(std::string)), mTextureBrushScenetool->mTextureBrushWindow, SLOT(setBrushTexture(std::string)));
|
||||||
|
connect(this, SIGNAL(passBrushTexture(std::string)), mTextureBrushScenetool, SLOT(updateBrushHistory(std::string)));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditMode::activate(toolbar);
|
EditMode::activate(toolbar);
|
||||||
@ -500,3 +502,8 @@ void CSVRender::TerrainTextureMode::setBrushShape(int brushShape)
|
|||||||
{
|
{
|
||||||
mBrushShape = brushShape;
|
mBrushShape = brushShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::TerrainTextureMode::setBrushTexture(std::string brushTexture)
|
||||||
|
{
|
||||||
|
mBrushTexture = brushTexture;
|
||||||
|
}
|
||||||
|
@ -92,7 +92,7 @@ namespace CSVRender
|
|||||||
void handleDropEvent(QDropEvent *event);
|
void handleDropEvent(QDropEvent *event);
|
||||||
void setBrushSize(int brushSize);
|
void setBrushSize(int brushSize);
|
||||||
void setBrushShape(int brushShape);
|
void setBrushShape(int brushShape);
|
||||||
|
void setBrushTexture(std::string brushShape);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
|
||||||
#include "scenetool.hpp"
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
@ -133,13 +137,40 @@ void CSVWidget::SceneToolTextureBrush::adjustToolTips()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSVWidget::SceneToolTextureBrush::SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip)
|
CSVWidget::SceneToolTextureBrush::SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip)
|
||||||
: SceneTool (parent),
|
: SceneTool (parent, Type_TopAction),
|
||||||
mToolTip (toolTip),
|
mToolTip (toolTip),
|
||||||
|
mBrushHistory{"L0#0"},
|
||||||
mTextureBrushWindow(new TextureBrushWindow(this))
|
mTextureBrushWindow(new TextureBrushWindow(this))
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
connect(mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setButtonIcon(int)));
|
connect(mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setButtonIcon(int)));
|
||||||
setButtonIcon(mTextureBrushWindow->mBrushShape);
|
setButtonIcon(mTextureBrushWindow->mBrushShape);
|
||||||
|
|
||||||
|
mPanel = new QFrame (this, Qt::Popup);
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout (mPanel);
|
||||||
|
|
||||||
|
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
mTable = new QTableWidget (0, 2, this);
|
||||||
|
|
||||||
|
mTable->setShowGrid (true);
|
||||||
|
mTable->verticalHeader()->hide();
|
||||||
|
mTable->horizontalHeader()->hide();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch);
|
||||||
|
mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::ResizeToContents);
|
||||||
|
#else
|
||||||
|
mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch);
|
||||||
|
mTable->horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents);
|
||||||
|
#endif
|
||||||
|
mTable->setSelectionMode (QAbstractItemView::NoSelection);
|
||||||
|
|
||||||
|
layout->addWidget (mTable);
|
||||||
|
|
||||||
|
connect (mTable, SIGNAL (clicked (const QModelIndex&)),
|
||||||
|
this, SLOT (clicked (const QModelIndex&)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
|
void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
|
||||||
@ -172,6 +203,45 @@ void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
|
|||||||
|
|
||||||
void CSVWidget::SceneToolTextureBrush::showPanel (const QPoint& position)
|
void CSVWidget::SceneToolTextureBrush::showPanel (const QPoint& position)
|
||||||
{
|
{
|
||||||
|
updatePanel();
|
||||||
|
mPanel->move (position);
|
||||||
|
mPanel->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::updatePanel()
|
||||||
|
{
|
||||||
|
mTable->setRowCount (mBrushHistory.size());
|
||||||
|
|
||||||
|
mTable->setItem (0, 1, new QTableWidgetItem (
|
||||||
|
QApplication::style()->standardIcon (QStyle::SP_TitleBarCloseButton), ""));
|
||||||
|
|
||||||
|
for (int i = mBrushHistory.size()-1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::updateBrushHistory (const std::string& brushTexture)
|
||||||
|
{
|
||||||
|
mBrushHistory.insert(mBrushHistory.begin(), brushTexture);
|
||||||
|
if(mBrushHistory.size() > 5) mBrushHistory.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::clicked (const QModelIndex& index)
|
||||||
|
{
|
||||||
|
if (index.column()==0)
|
||||||
|
{
|
||||||
|
std::string brushTexture = mBrushHistory[index.row()];
|
||||||
|
std::swap(mBrushHistory[index.row()], mBrushHistory[0]);
|
||||||
|
mTextureBrushWindow->setBrushTexture(brushTexture);
|
||||||
|
emit passTextureId(brushTexture);
|
||||||
|
updatePanel();
|
||||||
|
mPanel->hide();
|
||||||
|
}
|
||||||
|
else if (index.column()==1)
|
||||||
|
{
|
||||||
|
mPanel->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWidget::SceneToolTextureBrush::activate ()
|
void CSVWidget::SceneToolTextureBrush::activate ()
|
||||||
|
@ -16,10 +16,7 @@
|
|||||||
|
|
||||||
#include "scenetool.hpp"
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
/*namespace CSVRender
|
class QTableWidget;
|
||||||
{
|
|
||||||
class TerrainTextureMode;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
@ -79,6 +76,9 @@ namespace CSVWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QString mToolTip;
|
QString mToolTip;
|
||||||
|
QFrame *mPanel;
|
||||||
|
QTableWidget *mTable;
|
||||||
|
std::vector<std::string> mBrushHistory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -89,6 +89,7 @@ namespace CSVWidget
|
|||||||
SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip);
|
SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip);
|
||||||
|
|
||||||
virtual void showPanel (const QPoint& position);
|
virtual void showPanel (const QPoint& position);
|
||||||
|
void updatePanel ();
|
||||||
|
|
||||||
TextureBrushWindow *mTextureBrushWindow;
|
TextureBrushWindow *mTextureBrushWindow;
|
||||||
|
|
||||||
@ -97,11 +98,14 @@ namespace CSVWidget
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setButtonIcon(int brushShape);
|
void setButtonIcon(int brushShape);
|
||||||
|
void updateBrushHistory (const std::string& mBrushTexture);
|
||||||
|
void clicked (const QModelIndex& index);
|
||||||
virtual void activate();
|
virtual void activate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void passEvent(QDropEvent *event);
|
void passEvent(QDropEvent *event);
|
||||||
void passEvent(QDragEnterEvent *event);
|
void passEvent(QDragEnterEvent *event);
|
||||||
|
void passTextureId(std::string brushTexture);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user