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
d8eddc
#include <tools inputmanager.h=""></tools>
shun-iwasawa ec85ad
#ifndef NDEBUG
d8eddc
#include <tools modifiers="" modifiertest.h=""></tools>
shun-iwasawa ec85ad
#endif
7a5892
#include <tools modifierline.h="" modifiers=""></tools>
d8eddc
#include <tools modifiers="" modifiertangents.h=""></tools>
362052
#include <tools modifierassistants.h="" modifiers=""></tools>
d8eddc
#include <tools modifiers="" modifiersegmentation.h=""></tools>
d8eddc
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
shun-iwasawa ec85ad
class FullColorBrushTool final : public TTool,
shun-iwasawa ec85ad
                                 public RasterController,
shun-iwasawa ec85ad
                                 public TInputHandler {
Shinya Kitaoka 120a6e
  Q_DECLARE_TR_FUNCTIONS(FullColorBrushTool)
7a5892
public:
shun-iwasawa ec85ad
  class TrackHandler : public TTrackToolHandler {
7a5892
  public:
7a5892
    MyPaintToonzBrush brush;
7a5892
shun-iwasawa ec85ad
    TrackHandler(const TRaster32P &ras, RasterController &controller,
shun-iwasawa ec85ad
                 const mypaint::Brush &brush)
shun-iwasawa ec85ad
        : brush(ras, controller, brush) {}
7a5892
  };
Toshihiro Shimizu 890ddd
7a5892
private:
bf1d82
  void updateCurrentStyle();
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
shun-iwasawa ec85ad
  void inputMouseMove(const TPointD &position,
shun-iwasawa ec85ad
                      const TInputState &state) override;
7a5892
  void inputSetBusy(bool busy) override;
shun-iwasawa ec85ad
  void inputPaintTrackPoint(const TTrackPoint &point, const TTrack &track,
shun-iwasawa ec85ad
                            bool firstTrack) override;
00337d
  void inputInvalidateRect(const TRectD &bounds) override;
shun-iwasawa ec85ad
  TTool *inputGetTool() override { return this; };
d8eddc
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
d8eddc
private:
d8eddc
  enum MouseEventType { ME_DOWN, ME_DRAG, ME_UP, ME_MOVE };
shun-iwasawa ec85ad
  void handleMouseEvent(MouseEventType type, const TPointD &pos,
shun-iwasawa ec85ad
                        const TMouseEvent &e);
shun-iwasawa ec85ad
Toshihiro Shimizu 890ddd
protected:
d8eddc
  TInputManager m_inputmanager;
shun-iwasawa ec85ad
#ifndef NDEBUG
d8eddc
  TSmartPointerT<tmodifiertest> m_modifierTest;</tmodifiertest>
shun-iwasawa ec85ad
#endif
7a5892
  TSmartPointerT<tmodifierline> m_modifierLine;</tmodifierline>
d8eddc
  TSmartPointerT<tmodifiertangents> m_modifierTangents;</tmodifiertangents>
362052
  TSmartPointerT<tmodifierassistants> m_modifierAssistants;</tmodifierassistants>
d8eddc
  TSmartPointerT<tmodifiersegmentation> m_modifierSegmentation;</tmodifiersegmentation>
shun-iwasawa ec85ad
Shinya Kitaoka 120a6e
  TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
shun-iwasawa ec85ad
  TIntPairProperty m_thickness;
shun-iwasawa ec85ad
  TBoolProperty m_pressure;
Shinya Kitaoka 120a6e
  TDoublePairProperty m_opacity;
shun-iwasawa ec85ad
  TDoubleProperty m_hardness;
shun-iwasawa ec85ad
  TDoubleProperty m_modifierSize;
shun-iwasawa ec85ad
  TDoubleProperty m_modifierOpacity;
shun-iwasawa ec85ad
  TBoolProperty m_modifierEraser;
shun-iwasawa ec85ad
  TBoolProperty m_modifierLockAlpha;
shun-iwasawa ec85ad
  TBoolProperty m_assistants;
shun-iwasawa ec85ad
  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
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;
manongjohn 5a2268
7a5892
  bool m_started;
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);
shun-iwasawa ec85ad
  void onActivate();
shun-iwasawa ec85ad
  void onDeactivate();
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