Blame synfig-studio/src/synfigapp/actions/layerpaint.h

9e9ccd
/* === S Y N F I G ========================================================= */
9e9ccd
/*!	\file layerpaint.h
9e9ccd
**	\brief Template File
9e9ccd
**
9e9ccd
**	$Id$
9e9ccd
**
9e9ccd
**	\legal
9e9ccd
**	......... ... 2014 Ivan Mahonin
9e9ccd
**
9e9ccd
**	This package is free software; you can redistribute it and/or
9e9ccd
**	modify it under the terms of the GNU General Public License as
9e9ccd
**	published by the Free Software Foundation; either version 2 of
9e9ccd
**	the License, or (at your option) any later version.
9e9ccd
**
9e9ccd
**	This package is distributed in the hope that it will be useful,
9e9ccd
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
9e9ccd
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9e9ccd
**	General Public License for more details.
9e9ccd
**	\endlegal
9e9ccd
*/
9e9ccd
/* ========================================================================= */
9e9ccd
9e9ccd
/* === S T A R T =========================================================== */
9e9ccd
9e9ccd
#ifndef __SYNFIG_APP_ACTION_LAYERPAINT_H
9e9ccd
#define __SYNFIG_APP_ACTION_LAYERPAINT_H
9e9ccd
9e9ccd
/* === H E A D E R S ======================================================= */
9e9ccd
0dde72
#include <synfig guid.h=""></synfig>
Diego Barrios Romero dcc14d
#include <synfig layer_bitmap.h="" layers=""></synfig>
0dde72
9e9ccd
#include <synfigapp action.h=""></synfigapp>
0dde72
f5e87b
#include <brushlib.h></brushlib.h>
9e9ccd
9e9ccd
/* === M A C R O S ========================================================= */
9e9ccd
9e9ccd
/* === T Y P E D E F S ===================================================== */
9e9ccd
9e9ccd
/* === C L A S S E S & S T R U C T S ======================================= */
9e9ccd
9e9ccd
namespace synfigapp {
9e9ccd
9e9ccd
class Instance;
9e9ccd
9e9ccd
namespace Action {
9e9ccd
9e9ccd
class LayerPaint :
9e9ccd
	public Undoable,
9e9ccd
	public CanvasSpecific
9e9ccd
{
f5e87b
public:
f5e87b
	struct PaintPoint {
f5e87b
		float x, y, pressure;
f5e87b
		double dtime;
f5e87b
		PaintPoint(): x(0), y(0), pressure(0), dtime(0) { }
f5e87b
		PaintPoint(float x, float y, float pressure, double dtime):
f5e87b
			x(x), y(y), pressure(pressure), dtime(dtime) { }
f5e87b
	};
9e9ccd
f5e87b
	class PaintStroke {
f5e87b
	private:
f5e87b
		static PaintStroke *first, *last;
0dde72
f5e87b
		PaintStroke *prev, *next;
f5e87b
		PaintStroke *prevSameLayer, *nextSameLayer;
9e9ccd
f5e87b
		etl::handle<synfig::layer_bitmap> layer;</synfig::layer_bitmap>
f5e87b
		brushlib::Brush brush_;
9e9ccd
f5e87b
		synfig::Surface surface;
f5e87b
		synfig::Point tl;
f5e87b
		synfig::Point br;
9e9ccd
f5e87b
		synfig::Point new_tl;
f5e87b
		synfig::Point new_br;
f5e87b
f5e87b
		std::vector<paintpoint> points;</paintpoint>
f5e87b
		bool prepared;
f5e87b
		bool applied;
f5e87b
f5e87b
		void paint_prev(synfig::Surface &surface);
f5e87b
		void paint_self(synfig::Surface &surface);
901e9f
		void reset(const PaintPoint &point);
f5e87b
f5e87b
	public:
f5e87b
		PaintStroke();
f5e87b
		~PaintStroke();
f5e87b
f5e87b
		void set_layer(etl::handle<synfig::layer_bitmap> layer) { assert(!prepared); this->layer = layer; }</synfig::layer_bitmap>
f5e87b
		etl::handle<synfig::layer_bitmap> get_layer() const { return layer; }</synfig::layer_bitmap>
f5e87b
f5e87b
		brushlib::Brush &brush() { assert(!prepared); return brush_; }
f5e87b
		const brushlib::Brush &get_brush() const { return brush_; }
f5e87b
f5e87b
		bool is_prepared() const { return prepared; }
f5e87b
f5e87b
		void prepare();
f5e87b
		void undo();
f5e87b
		void apply();
f5e87b
		void add_point_and_apply(const PaintPoint &point);
f5e87b
	};
f5e87b
0dde72
private:
0dde72
	synfig::GUID id;
0dde72
	bool applied;
0dde72
0dde72
public:
f5e87b
	PaintStroke stroke;
9e9ccd
9e9ccd
	LayerPaint();
9e9ccd
9e9ccd
	static ParamVocab get_param_vocab();
9e9ccd
	static bool is_candidate(const ParamList &x);
9e9ccd
9e9ccd
	virtual bool set_param(const synfig::String& name, const Param &);
9e9ccd
	virtual bool is_ready()const;
9e9ccd
9e9ccd
	virtual void perform();
9e9ccd
	virtual void undo();
9e9ccd
9e9ccd
	ACTION_MODULE_EXT
9e9ccd
};
9e9ccd
9e9ccd
}; // END of namespace action
9e9ccd
}; // END of namespace studio
9e9ccd
9e9ccd
/* === E N D =============================================================== */
9e9ccd
9e9ccd
#endif