1 | /* === S Y N F I G ========================================================= */ |
---|
2 | /*! \file layerpaint.h |
---|
3 | ** \brief Template File |
---|
4 | ** |
---|
5 | ** $Id$ |
---|
6 | ** |
---|
7 | ** \legal |
---|
8 | ** ......... ... 2014 Ivan Mahonin |
---|
9 | ** |
---|
10 | ** This package is free software; you can redistribute it and/or |
---|
11 | ** modify it under the terms of the GNU General Public License as |
---|
12 | ** published by the Free Software Foundation; either version 2 of |
---|
13 | ** the License, or (at your option) any later version. |
---|
14 | ** |
---|
15 | ** This package is distributed in the hope that it will be useful, |
---|
16 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | ** General Public License for more details. |
---|
19 | ** \endlegal |
---|
20 | */ |
---|
21 | /* ========================================================================= */ |
---|
22 | |
---|
23 | /* === S T A R T =========================================================== */ |
---|
24 | |
---|
25 | #ifndef __SYNFIG_APP_ACTION_LAYERPAINT_H |
---|
26 | #define __SYNFIG_APP_ACTION_LAYERPAINT_H |
---|
27 | |
---|
28 | /* === H E A D E R S ======================================================= */ |
---|
29 | |
---|
30 | #include <synfig/layers/layer_bitmap.h> |
---|
31 | #include <synfigapp/action.h> |
---|
32 | #include <brushlib.h> |
---|
33 | |
---|
34 | /* === M A C R O S ========================================================= */ |
---|
35 | |
---|
36 | /* === T Y P E D E F S ===================================================== */ |
---|
37 | |
---|
38 | /* === C L A S S E S & S T R U C T S ======================================= */ |
---|
39 | |
---|
40 | namespace synfigapp { |
---|
41 | |
---|
42 | class Instance; |
---|
43 | |
---|
44 | namespace Action { |
---|
45 | |
---|
46 | class LayerPaint : |
---|
47 | public Undoable, |
---|
48 | public CanvasSpecific |
---|
49 | { |
---|
50 | public: |
---|
51 | struct PaintPoint { |
---|
52 | float x, y, pressure; |
---|
53 | double dtime; |
---|
54 | PaintPoint(): x(0), y(0), pressure(0), dtime(0) { } |
---|
55 | PaintPoint(float x, float y, float pressure, double dtime): |
---|
56 | x(x), y(y), pressure(pressure), dtime(dtime) { } |
---|
57 | }; |
---|
58 | |
---|
59 | class PaintStroke { |
---|
60 | private: |
---|
61 | static PaintStroke *first, *last; |
---|
62 | PaintStroke *prev, *next; |
---|
63 | PaintStroke *prevSameLayer, *nextSameLayer; |
---|
64 | |
---|
65 | etl::handle<synfig::Layer_Bitmap> layer; |
---|
66 | brushlib::Brush brush_; |
---|
67 | |
---|
68 | synfig::Surface surface; |
---|
69 | synfig::Point tl; |
---|
70 | synfig::Point br; |
---|
71 | |
---|
72 | synfig::Point new_tl; |
---|
73 | synfig::Point new_br; |
---|
74 | |
---|
75 | std::vector<PaintPoint> points; |
---|
76 | bool prepared; |
---|
77 | bool applied; |
---|
78 | |
---|
79 | void copy_to_cairo_surface(const synfig::Surface &surface, synfig::CairoSurface &csurface); |
---|
80 | void paint_prev(synfig::Surface &surface); |
---|
81 | void paint_self(synfig::Surface &surface); |
---|
82 | void reset(const PaintPoint &point); |
---|
83 | |
---|
84 | public: |
---|
85 | PaintStroke(); |
---|
86 | ~PaintStroke(); |
---|
87 | |
---|
88 | void set_layer(etl::handle<synfig::Layer_Bitmap> layer) { assert(!prepared); this->layer = layer; } |
---|
89 | etl::handle<synfig::Layer_Bitmap> get_layer() const { return layer; } |
---|
90 | |
---|
91 | brushlib::Brush &brush() { assert(!prepared); return brush_; } |
---|
92 | const brushlib::Brush &get_brush() const { return brush_; } |
---|
93 | |
---|
94 | bool is_prepared() const { return prepared; } |
---|
95 | |
---|
96 | void prepare(); |
---|
97 | void undo(); |
---|
98 | void apply(); |
---|
99 | void add_point_and_apply(const PaintPoint &point); |
---|
100 | }; |
---|
101 | |
---|
102 | PaintStroke stroke; |
---|
103 | |
---|
104 | LayerPaint(); |
---|
105 | |
---|
106 | static ParamVocab get_param_vocab(); |
---|
107 | static bool is_candidate(const ParamList &x); |
---|
108 | |
---|
109 | virtual bool set_param(const synfig::String& name, const Param &); |
---|
110 | virtual bool is_ready()const; |
---|
111 | |
---|
112 | virtual void perform(); |
---|
113 | virtual void undo(); |
---|
114 | |
---|
115 | ACTION_MODULE_EXT |
---|
116 | }; |
---|
117 | |
---|
118 | }; // END of namespace action |
---|
119 | }; // END of namespace studio |
---|
120 | |
---|
121 | /* === E N D =============================================================== */ |
---|
122 | |
---|
123 | #endif |
---|