Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FULLCOLORBRUSHTOOL_H
Toshihiro Shimizu 890ddd
#define FULLCOLORBRUSHTOOL_H
Toshihiro Shimizu 890ddd
bf1d82
#include <ctime></ctime>
bf1d82
shun-iwasawa 98926d
#include "toonzrasterbrushtool.h"
bf1d82
#include "mypainttoonzbrush.h"
bf1d82
#include "toonz/mypaintbrushstyle.h"
bf1d82
#include <qelapsedtimer></qelapsedtimer>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//  Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TTileSetFullColor;
Toshihiro Shimizu 890ddd
class TTileSaverFullColor;
bf1d82
class MyPaintToonzBrush;
Toshihiro Shimizu 890ddd
class FullColorBrushToolNotifier;
shun-iwasawa 98926d
namespace mypaint {
shun-iwasawa 98926d
class Brush;
shun-iwasawa 98926d
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
//    FullColor Brush Tool declaration
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
bf1d82
class FullColorBrushTool final : public TTool, public RasterController {
Shinya Kitaoka 120a6e
  Q_DECLARE_TR_FUNCTIONS(FullColorBrushTool)
Toshihiro Shimizu 890ddd
bf1d82
  void updateCurrentStyle();
bf1d82
  double restartBrushTimer();
bf1d82
  void applyClassicToonzBrushSettings(mypaint::Brush &mypaintBrush);
bf1d82
  void applyToonzBrushSettings(mypaint::Brush &mypaintBrush);
shun_iwasawa e3df22
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FullColorBrushTool(std::string name);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  ToolType getToolType() const override { return TTool::LevelWriteTool; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  ToolOptionsBox *createOptionsBox() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void updateTranslation() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onActivate() override;
Shinya Kitaoka 473e70
  void onDeactivate() override;
Toshihiro Shimizu 890ddd
bf1d82
  bool askRead(const TRect &rect) override;
bf1d82
  bool askWrite(const TRect &rect) override;
bf1d82
Shinya Kitaoka 473e70
  bool preLeftButtonDown() override;
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
Shinya Kitaoka 473e70
  void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
Shinya Kitaoka 473e70
  void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void draw() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onEnter() override;
Shinya Kitaoka 473e70
  void onLeave() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int getCursorId() const override { return ToolCursor::PenCursor; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  TPropertyGroup *getProperties(int targetType) override;
Shinya Kitaoka 473e70
  bool onPropertyChanged(std::string propertyName) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onImageChanged() override;
Shinya Kitaoka 120a6e
  void setWorkAndBackupImages();
Shinya Kitaoka 120a6e
  void updateWorkAndBackupRasters(const TRect &rect);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void initPresets();
Shinya Kitaoka 120a6e
  void loadPreset();
Shinya Kitaoka 120a6e
  void addPreset(QString name);
Shinya Kitaoka 120a6e
  void removePreset();
Toshihiro Shimizu 890ddd
manongjohn df5842
  void loadLastBrush();
manongjohn df5842
Shinya Kitaoka 120a6e
  void onCanvasSizeChanged();
bf1d82
  void onColorStyleChanged();
bf1d82
shun-iwasawa 98926d
  TMyPaintBrushStyle *getBrushStyle();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TIntPairProperty m_thickness;
Shinya Kitaoka 120a6e
  TBoolProperty m_pressure;
Shinya Kitaoka 120a6e
  TDoublePairProperty m_opacity;
Shinya Kitaoka 120a6e
  TDoubleProperty m_hardness;
bf1d82
  TDoubleProperty m_modifierSize;
bf1d82
  TDoubleProperty m_modifierOpacity;
572ed1
  TBoolProperty m_modifierEraser;
572ed1
  TBoolProperty m_modifierLockAlpha;
Shinya Kitaoka 120a6e
  TEnumProperty m_preset;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPixel32 m_currentColor;
bf1d82
  bool m_enabledPressure;
bf1d82
  int m_minCursorThick, m_maxCursorThick;
Toshihiro Shimizu 890ddd
bf1d82
  TPointD m_mousePos,  //!< Current mouse position, in world coordinates.
shun-iwasawa 98926d
      m_brushPos;      //!< World position the brush will be painted at.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterP m_backUpRas;
Shinya Kitaoka 120a6e
  TRaster32P m_workRaster;
Toshihiro Shimizu 890ddd
bf1d82
  TRect m_strokeRect, m_strokeSegmentRect, m_lastRect;
Toshihiro Shimizu 890ddd
bf1d82
  MyPaintToonzBrush *m_toonz_brush;
bf1d82
  QElapsedTimer m_brushTimer;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TTileSetFullColor *m_tileSet;
Shinya Kitaoka 120a6e
  TTileSaverFullColor *m_tileSaver;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  BrushPresetManager
Shinya Kitaoka 120a6e
      m_presetsManager;  //!< Manager for presets of this tool instance
Shinya Kitaoka 120a6e
  FullColorBrushToolNotifier *m_notifier;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_presetsLoaded;
Shinya Kitaoka 120a6e
  bool m_firstTime;
Jeremy Bullock 5af997
  bool m_mousePressed = false;
Jeremy Bullock 5af997
  TMouseEvent m_mouseEvent;
manongjohn 5a2268
justburner e250b7
  bool m_isStraight = false;
justburner e250b7
  TPointD m_firstPoint;
justburner e250b7
  TPointD m_lastPoint;
justburner e250b7
  double m_maxPressure = -1.0;
justburner e250b7
manongjohn 5a2268
  bool m_propertyUpdating = false;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FullColorBrushToolNotifier final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FullColorBrushTool *m_tool;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FullColorBrushToolNotifier(FullColorBrushTool *tool);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Shinya Kitaoka 120a6e
  void onCanvasSizeChanged() { m_tool->onCanvasSizeChanged(); }
bf1d82
  void onColorStyleChanged() { m_tool->onColorStyleChanged(); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // FULLCOLORBRUSHTOOL_H