Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FULLCOLORBRUSHTOOL_H
Toshihiro Shimizu 890ddd
#define FULLCOLORBRUSHTOOL_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "brushtool.h"
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;
Toshihiro Shimizu 890ddd
class BluredBrush;
Toshihiro Shimizu 890ddd
class FullColorBrushToolNotifier;
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
Toshihiro Shimizu 890ddd
class FullColorBrushTool : public TTool
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_DECLARE_TR_FUNCTIONS(FullColorBrushTool)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 3bfa54
	FullColorBrushTool(std::string name);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolType getToolType() const { return TTool::LevelWriteTool; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolOptionsBox *createOptionsBox();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateTranslation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onActivate();
Toshihiro Shimizu 890ddd
	void onDeactivate();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool preLeftButtonDown();
Toshihiro Shimizu 890ddd
	void leftButtonDown(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
	void leftButtonDrag(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
	void leftButtonUp(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
	void mouseMove(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onEnter();
Toshihiro Shimizu 890ddd
	void onLeave();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getCursorId() const { return ToolCursor::PenCursor; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPropertyGroup *getProperties(int targetType);
Shinya Kitaoka 3bfa54
	bool onPropertyChanged(std::string propertyName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onImageChanged();
Toshihiro Shimizu 890ddd
	void setWorkAndBackupImages();
Toshihiro Shimizu 890ddd
	void updateWorkAndBackupRasters(const TRect &rect);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void initPresets();
Toshihiro Shimizu 890ddd
	void loadPreset();
Toshihiro Shimizu 890ddd
	void addPreset(QString name);
Toshihiro Shimizu 890ddd
	void removePreset();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onCanvasSizeChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TIntPairProperty m_thickness;
Toshihiro Shimizu 890ddd
	TBoolProperty m_pressure;
Toshihiro Shimizu 890ddd
	TDoublePairProperty m_opacity;
Toshihiro Shimizu 890ddd
	TDoubleProperty m_hardness;
Toshihiro Shimizu 890ddd
	TEnumProperty m_preset;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixel32 m_currentColor;
Toshihiro Shimizu 890ddd
	int m_styleId,
Toshihiro Shimizu 890ddd
		m_minThick,
Toshihiro Shimizu 890ddd
		m_maxThick;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double m_oldOpacity;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD m_dpiScale,
Toshihiro Shimizu 890ddd
		m_mousePos, //!< Current mouse position, in world coordinates.
Toshihiro Shimizu 890ddd
		m_brushPos; //!< World position the brush will be painted at.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP m_backUpRas;
Toshihiro Shimizu 890ddd
	TRaster32P m_workRaster;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRect m_strokeRect,
Toshihiro Shimizu 890ddd
		m_lastRect;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QRadialGradient m_brushPad;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
	std::vector<tthickpoint> m_points;</tthickpoint>
Toshihiro Shimizu 890ddd
	BluredBrush *m_brush;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TTileSetFullColor *m_tileSet;
Toshihiro Shimizu 890ddd
	TTileSaverFullColor *m_tileSaver;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	BrushPresetManager m_presetsManager; //!< Manager for presets of this tool instance
Toshihiro Shimizu 890ddd
	FullColorBrushToolNotifier *m_notifier;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_presetsLoaded;
Toshihiro Shimizu 890ddd
	bool m_firstTime;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FullColorBrushToolNotifier : public QObject
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FullColorBrushTool *m_tool;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FullColorBrushToolNotifier(FullColorBrushTool *tool);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onCanvasSizeChanged() { m_tool->onCanvasSizeChanged(); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif //FULLCOLORBRUSHTOOL_H