- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# layer_pastecanvas.h

Go to the documentation of this file.

    00001 /* === S Y N F I G ========================================================= */
    00022 /* ========================================================================= */
    00023
    00024 /* === S T A R T =========================================================== */
    00025
    00026 #ifndef __SYNFIG_LAYER_PASTEIMAGE_H
    00027 #define __SYNFIG_LAYER_PASTEIMAGE_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030
    00031 #include "layer_composite.h"
    00032 #include "color.h"
    00033 #include "vector.h"
    00034 #include "real.h"
    00035 #include "time.h"
    00036 #include "canvasbase.h"
    00037 #include "canvas.h"
    00038 #include "rect.h"
    00039
    00040 /* === M A C R O S ========================================================= */
    00041
    00042 /* === T Y P E D E F S ===================================================== */
    00043
    00044 /* === C L A S S E S & S T R U C T S ======================================= */
    00045
    00046 namespace synfig {
    00047
    00048 class Layer_PasteCanvas : public Layer_Composite, public Layer_NoDeform
    00049 {
    00050     SYNFIG_LAYER_MODULE_EXT
    00051 private:
    00052
    00053     Vector origin;
    00054     Vector focus;
    00055
    00056     etl::loose_handle<synfig::Canvas> canvas;
    00057
    00059     mutable int depth;
    00060
    00061     Real zoom;
    00062
    00063     Time time_offset;
    00064
    00065     mutable Time curr_time;
    00066
    00067     bool muck_with_time_;
    00068
    00069     bool children_lock;
    00070
    00071     mutable Rect bounds;
    00072
    00073     sigc::connection child_changed_connection;
    00074
    00075     // Nasty hack: Remember whether we called an extra ref() when
    00076     // setting the canvas, so we know whether to call an extra unref()
    00077     // when finished with the canvas.
    00078     //
    00079     // Here's the story:
    00080     //
    00081     // The root canvas is destructed first.  That sets the
    00082     // Layer::canvas_ (the parent canvas) of any PasteCanvas layer it
    00083     // contains to nil, due to a call to Layer::set_canvas(0),
    00084     // triggered by the connection made when Layer::set_canvas
    00085     // originally set its canvas_ member to point to the root canvas.
    00086     // ~Canvas does begin_delete() which triggers that connection.
    00087     //
    00088     // After ~Canvas has run, the members of the root canvas are
    00089     // freed, including its children_ list.  If this was the last
    00090     // reference to the child canvas that the pastecanvas uses, that
    00091     // child canvas will Layer_PasteCanvas::set_sub_canvas(0) on the
    00092     // PasteCanvas layer to set its canvas (the child, pasted canvas)
    00093     // not to refer to the soon-to-be destroys child canvas.  But
    00094     // set_sub_canvas() originally looked at the value of
    00095     // Layer::canvas_ (the parent canvas, obtained via
    00096     // Layer::get_canvas()) to decide whether to do an extra ref() on
    00097     // canvas (the child canvas).  We need to unref() it now if we
    00098     // did, but we've forgotten whether we did.  So we use this
    00099     // 'extra_reference' member to store that decision.
    00100     bool extra_reference;
    00101
    00102     /*
    00103  -- ** -- S I G N A L S -------------------------------------------------------
    00104     */
    00105
    00106 private:
    00107
    00108     sigc::signal<void> signal_subcanvas_changed_;
    00109
    00110     /*
    00111  -- ** -- S I G N A L   I N T E R F A C E -------------------------------------
    00112     */
    00113
    00114 public:
    00115
    00116     sigc::signal<void>& signal_subcanvas_changed() { return signal_subcanvas_changed_; }
    00117
    00118 public:
    00119
    00120     void update_renddesc();
    00121
    00122     virtual void on_canvas_set();
    00123
    00124     void set_muck_with_time(bool x=false) { muck_with_time_=x; }
    00125
    00126     etl::handle<synfig::Canvas> get_sub_canvas()const { return canvas; }
    00127     void set_sub_canvas(etl::handle<synfig::Canvas> x);
    00128
    00129     Real get_zoom()const { return zoom; }
    00130
    00131     Time get_time_offset()const { return time_offset; }
    00132
    00133     Point get_origin()const { return origin; }
    00134
    00135     Layer_PasteCanvas();
    00136     virtual ~Layer_PasteCanvas();
    00137
    00138     virtual String get_local_name()const;
    00139
    00140     virtual bool set_param(const String & param, const synfig::ValueBase &value);
    00141
    00142     virtual ValueBase get_param(const String & param)const;
    00143
    00144     virtual Color get_color(Context context, const Point &pos)const;
    00145
    00146     virtual void set_time(Context context, Time time)const;
    00147
    00148     virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
    00149
    00150     virtual Vocab get_param_vocab()const;
    00151
    00152     virtual synfig::Rect get_bounding_rect()const;
    00153
    00154     virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
    00155
    00156 protected:
    00157     virtual void get_times_vfunc(Node::time_set &set) const;
    00158
    00159 }; // END of class Layer_PasteCanvas
    00160
    00161 }; // END of namespace synfig
    00162
    00163 /* === E N D =============================================================== */
    00164
    00165 #endif