synfig-core  1.0.3
layer_pastecanvas.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
23 /* ========================================================================= */
24 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __SYNFIG_LAYER_PASTECANVAS_H
28 #define __SYNFIG_LAYER_PASTECANVAS_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #include "layer_composite.h"
33 #include <synfig/color.h>
34 #include <synfig/vector.h>
35 #include <synfig/real.h>
36 #include <synfig/time.h>
37 #include <synfig/canvasbase.h>
38 #include <synfig/canvas.h>
39 #include <synfig/rect.h>
40 #include <synfig/transformation.h>
41 
42 /* === M A C R O S ========================================================= */
43 
44 /* === T Y P E D E F S ===================================================== */
45 
46 /* === C L A S S E S & S T R U C T S ======================================= */
47 
48 namespace synfig {
53 {
54 private:
56  ValueBase param_origin;
58  ValueBase param_transformation;
60  etl::loose_handle<synfig::Canvas> canvas;
62  ValueBase param_time_dilation;
64  ValueBase param_time_offset;
66  ValueBase param_outline_grow;
68  ValueBase param_children_lock;
70  mutable ValueBase param_curr_time;
71 
73  bool muck_with_time_;
75  mutable int depth;
76 
79  mutable Rect bounds;
81  sigc::connection child_changed_connection;
82 
83  // Nasty hack: Remember whether we called an extra ref() when
84  // setting the canvas, so we know whether to call an extra unref()
85  // when finished with the canvas.
86  //
87  // Here's the story:
88  //
89  // The root canvas is destructed first. That sets the
90  // Layer::canvas_ (the parent canvas) of any PasteCanvas layer it
91  // contains to nil, due to a call to Layer::set_canvas(0),
92  // triggered by the connection made when Layer::set_canvas
93  // originally set its canvas_ member to point to the root canvas.
94  // ~Canvas does begin_delete() which triggers that connection.
95  //
96  // After ~Canvas has run, the members of the root canvas are
97  // freed, including its children_ list. If this was the last
98  // reference to the child canvas that the pastecanvas uses, that
99  // child canvas will Layer_PasteCanvas::set_sub_canvas(0) on the
100  // PasteCanvas layer to set its canvas (the child, pasted canvas)
101  // not to refer to the soon-to-be destroys child canvas. But
102  // set_sub_canvas() originally looked at the value of
103  // Layer::canvas_ (the parent canvas, obtained via
104  // Layer::get_canvas()) to decide whether to do an extra ref() on
105  // canvas (the child canvas). We need to unref() it now if we
106  // did, but we've forgotten whether we did. So we use this
107  // 'extra_reference' member to store that decision.
108  bool extra_reference;
109 
110  /*
111  -- ** -- S I G N A L S -------------------------------------------------------
112  */
113 
114 private:
116  sigc::signal<void> signal_subcanvas_changed_;
117 
118  /*
119  -- ** -- S I G N A L I N T E R F A C E -------------------------------------
120  */
121 
122 public:
124  sigc::signal<void>& signal_subcanvas_changed() { return signal_subcanvas_changed_; }
125 
126 public:
127 
130  void update_renddesc();
131 
135  virtual void on_canvas_set();
138  void set_muck_with_time(bool x=false) { muck_with_time_=x; }
139 
142  etl::handle<synfig::Canvas> get_sub_canvas()const { return canvas; }
145  void set_sub_canvas(etl::handle<synfig::Canvas> x);
147  Real get_time_dilation()const { return param_time_dilation.get(Real()); }
149  Time get_time_offset()const { return param_time_offset.get(Time()); }
150 
152  Point get_origin()const { return param_origin.get(Point()); }
154  Transformation get_transformation()const { return param_transformation.get(Transformation()); }
157  {
159  }
160 
164  virtual ~Layer_PasteCanvas();
166  virtual String get_local_name()const;
168  virtual bool set_param(const String & param, const synfig::ValueBase &value);
170  virtual ValueBase get_param(const String & param)const;
172  virtual void apply_z_range_to_params(ContextParams &cp)const;
174  virtual Color get_color(Context context, const Point &pos)const;
176  virtual void set_time(IndependentContext context, Time time)const;
179  virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
180  virtual bool accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
182  Rect get_bounding_rect_context_dependent(const ContextParams &context_params)const;
185  virtual Rect get_full_bounding_rect(Context context)const;
187  virtual Vocab get_param_vocab()const;
189  virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
190  virtual void set_render_method(Context context, RenderMethod x);
191 
192  virtual void fill_sound_processor(SoundProcessor &soundProcessor) const;
193 
194 protected:
199  virtual void get_times_vfunc(Node::time_set &set) const;
200 
201 }; // END of class Layer_PasteCanvas
202 
203 }; // END of namespace synfig
204 
205 /* === E N D =============================================================== */
206 
207 #endif