forked from teamnwah/openmw-tes3coop
Select dragged texture-assets, add brush settings widget-type, fixes.
This commit is contained in:
parent
baa707b5e3
commit
5656745445
8 changed files with 310 additions and 209 deletions
|
@ -81,7 +81,7 @@ opencs_units_noqt (view/world
|
||||||
|
|
||||||
opencs_units (view/widget
|
opencs_units (view/widget
|
||||||
scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton
|
scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton
|
||||||
scenetooltoggle2 completerpopup coloreditor colorpickerpopup droplineedit
|
scenetooltoggle2 scenetooltexturebrush completerpopup coloreditor colorpickerpopup droplineedit
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/render
|
opencs_units (view/render
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "../widget/modebutton.hpp"
|
#include "../widget/modebutton.hpp"
|
||||||
#include "../widget/scenetoolbar.hpp"
|
#include "../widget/scenetoolbar.hpp"
|
||||||
|
#include "../widget/scenetooltexturebrush.hpp"
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/prefs/state.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
@ -41,138 +42,41 @@
|
||||||
#include "object.hpp" // Something small needed regarding pointers from here ()
|
#include "object.hpp" // Something small needed regarding pointers from here ()
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
|
||||||
CSVRender::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent)
|
|
||||||
: QGroupBox(title, parent)
|
|
||||||
{
|
|
||||||
brushSizeSlider = new QSlider(Qt::Horizontal);
|
|
||||||
brushSizeSlider->setTickPosition(QSlider::TicksBothSides);
|
|
||||||
brushSizeSlider->setTickInterval(10);
|
|
||||||
brushSizeSlider->setRange(1, 50);
|
|
||||||
brushSizeSlider->setSingleStep(1);
|
|
||||||
|
|
||||||
brushSizeSpinBox = new QSpinBox;
|
|
||||||
brushSizeSpinBox->setRange(1, 50);
|
|
||||||
brushSizeSpinBox->setSingleStep(1);
|
|
||||||
|
|
||||||
layoutSliderSize = new QHBoxLayout;
|
|
||||||
layoutSliderSize->addWidget(brushSizeSlider);
|
|
||||||
layoutSliderSize->addWidget(brushSizeSpinBox);
|
|
||||||
|
|
||||||
connect(brushSizeSlider, SIGNAL(valueChanged(int)), brushSizeSpinBox, SLOT(setValue(int)));
|
|
||||||
connect(brushSizeSpinBox, SIGNAL(valueChanged(int)), brushSizeSlider, SLOT(setValue(int)));
|
|
||||||
|
|
||||||
setLayout(layoutSliderSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVRender::TextureBrushWindow::TextureBrushWindow(WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
|
||||||
: QFrame(parent, Qt::Popup),
|
|
||||||
mWorldspaceWidget (worldspaceWidget),
|
|
||||||
mBrushSize(0),
|
|
||||||
mBrushShape(0)
|
|
||||||
{
|
|
||||||
mBrushTextureLabel = "Brush: " + mBrushTexture;
|
|
||||||
selectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel), this);
|
|
||||||
|
|
||||||
QVBoxLayout *layoutMain = new QVBoxLayout;
|
|
||||||
layoutMain->setSpacing(0);
|
|
||||||
|
|
||||||
QHBoxLayout *layoutHorizontal = new QHBoxLayout;
|
|
||||||
layoutHorizontal->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
layoutHorizontal->setSpacing(0);
|
|
||||||
|
|
||||||
configureButtonInitialSettings(buttonPoint);
|
|
||||||
configureButtonInitialSettings(buttonSquare);
|
|
||||||
configureButtonInitialSettings(buttonCircle);
|
|
||||||
configureButtonInitialSettings(buttonCustom);
|
|
||||||
|
|
||||||
QButtonGroup* brushButtonGroup = new QButtonGroup(this);
|
|
||||||
brushButtonGroup->addButton(buttonPoint);
|
|
||||||
brushButtonGroup->addButton(buttonSquare);
|
|
||||||
brushButtonGroup->addButton(buttonCircle);
|
|
||||||
brushButtonGroup->addButton(buttonCustom);
|
|
||||||
|
|
||||||
brushButtonGroup->setExclusive(true);
|
|
||||||
|
|
||||||
layoutHorizontal->addWidget(buttonPoint);
|
|
||||||
layoutHorizontal->addWidget(buttonSquare);
|
|
||||||
layoutHorizontal->addWidget(buttonCircle);
|
|
||||||
layoutHorizontal->addWidget(buttonCustom);
|
|
||||||
|
|
||||||
horizontalGroupBox = new QGroupBox(tr(""));
|
|
||||||
horizontalGroupBox->setLayout(layoutHorizontal);
|
|
||||||
|
|
||||||
BrushSizeControls* sizeSliders = new BrushSizeControls(tr(""), this);
|
|
||||||
|
|
||||||
layoutMain->addWidget(horizontalGroupBox);
|
|
||||||
layoutMain->addWidget(sizeSliders);
|
|
||||||
layoutMain->addWidget(selectedBrush);
|
|
||||||
|
|
||||||
setLayout(layoutMain);
|
|
||||||
|
|
||||||
connect(buttonPoint, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
|
||||||
connect(buttonSquare, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
|
||||||
connect(buttonCircle, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
|
||||||
connect(buttonCustom, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
|
||||||
|
|
||||||
connect(sizeSliders->brushSizeSlider, SIGNAL(valueChanged(int)), parent, SLOT(setBrushSize(int)));
|
|
||||||
|
|
||||||
connect(parent, SIGNAL(passBrushTexture(std::string)), this, SLOT(setBrushTexture(std::string)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TextureBrushWindow::configureButtonInitialSettings(QPushButton *button)
|
|
||||||
{
|
|
||||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
||||||
button->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
button->setIconSize (QSize (48-6, 48-6));
|
|
||||||
button->setFixedSize (48, 48);
|
|
||||||
button->setAcceptDrops(true);
|
|
||||||
button->setCheckable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TextureBrushWindow::setBrushTexture(std::string brushTexture)
|
|
||||||
{
|
|
||||||
mBrushTexture = brushTexture;
|
|
||||||
mBrushTextureLabel = "Brush:" + mBrushTexture;
|
|
||||||
selectedBrush->setText(QString::fromStdString(mBrushTextureLabel));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TextureBrushWindow::setBrushSize(int brushSize)
|
|
||||||
{
|
|
||||||
mBrushSize = brushSize;
|
|
||||||
emit passBrushSize(mBrushSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TextureBrushWindow::setBrushShape()
|
|
||||||
{
|
|
||||||
if(buttonPoint->isChecked()) mBrushShape = 0;
|
|
||||||
if(buttonSquare->isChecked()) mBrushShape = 1;
|
|
||||||
if(buttonCircle->isChecked()) mBrushShape = 2;
|
|
||||||
if(buttonCustom->isChecked()) mBrushShape = 3;
|
|
||||||
emit passBrushShape(mBrushShape);
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVRender::TerrainTextureMode::TerrainTextureMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
CSVRender::TerrainTextureMode::TerrainTextureMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
||||||
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, Mask_Terrain | Mask_Reference, "Terrain texture editing", parent),
|
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, Mask_Terrain | Mask_Reference, "Terrain texture editing", parent),
|
||||||
textureBrushWindow(new TextureBrushWindow(worldspaceWidget, this)),
|
|
||||||
mBrushTexture("#0"),
|
mBrushTexture("#0"),
|
||||||
mBrushSize(0),
|
mBrushSize(0),
|
||||||
mBrushShape(0)
|
mBrushShape(0),
|
||||||
|
mTextureBrushScenetool(0)
|
||||||
{
|
{
|
||||||
connect(parent, SIGNAL(passEvent(QDragEnterEvent*)), this, SLOT(handleDragEnterEvent(QDragEnterEvent*)));
|
|
||||||
connect(parent, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*)));
|
|
||||||
connect(parent, SIGNAL(passEvent(QMouseEvent*)), this, SLOT(handleMouseEvent(QMouseEvent*)));
|
|
||||||
connect(textureBrushWindow, SIGNAL(passBrushSize(int)), this, SLOT(setBrushSize(int)));
|
|
||||||
connect(textureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setBrushShape(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::activate(CSVWidget::SceneToolbar* toolbar)
|
void CSVRender::TerrainTextureMode::activate(CSVWidget::SceneToolbar* toolbar)
|
||||||
{
|
{
|
||||||
|
if(!mTextureBrushScenetool)
|
||||||
|
{
|
||||||
|
mTextureBrushScenetool = new CSVWidget::SceneToolTextureBrush (toolbar, "scenetooltexturebrush");
|
||||||
|
connect(mTextureBrushScenetool, SIGNAL (clicked()), mTextureBrushScenetool, SLOT (activate()));
|
||||||
|
connect(mTextureBrushScenetool->mTextureBrushWindow, SIGNAL(passBrushSize(int)), this, SLOT(setBrushSize(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, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*)));
|
||||||
|
connect(this, SIGNAL(passBrushTexture(std::string)), mTextureBrushScenetool->mTextureBrushWindow, SLOT(setBrushTexture(std::string)));
|
||||||
|
}
|
||||||
|
|
||||||
EditMode::activate(toolbar);
|
EditMode::activate(toolbar);
|
||||||
|
toolbar->addTool (mTextureBrushScenetool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::deactivate(CSVWidget::SceneToolbar* toolbar)
|
void CSVRender::TerrainTextureMode::deactivate(CSVWidget::SceneToolbar* toolbar)
|
||||||
{
|
{
|
||||||
|
if(mTextureBrushScenetool)
|
||||||
|
{
|
||||||
|
toolbar->removeTool (mTextureBrushScenetool);
|
||||||
|
delete mTextureBrushScenetool;
|
||||||
|
mTextureBrushScenetool = 0;
|
||||||
|
}
|
||||||
EditMode::deactivate(toolbar);
|
EditMode::deactivate(toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,10 +163,6 @@ void CSVRender::TerrainTextureMode::dragAborted() {
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::dragWheel (int diff, double speedFactor) {}
|
void CSVRender::TerrainTextureMode::dragWheel (int diff, double speedFactor) {}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::handleDragEnterEvent (QDragEnterEvent *event) {
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::handleDropEvent (QDropEvent *event) {
|
void CSVRender::TerrainTextureMode::handleDropEvent (QDropEvent *event) {
|
||||||
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
||||||
|
|
||||||
|
@ -287,24 +187,11 @@ void CSVRender::TerrainTextureMode::handleDropEvent (QDropEvent *event) {
|
||||||
{
|
{
|
||||||
std::string textureFileName = uid.toString();
|
std::string textureFileName = uid.toString();
|
||||||
createTexture(textureFileName);
|
createTexture(textureFileName);
|
||||||
|
emit passBrushTexture(mBrushTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::handleMouseEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button()==Qt::MidButton)
|
|
||||||
{
|
|
||||||
QPoint position = QCursor::pos();
|
|
||||||
textureBrushWindow->move (position);
|
|
||||||
textureBrushWindow->show();
|
|
||||||
}
|
|
||||||
if (event->button()==Qt::LeftButton) PushButton::mouseReleaseEvent (event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::handlePrimarySelectOnModeButton () {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitResult& hit)
|
void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitResult& hit)
|
||||||
{
|
{
|
||||||
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
|
@ -529,6 +416,7 @@ void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName)
|
||||||
QModelIndex index(ltexTable.getModelIndex (newId, ltexTable.findColumnIndex (CSMWorld::Columns::ColumnId_Texture)));
|
QModelIndex index(ltexTable.getModelIndex (newId, ltexTable.findColumnIndex (CSMWorld::Columns::ColumnId_Texture)));
|
||||||
undoStack.push (new CSMWorld::ModifyCommand(ltexTable, index, textureFileNameVariant));
|
undoStack.push (new CSMWorld::ModifyCommand(ltexTable, index, textureFileNameVariant));
|
||||||
undoStack.endMacro();
|
undoStack.endMacro();
|
||||||
|
mBrushTexture = newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId)
|
bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId)
|
||||||
|
@ -602,7 +490,7 @@ bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId)
|
||||||
document.getUndoStack().push (new CSMWorld::CreateCommand (landTable, cellId));
|
document.getUndoStack().push (new CSMWorld::CreateCommand (landTable, cellId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,59 +26,12 @@
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolMode;
|
class SceneToolTextureBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
|
||||||
/// \brief Layout-box for some brush button settings
|
|
||||||
class BrushSizeControls : public QGroupBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
BrushSizeControls(const QString &title, QWidget *parent);
|
|
||||||
QSlider *brushSizeSlider;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSpinBox *brushSizeSpinBox;
|
|
||||||
QHBoxLayout *layoutSliderSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \brief Brush settings window
|
|
||||||
class TextureBrushWindow : public QFrame
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
TextureBrushWindow(WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
|
|
||||||
void configureButtonInitialSettings(QPushButton *button);
|
|
||||||
|
|
||||||
QPushButton *buttonPoint = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-point")), "", this);
|
|
||||||
QPushButton *buttonSquare = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-square")), "", this);
|
|
||||||
QPushButton *buttonCircle = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-circle")), "", this);
|
|
||||||
QPushButton *buttonCustom = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-custom")), "", this);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLabel *selectedBrush;
|
|
||||||
QGroupBox *horizontalGroupBox;
|
|
||||||
WorldspaceWidget *mWorldspaceWidget;
|
|
||||||
int mBrushSize;
|
|
||||||
int mBrushShape;
|
|
||||||
std::string mBrushTexture;
|
|
||||||
std::string mBrushTextureLabel;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setBrushTexture(std::string brushTexture);
|
|
||||||
void setBrushShape();
|
|
||||||
void setBrushSize(int brushSize);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void passBrushSize (int brushSize);
|
|
||||||
void passBrushShape(int brushShape);
|
|
||||||
};
|
|
||||||
|
|
||||||
class TerrainTextureMode : public EditMode
|
class TerrainTextureMode : public EditMode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -130,11 +83,11 @@ namespace CSVRender
|
||||||
bool allowLandTextureEditing(std::string textureFileName);
|
bool allowLandTextureEditing(std::string textureFileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureBrushWindow *textureBrushWindow;
|
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
std::string mBrushTexture;
|
std::string mBrushTexture;
|
||||||
int mBrushSize;
|
int mBrushSize;
|
||||||
int mBrushShape;
|
int mBrushShape;
|
||||||
|
CSVWidget::SceneToolTextureBrush *mTextureBrushScenetool;
|
||||||
|
|
||||||
const int cellSize {ESM::Land::REAL_SIZE};
|
const int cellSize {ESM::Land::REAL_SIZE};
|
||||||
const int landSize {ESM::Land::LAND_SIZE};
|
const int landSize {ESM::Land::LAND_SIZE};
|
||||||
|
@ -144,10 +97,7 @@ namespace CSVRender
|
||||||
void passBrushTexture(std::string brushTexture);
|
void passBrushTexture(std::string brushTexture);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleDragEnterEvent (QDragEnterEvent *event);
|
|
||||||
void handleDropEvent(QDropEvent *event);
|
void handleDropEvent(QDropEvent *event);
|
||||||
void handleMouseEvent (QMouseEvent *event);
|
|
||||||
void handlePrimarySelectOnModeButton();
|
|
||||||
void setBrushSize(int brushSize);
|
void setBrushSize(int brushSize);
|
||||||
void setBrushShape(int brushShape);
|
void setBrushShape(int brushShape);
|
||||||
|
|
||||||
|
|
|
@ -576,10 +576,6 @@ void CSVRender::WorldspaceWidget::debugProfileAboutToBeRemoved (const QModelInde
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::editModeChanged (const std::string& id)
|
void CSVRender::WorldspaceWidget::editModeChanged (const std::string& id)
|
||||||
{
|
{
|
||||||
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).setEditLock (mLocked);
|
|
||||||
if (mEditMode->getCurrentId() == "terrain-texture") mEditMode->setAcceptDrops(true);
|
|
||||||
else mEditMode->setAcceptDrops(false);
|
|
||||||
|
|
||||||
mDragging = false;
|
mDragging = false;
|
||||||
mDragMode = InteractionType_None;
|
mDragMode = InteractionType_None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,6 @@ void CSVWidget::SceneToolMode::setButton (const std::string& id)
|
||||||
|
|
||||||
void CSVWidget::SceneToolMode::mouseReleaseEvent (QMouseEvent *event)
|
void CSVWidget::SceneToolMode::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button()==Qt::MidButton && getCurrentId() == "terrain-texture") emit passEvent(event);
|
|
||||||
if (getType()==Type_TopAction && event->button()==Qt::RightButton)
|
if (getType()==Type_TopAction && event->button()==Qt::RightButton)
|
||||||
showPanel (parentWidget()->mapToGlobal (pos()));
|
showPanel (parentWidget()->mapToGlobal (pos()));
|
||||||
else
|
else
|
||||||
|
@ -154,15 +153,6 @@ bool CSVWidget::SceneToolMode::event(QEvent* event)
|
||||||
return SceneTool::event(event);
|
return SceneTool::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWidget::SceneToolMode::dragEnterEvent (QDragEnterEvent *event)
|
|
||||||
{
|
|
||||||
emit passEvent(event);
|
|
||||||
}
|
|
||||||
void CSVWidget::SceneToolMode::dropEvent (QDropEvent *event)
|
|
||||||
{
|
|
||||||
emit passEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWidget::SceneToolMode::selected()
|
void CSVWidget::SceneToolMode::selected()
|
||||||
{
|
{
|
||||||
std::map<ModeButton *, std::string>::iterator iter =
|
std::map<ModeButton *, std::string>::iterator iter =
|
||||||
|
|
|
@ -49,8 +49,6 @@ namespace CSVWidget
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
void dragEnterEvent (QDragEnterEvent *event);
|
|
||||||
void dropEvent (QDropEvent *event);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -76,9 +74,6 @@ namespace CSVWidget
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void modeChanged (const std::string& id);
|
void modeChanged (const std::string& id);
|
||||||
void passEvent (QMouseEvent *event);
|
|
||||||
void passEvent (QDragEnterEvent *event);
|
|
||||||
void passEvent (QDropEvent *event);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
173
apps/opencs/view/widget/scenetooltexturebrush.cpp
Normal file
173
apps/opencs/view/widget/scenetooltexturebrush.cpp
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
#include "scenetooltexturebrush.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QDrag>
|
||||||
|
|
||||||
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
CSVWidget::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent)
|
||||||
|
: QGroupBox(title, parent)
|
||||||
|
{
|
||||||
|
mBrushSizeSlider = new QSlider(Qt::Horizontal);
|
||||||
|
mBrushSizeSlider->setTickPosition(QSlider::TicksBothSides);
|
||||||
|
mBrushSizeSlider->setTickInterval(10);
|
||||||
|
mBrushSizeSlider->setRange(1, 50);
|
||||||
|
mBrushSizeSlider->setSingleStep(1);
|
||||||
|
|
||||||
|
mBrushSizeSpinBox = new QSpinBox;
|
||||||
|
mBrushSizeSpinBox->setRange(1, 50);
|
||||||
|
mBrushSizeSpinBox->setSingleStep(1);
|
||||||
|
|
||||||
|
mLayoutSliderSize = new QHBoxLayout;
|
||||||
|
mLayoutSliderSize->addWidget(mBrushSizeSlider);
|
||||||
|
mLayoutSliderSize->addWidget(mBrushSizeSpinBox);
|
||||||
|
|
||||||
|
connect(mBrushSizeSlider, SIGNAL(valueChanged(int)), mBrushSizeSpinBox, SLOT(setValue(int)));
|
||||||
|
connect(mBrushSizeSpinBox, SIGNAL(valueChanged(int)), mBrushSizeSlider, SLOT(setValue(int)));
|
||||||
|
|
||||||
|
setLayout(mLayoutSliderSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::TextureBrushWindow::TextureBrushWindow(QWidget *parent)
|
||||||
|
: QFrame(parent, Qt::Popup),
|
||||||
|
mBrushShape(0),
|
||||||
|
mBrushSize(0)
|
||||||
|
|
||||||
|
{
|
||||||
|
mBrushTextureLabel = "Brush: " + mBrushTexture;
|
||||||
|
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel), this);
|
||||||
|
|
||||||
|
QVBoxLayout *layoutMain = new QVBoxLayout;
|
||||||
|
layoutMain->setSpacing(0);
|
||||||
|
|
||||||
|
QHBoxLayout *layoutHorizontal = new QHBoxLayout;
|
||||||
|
layoutHorizontal->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
layoutHorizontal->setSpacing(0);
|
||||||
|
|
||||||
|
configureButtonInitialSettings(mButtonPoint);
|
||||||
|
configureButtonInitialSettings(mButtonSquare);
|
||||||
|
configureButtonInitialSettings(mButtonCircle);
|
||||||
|
configureButtonInitialSettings(mButtonCustom);
|
||||||
|
|
||||||
|
QButtonGroup* brushButtonGroup = new QButtonGroup(this);
|
||||||
|
brushButtonGroup->addButton(mButtonPoint);
|
||||||
|
brushButtonGroup->addButton(mButtonSquare);
|
||||||
|
brushButtonGroup->addButton(mButtonCircle);
|
||||||
|
brushButtonGroup->addButton(mButtonCustom);
|
||||||
|
|
||||||
|
brushButtonGroup->setExclusive(true);
|
||||||
|
|
||||||
|
layoutHorizontal->addWidget(mButtonPoint);
|
||||||
|
layoutHorizontal->addWidget(mButtonSquare);
|
||||||
|
layoutHorizontal->addWidget(mButtonCircle);
|
||||||
|
layoutHorizontal->addWidget(mButtonCustom);
|
||||||
|
|
||||||
|
mHorizontalGroupBox = new QGroupBox(tr(""));
|
||||||
|
mHorizontalGroupBox->setLayout(layoutHorizontal);
|
||||||
|
|
||||||
|
layoutMain->addWidget(mHorizontalGroupBox);
|
||||||
|
layoutMain->addWidget(mSizeSliders);
|
||||||
|
layoutMain->addWidget(mSelectedBrush);
|
||||||
|
|
||||||
|
setLayout(layoutMain);
|
||||||
|
|
||||||
|
connect(mButtonPoint, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonSquare, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonCircle, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonCustom, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::TextureBrushWindow::configureButtonInitialSettings(QPushButton *button)
|
||||||
|
{
|
||||||
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
|
button->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
button->setIconSize (QSize (48-6, 48-6));
|
||||||
|
button->setFixedSize (48, 48);
|
||||||
|
button->setCheckable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::TextureBrushWindow::setBrushTexture(std::string brushTexture)
|
||||||
|
{
|
||||||
|
mBrushTexture = brushTexture;
|
||||||
|
mBrushTextureLabel = "Brush:" + mBrushTexture;
|
||||||
|
mSelectedBrush->setText(QString::fromStdString(mBrushTextureLabel));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::TextureBrushWindow::setBrushSize(int brushSize)
|
||||||
|
{
|
||||||
|
mBrushSize = brushSize;
|
||||||
|
emit passBrushSize(mBrushSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::TextureBrushWindow::setBrushShape()
|
||||||
|
{
|
||||||
|
if(mButtonPoint->isChecked()) mBrushShape = 0;
|
||||||
|
if(mButtonSquare->isChecked()) mBrushShape = 1;
|
||||||
|
if(mButtonCircle->isChecked()) mBrushShape = 2;
|
||||||
|
if(mButtonCustom->isChecked()) mBrushShape = 3;
|
||||||
|
emit passBrushShape(mBrushShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::adjustToolTips()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::SceneToolTextureBrush::SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip)
|
||||||
|
: SceneTool (parent),
|
||||||
|
mToolTip (toolTip),
|
||||||
|
mTextureBrushWindow(new TextureBrushWindow(this))
|
||||||
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
|
if(mTextureBrushWindow->mBrushShape == 0) setIcon (QIcon (QPixmap (":scenetoolbar/brush-point")));
|
||||||
|
if(mTextureBrushWindow->mBrushShape == 1) setIcon (QIcon (QPixmap (":scenetoolbar/brush-square")));
|
||||||
|
if(mTextureBrushWindow->mBrushShape == 2) setIcon (QIcon (QPixmap (":scenetoolbar/brush-circle")));
|
||||||
|
if(mTextureBrushWindow->mBrushShape == 3) setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
|
||||||
|
connect(mTextureBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setButtonIcon(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
|
||||||
|
{
|
||||||
|
if(brushShape == 0) setIcon (QIcon (QPixmap (":scenetoolbar/brush-point")));
|
||||||
|
if(brushShape == 1) setIcon (QIcon (QPixmap (":scenetoolbar/brush-square")));
|
||||||
|
if(brushShape == 2) setIcon (QIcon (QPixmap (":scenetoolbar/brush-circle")));
|
||||||
|
if(brushShape == 3) setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::showPanel (const QPoint& position)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::activate ()
|
||||||
|
{
|
||||||
|
QPoint position = QCursor::pos();
|
||||||
|
mTextureBrushWindow->move (position);
|
||||||
|
mTextureBrushWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolTextureBrush::dragEnterEvent (QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
emit passEvent(event);
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
void CSVWidget::SceneToolTextureBrush::dropEvent (QDropEvent *event)
|
||||||
|
{
|
||||||
|
emit passEvent(event);
|
||||||
|
event->accept();
|
||||||
|
}
|
109
apps/opencs/view/widget/scenetooltexturebrush.hpp
Normal file
109
apps/opencs/view/widget/scenetooltexturebrush.hpp
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#ifndef CSV_WIDGET_SCENETOOLTEXTUREBRUSH_H
|
||||||
|
#define CSV_WIDGET_SCENETOOLTEXTUREBRUSH_H
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
/*namespace CSVRender
|
||||||
|
{
|
||||||
|
class TerrainTextureMode;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
/// \brief Layout-box for some brush button settings
|
||||||
|
class BrushSizeControls : public QGroupBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BrushSizeControls(const QString &title, QWidget *parent);
|
||||||
|
QSlider *mBrushSizeSlider;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSpinBox *mBrushSizeSpinBox;
|
||||||
|
QHBoxLayout *mLayoutSliderSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \brief Brush settings window
|
||||||
|
class TextureBrushWindow : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TextureBrushWindow(QWidget *parent = 0);
|
||||||
|
void configureButtonInitialSettings(QPushButton *button);
|
||||||
|
|
||||||
|
QPushButton *mButtonPoint = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-point")), "", this);
|
||||||
|
QPushButton *mButtonSquare = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-square")), "", this);
|
||||||
|
QPushButton *mButtonCircle = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-circle")), "", this);
|
||||||
|
QPushButton *mButtonCustom = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-custom")), "", this);
|
||||||
|
BrushSizeControls* mSizeSliders = new BrushSizeControls(tr(""), this);
|
||||||
|
int mBrushShape;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel *mSelectedBrush;
|
||||||
|
QGroupBox *mHorizontalGroupBox;
|
||||||
|
int mBrushSize;
|
||||||
|
std::string mBrushTexture;
|
||||||
|
std::string mBrushTextureLabel;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setBrushTexture(std::string brushTexture);
|
||||||
|
void setBrushShape();
|
||||||
|
void setBrushSize(int brushSize);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void passBrushSize (int brushSize);
|
||||||
|
void passBrushShape(int brushShape);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SceneToolTextureBrush : public SceneTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QString mToolTip;
|
||||||
|
|
||||||
|
//CSVRender::TerrainTextureMode *mTerrainTextureMode;
|
||||||
|
//QIcon *mTextureBrushIcon;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void adjustToolTips();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SceneToolTextureBrush (SceneToolbar *parent, const QString& toolTip);
|
||||||
|
|
||||||
|
virtual void showPanel (const QPoint& position);
|
||||||
|
|
||||||
|
TextureBrushWindow *mTextureBrushWindow;
|
||||||
|
//virtual void activate();
|
||||||
|
|
||||||
|
void dropEvent (QDropEvent *event);
|
||||||
|
void dragEnterEvent (QDragEnterEvent *event);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setButtonIcon(int brushShape);
|
||||||
|
virtual void activate();
|
||||||
|
//void clicked ();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void passEvent(QDropEvent *event);
|
||||||
|
void passEvent(QDragEnterEvent *event);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue