1 /* === S Y N F I G ========================================================= */
2 /*! \file layer_pastecanvas.h
3 ** \brief Header file for implementation of the "Paste Canvas" layer
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_LAYER_PASTEIMAGE_H
27 #define __SYNFIG_LAYER_PASTEIMAGE_H
29 /* === H E A D E R S ======================================================= */
31 #include "layer_composite.h"
36 #include "canvasbase.h"
40 /* === M A C R O S ========================================================= */
42 /* === T Y P E D E F S ===================================================== */
44 /* === C L A S S E S & S T R U C T S ======================================= */
47 /*! \class Layer_PasteCanvas
48 ** \brief Class of the Pasted Canvas layer.
50 class Layer_PasteCanvas : public Layer_Composite, public Layer_NoDeform
52 //! Layer module: defines the needed members to belong to a layer's factory.
53 SYNFIG_LAYER_MODULE_EXT
55 //! Parameter Origin of the paste canvas layer
57 //!Parameter Focus of the zoom of the paste canvas layer
59 //! The canvas parameter
60 etl::loose_handle<synfig::Canvas> canvas;
61 //! Recursion depth counter. Not a parameter
63 //! Zoom parameter of the paste canvas layer
65 //! Time offset parameter of the paste canvas layer
67 //! Current time of the paste canvas layer. \see set_time
68 mutable Time curr_time;
69 //! \todo writeme! Not a parameter
71 //! Parameter that avoid hit check to go depth into the children.
73 //! Boundaries of the paste canvas layer. It is the canvas's boundary
74 //! affected by the zoom, origin and focus.
76 //! signal connection for children. Seems to be used only here
77 sigc::connection child_changed_connection;
79 // Nasty hack: Remember whether we called an extra ref() when
80 // setting the canvas, so we know whether to call an extra unref()
81 // when finished with the canvas.
85 // The root canvas is destructed first. That sets the
86 // Layer::canvas_ (the parent canvas) of any PasteCanvas layer it
87 // contains to nil, due to a call to Layer::set_canvas(0),
88 // triggered by the connection made when Layer::set_canvas
89 // originally set its canvas_ member to point to the root canvas.
90 // ~Canvas does begin_delete() which triggers that connection.
92 // After ~Canvas has run, the members of the root canvas are
93 // freed, including its children_ list. If this was the last
94 // reference to the child canvas that the pastecanvas uses, that
95 // child canvas will Layer_PasteCanvas::set_sub_canvas(0) on the
96 // PasteCanvas layer to set its canvas (the child, pasted canvas)
97 // not to refer to the soon-to-be destroys child canvas. But
98 // set_sub_canvas() originally looked at the value of
99 // Layer::canvas_ (the parent canvas, obtained via
100 // Layer::get_canvas()) to decide whether to do an extra ref() on
101 // canvas (the child canvas). We need to unref() it now if we
102 // did, but we've forgotten whether we did. So we use this
103 // 'extra_reference' member to store that decision.
104 bool extra_reference;
107 -- ** -- S I G N A L S -------------------------------------------------------
111 //! Signal used when the canvas parameter has changed. \see layertreestore.cpp
112 sigc::signal<void> signal_subcanvas_changed_;
115 -- ** -- S I G N A L I N T E R F A C E -------------------------------------
119 //! Wrapper for the subcanvas changed signal
120 sigc::signal<void>& signal_subcanvas_changed() { return signal_subcanvas_changed_; }
124 void update_renddesc();
126 virtual void on_canvas_set();
128 void set_muck_with_time(bool x=false) { muck_with_time_=x; }
130 etl::handle<synfig::Canvas> get_sub_canvas()const { return canvas; }
131 void set_sub_canvas(etl::handle<synfig::Canvas> x);
133 Real get_zoom()const { return zoom; }
135 Time get_time_offset()const { return time_offset; }
137 Point get_origin()const { return origin; }
140 virtual ~Layer_PasteCanvas();
142 virtual String get_local_name()const;
144 virtual bool set_param(const String & param, const synfig::ValueBase &value);
146 virtual ValueBase get_param(const String & param)const;
148 virtual Color get_color(Context context, const Point &pos)const;
150 virtual void set_time(Context context, Time time)const;
152 virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
154 virtual Vocab get_param_vocab()const;
156 virtual synfig::Rect get_bounding_rect()const;
158 virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
161 virtual void get_times_vfunc(Node::time_set &set) const;
163 }; // END of class Layer_PasteCanvas
165 }; // END of namespace synfig
167 /* === E N D =============================================================== */