Select dragged texture-assets, add brush settings widget-type, fixes.
parent
baa707b5e3
commit
5656745445
@ -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();
|
||||
}
|
@ -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 New Issue