From bbc337a0af8618e6c0b6f3f5c2816b113d07c44c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 26 May 2018 12:16:02 +0200 Subject: [PATCH] code cleanup --- .../view/widget/scenetooltexturebrush.cpp | 7 +++ .../view/widget/scenetooltexturebrush.hpp | 46 +++++++++++++------ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/widget/scenetooltexturebrush.cpp b/apps/opencs/view/widget/scenetooltexturebrush.cpp index dab6a2850..2208f88a6 100644 --- a/apps/opencs/view/widget/scenetooltexturebrush.cpp +++ b/apps/opencs/view/widget/scenetooltexturebrush.cpp @@ -78,6 +78,13 @@ CSVWidget::TextureBrushWindow::TextureBrushWindow(CSMDoc::Document& document, QW mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel)); } + mButtonPoint = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-point")), "", this); + mButtonSquare = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-square")), "", this); + mButtonCircle = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-circle")), "", this); + mButtonCustom = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-custom")), "", this); + + mSizeSliders = new BrushSizeControls("Brush size", this); + QVBoxLayout *layoutMain = new QVBoxLayout; layoutMain->setSpacing(0); layoutMain->setContentsMargins(4,0,4,4); diff --git a/apps/opencs/view/widget/scenetooltexturebrush.hpp b/apps/opencs/view/widget/scenetooltexturebrush.hpp index d40132d42..4669f432e 100644 --- a/apps/opencs/view/widget/scenetooltexturebrush.hpp +++ b/apps/opencs/view/widget/scenetooltexturebrush.hpp @@ -20,8 +20,15 @@ class QTableWidget; +namespace CSVRender +{ + class TerrainTextureMode; +} + namespace CSVWidget { + class SceneToolTextureBrush; + /// \brief Layout-box for some brush button settings class BrushSizeControls : public QGroupBox { @@ -29,13 +36,18 @@ namespace CSVWidget public: BrushSizeControls(const QString &title, QWidget *parent); - QSlider *mBrushSizeSlider; - QSpinBox *mBrushSizeSpinBox; private: QHBoxLayout *mLayoutSliderSize; + QSlider *mBrushSizeSlider; + QSpinBox *mBrushSizeSpinBox; + + friend class SceneToolTextureBrush; + friend class CSVRender::TerrainTextureMode; }; + class SceneToolTextureBrush; + /// \brief Brush settings window class TextureBrushWindow : public QFrame { @@ -45,24 +57,27 @@ namespace CSVWidget TextureBrushWindow(CSMDoc::Document& document, 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); - QString toolTipPoint = "Paint single point"; - QString toolTipSquare = "Paint with square brush"; - QString toolTipCircle = "Paint with circle brush"; - QString toolTipCustom = "Paint custom selection (not implemented yet)"; - BrushSizeControls* mSizeSliders = new BrushSizeControls("Brush size", this); + const QString toolTipPoint = "Paint single point"; + const QString toolTipSquare = "Paint with square brush"; + const QString toolTipCircle = "Paint with circle brush"; + const QString toolTipCustom = "Paint custom selection (not implemented yet)"; + + private: int mBrushShape; int mBrushSize; std::string mBrushTexture; - - private: CSMDoc::Document& mDocument; QLabel *mSelectedBrush; QGroupBox *mHorizontalGroupBox; std::string mBrushTextureLabel; + QPushButton *mButtonPoint; + QPushButton *mButtonSquare; + QPushButton *mButtonCircle; + QPushButton *mButtonCustom; + BrushSizeControls* mSizeSliders; + + friend class SceneToolTextureBrush; + friend class CSVRender::TerrainTextureMode; public slots: void setBrushTexture(std::string brushTexture); @@ -84,6 +99,7 @@ namespace CSVWidget QFrame *mPanel; QTableWidget *mTable; std::vector mBrushHistory; + TextureBrushWindow *mTextureBrushWindow; private: @@ -96,11 +112,11 @@ namespace CSVWidget virtual void showPanel (const QPoint& position); void updatePanel (); - TextureBrushWindow *mTextureBrushWindow; - void dropEvent (QDropEvent *event); void dragEnterEvent (QDragEnterEvent *event); + friend class CSVRender::TerrainTextureMode; + public slots: void setButtonIcon(int brushShape); void updateBrushHistory (const std::string& mBrushTexture);