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

# layer.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_H
    00027 #define __SYNFIG_LAYER_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030
    00031 #include "string_decl.h"
    00032 #include <map>
    00033 #include <ETL/handle>
    00034 #include "real.h"
    00035 #include "string.h"
    00036 #include <sigc++/signal.h>
    00037 #include <sigc++/connection.h>
    00038 #include "node.h"
    00039 #include "time.h"
    00040 #include "guid.h"
    00041
    00042 /* === M A C R O S ========================================================= */
    00043
    00045 #define SYNFIG_LAYER_MODULE_EXT                                                         \
    00046     public:                                                                             \
    00047     static const char name__[], version__[], cvs_id__[], local_name__[], category__[];  \
    00048     static Layer *create();
    00049
    00051 #define SYNFIG_LAYER_SET_NAME(class,x)                                                  \
    00052     const char class::name__[]=x
    00053
    00055 #define SYNFIG_LAYER_SET_LOCAL_NAME(class,x)                                            \
    00056     const char class::local_name__[]=x;
    00057
    00059 #define SYNFIG_LAYER_SET_CATEGORY(class,x)                                              \
    00060     const char class::category__[]=x
    00061
    00063 #define SYNFIG_LAYER_SET_VERSION(class,x)                                               \
    00064     const char class::version__[]=x
    00065
    00067 #define SYNFIG_LAYER_SET_CVS_ID(class,x)                                                \
    00068     const char class::cvs_id__[]=x
    00069
    00071 #define SYNFIG_LAYER_INIT(class)                                                        \
    00072     synfig::Layer* class::create()                                                      \
    00073     {                                                                                   \
    00074         return new class();                                                             \
    00075     }
    00076
    00078 #define IMPORT_PLUS(x,y)                                                                \
    00079     if (param==#x && value.same_type_as(x))                                             \
    00080     {                                                                                   \
    00081         value.put(&x);                                                                  \
    00082         {                                                                               \
    00083             y;                                                                          \
    00084         }                                                                               \
    00085         return true;                                                                    \
    00086     }
    00087
    00089 #define IMPORT_AS(x,y)                                                                  \
    00090     if (param==y && value.same_type_as(x))                                              \
    00091     {                                                                                   \
    00092         value.put(&x);                                                                  \
    00093         return true;                                                                    \
    00094     }
    00095
    00097 #define IMPORT(x)                                                                       \
    00098     IMPORT_AS(x,#x)
    00099
    00101 #define EXPORT_AS(x,y)                                                                  \
    00102     if (param==y)                                                                       \
    00103         return ValueBase(x);
    00104
    00106 #define EXPORT(x)                                                                       \
    00107     EXPORT_AS(x,#x)
    00108
    00110 #define EXPORT_NAME()                                                                   \
    00111     if (param=="Name" || param=="name" || param=="name__")                              \
    00112         return name__;                                                                  \
    00113     else if (param=="local_name__")                                                     \
    00114         return dgettext("synfig",local_name__);
    00115
    00117 #define EXPORT_VERSION()                                                                \
    00118     if (param=="Version" || param=="version" || param=="version__")                     \
    00119         return version__;
    00120
    00123 #define CATEGORY_DO_NOT_USE "Do Not Use"
    00124
    00125 /* === T Y P E D E F S ===================================================== */
    00126
    00127 /* === C L A S S E S & S T R U C T S ======================================= */
    00128
    00129 namespace synfig {
    00130
    00131 class Canvas;
    00132 class Vector;
    00133 typedef Vector Point;
    00134 class Canvas;
    00135 class ParamDesc;
    00136 class ParamVocab;
    00137 class ValueNode;
    00138 class ValueBase;
    00139 class Time;
    00140 class Surface;
    00141 class RendDesc;
    00142 class ProgressCallback;
    00143 class Context;
    00144 class Color;
    00145 class Transform;
    00146 class Rect;
    00147 class GUID;
    00148
    00149
    00154 class Layer : public Node
    00155 {
    00156     friend class ValueNode;
    00157     friend class Context;
    00158
    00159     /*
    00160  -- ** -- T Y P E S -----------------------------------------------------------
    00161     */
    00162
    00163 public:
    00164
    00166     typedef Layer* (*Factory)();
    00167
    00168     struct BookEntry
    00169     {
    00170         Factory factory;
    00171         String name;
    00172         String local_name;
    00173         String category;
    00174         String cvs_id;
    00175         String version;
    00176         BookEntry() { }
    00177         BookEntry(Factory        factory,
    00178                   const String  &name,
    00179                   const String  &local_name,
    00180                   const String  &category,
    00181                   const String  &cvs_id,
    00182                   const String  &version):
    00183             factory(factory),
    00184             name(name),
    00185             local_name(local_name),
    00186             category(category),
    00187             cvs_id(cvs_id),
    00188             version(version) { }
    00189     };
    00190
    00191     typedef std::map<String,BookEntry> Book;
    00192
    00193     static void register_in_book(const BookEntry &);
    00194
    00195     static Book& book();
    00196
    00197     static bool subsys_init();
    00198
    00199     static bool subsys_stop();
    00200
    00201     typedef std::map<String,ValueBase> ParamList;
    00202
    00203     typedef etl::handle<Layer> Handle;
    00204
    00205     typedef etl::loose_handle<Layer> LooseHandle;
    00206
    00207     typedef etl::handle<const Layer> ConstHandle;
    00208
    00209     typedef std::map<String,etl::rhandle<ValueNode> > DynamicParamList;
    00210
    00212
    00213     typedef ParamVocab Vocab;
    00214
    00215     /*
    00216  -- ** -- D A T A -------------------------------------------------------------
    00217     */
    00218
    00219 private:
    00220
    00224     bool active_;
    00225
    00227     etl::loose_handle<Canvas> canvas_;
    00228
    00229     DynamicParamList dynamic_param_list_;
    00230
    00232     String description_;
    00233
    00235     float z_depth_;
    00236
    00238     mutable Time dirty_time_;
    00239
    00241     String group_;
    00242
    00244     sigc::connection parent_death_connect_;
    00245
    00246     /*
    00247  -- ** -- S I G N A L S -------------------------------------------------------
    00248     */
    00249
    00250 private:
    00251
    00253     sigc::signal<void> signal_status_changed_;
    00254
    00256     sigc::signal<void,String> signal_param_changed_;
    00257
    00259     sigc::signal<void> signal_description_changed_;
    00260
    00262     sigc::signal<void, int, etl::handle<Canvas> > signal_moved_;
    00263
    00264     sigc::signal<void, String> signal_added_to_group_;
    00265
    00266     sigc::signal<void, String> signal_removed_from_group_;
    00267
    00268     /*
    00269  -- ** -- S I G N A L   I N T E R F A C E -------------------------------------
    00270     */
    00271
    00272 public:
    00273
    00275     sigc::signal<void>& signal_status_changed() { return signal_status_changed_; }
    00276
    00278     sigc::signal<void,String>& signal_param_changed() { return signal_param_changed_; }
    00279
    00281     sigc::signal<void>& signal_description_changed() { return signal_description_changed_;}
    00282
    00284     sigc::signal<void, int, etl::handle<Canvas> >& signal_moved() { return signal_moved_; }
    00285
    00286     sigc::signal<void, String>& signal_added_to_group() { return signal_added_to_group_; }
    00287
    00288     sigc::signal<void, String>& signal_removed_from_group() { return signal_removed_from_group_; }
    00289
    00290     /*
    00291  -- ** -- C O N S T R U C T O R S ---------------------------------------------
    00292     */
    00293
    00294 protected:
    00295
    00296     Layer();
    00297
    00298 public:
    00299     virtual ~Layer();
    00300
    00301     /*
    00302  -- ** -- M E M B E R   F U N C T I O N S -------------------------------------
    00303     */
    00304
    00305 public:
    00306
    00307     virtual void on_canvas_set();
    00308
    00310     void add_to_group(const String&);
    00311
    00313     void remove_from_group(const String&);
    00314
    00316     void remove_from_all_groups();
    00317
    00319     String get_group()const;
    00320
    00322     //DynamicParamList &dynamic_param_list() { return dynamic_param_list_; }
    00323
    00325     const DynamicParamList &dynamic_param_list()const { return dynamic_param_list_; }
    00326
    00327     bool connect_dynamic_param(const String& param, etl::loose_handle<ValueNode>);
    00328     bool disconnect_dynamic_param(const String& param);
    00329
    00331     void enable() { set_active(true); }
    00332
    00334
    00336     void disable() { set_active(false); }
    00337
    00339
    00341     void set_active(bool x);
    00342
    00344     bool active()const { return active_; }
    00345
    00347
    00348     int get_depth()const;
    00349
    00351     float get_z_depth()const { return z_depth_; }
    00352
    00354     float get_z_depth(const synfig::Time& t)const;
    00355
    00357     void set_z_depth(float x) { z_depth_=x; }
    00358
    00360     void set_canvas(etl::loose_handle<Canvas> canvas);
    00361
    00363     etl::loose_handle<Canvas> get_canvas()const;
    00364
    00366     const String& get_description()const { return description_; }
    00367
    00369     void set_description(const String& x);
    00370
    00372     const String get_non_empty_description()const { return get_description().empty() ? get_local_name() : get_description(); }
    00373
    00375     const String get_param_local_name(const String &param_name)const;
    00376
    00377     /*
    00378  -- ** -- V I R T U A L   F U N C T I O N S -----------------------------------
    00379     */
    00380
    00381 public:
    00382     virtual Rect get_bounding_rect()const;
    00383
    00384     virtual Rect get_full_bounding_rect(Context context)const;
    00385
    00387     virtual String get_name()const;
    00388
    00390     virtual String get_local_name()const;
    00391
    00393     virtual Vocab get_param_vocab()const;
    00394
    00396     virtual String get_version()const;
    00397
    00399     virtual etl::handle<Transform> get_transform()const;
    00400
    00402
    00404     virtual bool set_version(const String &ver);
    00405
    00407
    00409     virtual void reset_version();
    00410
    00412
    00419     virtual bool set_param(const String &param, const ValueBase &value);
    00420
    00422     virtual bool set_param_list(const ParamList &);
    00423
    00425
    00429     virtual ValueBase get_param(const String &param)const;
    00430
    00432     virtual ParamList get_param_list()const;
    00433
    00435
    00439     virtual void set_time(Context context, Time time)const;
    00440
    00442
    00447     virtual void set_time(Context context, Time time, const Point &point)const;
    00448
    00450
    00454     virtual Color get_color(Context context, const Point &pos)const;
    00455
    00457
    00465     virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
    00466
    00468
    00472     virtual Handle hit_check(Context context, const Point &point)const;
    00473
    00475     virtual Handle clone(const GUID& deriv_guid=GUID())const;
    00476
    00478
    00483     virtual bool reads_context()const;
    00484
    00486     virtual Handle simple_clone()const;
    00487
    00488 protected:
    00489
    00491     virtual void on_changed();
    00492
    00494     virtual void get_times_vfunc(Node::time_set &set) const;
    00495
    00496     /*
    00497  -- ** -- S T A T I C  F U N C T I O N S --------------------------------------
    00498     */
    00499
    00500 public:
    00501
    00503
    00508     static Layer::LooseHandle create(const String &type);
    00509
    00510 }; // END of class Layer
    00511
    00512 }; // END of namespace synfig
    00513
    00514
    00515 /* === E N D =============================================================== */
    00516
    00517 #endif