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

# canvasinterface.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_APP_CANVASINTERFACE_H
    00027 #define __SYNFIG_APP_CANVASINTERFACE_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030
    00031 //#include <synfig/canvas.h>
    00032 #include <synfig/value.h>
    00033 #include <sigc++/signal.h>
    00034 #include <sigc++/object.h>
    00035 #include <list>
    00036 #include "selectionmanager.h"
    00037 #include "uimanager.h"
    00038 #include "value_desc.h"
    00039 #include "editmode.h"
    00040
    00041 /* === M A C R O S ========================================================= */
    00042
    00043 /* === T Y P E D E F S ===================================================== */
    00044
    00045 /* === C L A S S E S & S T R U C T S ======================================= */
    00046
    00047 namespace synfig { class ValueNode_DynamicList; class Waypoint; class GUIDSet; class Canvas; };
    00048
    00049 namespace synfigapp {
    00050
    00051 namespace Action { class ParamList; class Param; class EditModeSet; };
    00052
    00053 class Instance;
    00054 class ValueDesc;
    00055
    00056 class CanvasInterface : public etl::shared_object, public sigc::trackable
    00057 {
    00058     friend class Instance;
    00059     friend class Action::EditModeSet;
    00060
    00061 public:
    00062
    00063     typedef EditMode Mode;
    00064
    00065 private:
    00066     // Constructor is private to force the use of the "create()" constructor.
    00067     CanvasInterface(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas);
    00068
    00069 private:
    00070     etl::loose_handle<Instance> instance_;
    00071     etl::handle<synfig::Canvas> canvas_;
    00072     etl::handle<SelectionManager> selection_manager_;
    00073     etl::handle<UIInterface> ui_interface_;
    00074     synfig::Time cur_time_;
    00075     Mode mode_;
    00076
    00077     sigc::signal<void,synfig::Layer::Handle> signal_layer_raised_;
    00078     sigc::signal<void,synfig::Layer::Handle> signal_layer_lowered_;
    00079     sigc::signal<void,synfig::Layer::Handle,int> signal_layer_inserted_;
    00080     sigc::signal<void,synfig::Layer::Handle,int,synfig::Canvas::Handle> signal_layer_moved_;
    00081     sigc::signal<void,synfig::Layer::Handle> signal_layer_removed_;
    00082     sigc::signal<void,synfig::Layer::Handle,bool> signal_layer_status_changed_;
    00083     sigc::signal<void,synfig::Layer::Handle,synfig::String> signal_layer_new_description_;
    00084     sigc::signal<void,synfig::Canvas::Handle> signal_canvas_added_;
    00085     sigc::signal<void,synfig::Canvas::Handle> signal_canvas_removed_;
    00086
    00087     sigc::signal<void,synfig::ValueNode::Handle> signal_value_node_added_;
    00088     sigc::signal<void,synfig::ValueNode::Handle> signal_value_node_deleted_;
    00089     sigc::signal<void,synfig::ValueNode::Handle,synfig::ValueNode::Handle> signal_value_node_replaced_;
    00090
    00091     sigc::signal<void,synfig::Keyframe> signal_keyframe_added_;
    00092     sigc::signal<void,synfig::Keyframe> signal_keyframe_removed_;
    00093     sigc::signal<void,synfig::Keyframe> signal_keyframe_changed_;
    00094
    00095     sigc::signal<void> signal_id_changed_;
    00096
    00097     sigc::signal<void> signal_time_changed_;
    00098
    00099     sigc::signal<void> signal_rend_desc_changed_;
    00100
    00101     sigc::signal<void,Mode> signal_mode_changed_;
    00102
    00103     //sigc::signal<void> signal_dirty_preview_;
    00104
    00105     sigc::signal<void,synfig::Layer::Handle,synfig::String> signal_layer_param_changed_;
    00106
    00107 public: // Signal Interface
    00108
    00109     sigc::signal<void,synfig::Layer::Handle,int,synfig::Canvas::Handle>& signal_layer_moved() { return signal_layer_moved_; }
    00110
    00111     sigc::signal<void,synfig::Layer::Handle,synfig::String>& signal_layer_new_description() { return signal_layer_new_description_; }
    00112
    00114     sigc::signal<void,synfig::Layer::Handle>& signal_layer_raised() { return signal_layer_raised_; }
    00115
    00117     sigc::signal<void,synfig::Layer::Handle>& signal_layer_lowered() { return signal_layer_lowered_; }
    00118
    00120     sigc::signal<void,synfig::Layer::Handle,int>& signal_layer_inserted() { return signal_layer_inserted_; }
    00121
    00123     sigc::signal<void,synfig::Layer::Handle>& signal_layer_removed() { return signal_layer_removed_; }
    00124
    00126     sigc::signal<void,synfig::Layer::Handle,bool>& signal_layer_status_changed() { return signal_layer_status_changed_; }
    00127
    00129     sigc::signal<void,etl::handle<synfig::Canvas> >& signal_canvas_added() { return signal_canvas_added_; }
    00130
    00132     sigc::signal<void,etl::handle<synfig::Canvas> >& signal_canvas_removed() { return signal_canvas_removed_; }
    00133
    00135     sigc::signal<void,synfig::Layer::Handle,synfig::String>& signal_layer_param_changed() { return signal_layer_param_changed_; }
    00136
    00138     //sigc::signal<void>& signal_dirty_preview() { return signal_dirty_preview_; }
    00139     sigc::signal<void>& signal_dirty_preview() { return get_canvas()->signal_dirty(); }
    00140
    00141     sigc::signal<void,etl::handle<synfig::ValueNode>,etl::handle<synfig::ValueNode> >&
    00142         signal_value_node_child_added() { return get_canvas()->signal_value_node_child_added(); }
    00143     sigc::signal<void,etl::handle<synfig::ValueNode>,etl::handle<synfig::ValueNode> >&
    00144         signal_value_node_child_removed() { return get_canvas()->signal_value_node_child_removed(); }
    00145
    00147     sigc::signal<void,etl::handle<synfig::ValueNode> >& signal_value_node_added() { return signal_value_node_added_; }
    00148
    00150     sigc::signal<void,etl::handle<synfig::ValueNode> >& signal_value_node_deleted() { return signal_value_node_deleted_; }
    00151
    00153     sigc::signal<void,etl::handle<synfig::ValueNode> >& signal_value_node_changed() { return get_canvas()->signal_value_node_changed(); }
    00154
    00156     sigc::signal<void,etl::handle<synfig::ValueNode> >& signal_value_node_renamed() { return get_canvas()->signal_value_node_renamed(); }
    00157
    00159     sigc::signal<void,Mode> signal_mode_changed() { return signal_mode_changed_; }
    00160
    00162     sigc::signal<void>& signal_id_changed() { return signal_id_changed_; }
    00163
    00165     sigc::signal<void> signal_time_changed() { return signal_time_changed_; }
    00166
    00168
    00169     sigc::signal<void,synfig::ValueNode::Handle,synfig::ValueNode::Handle>& signal_value_node_replaced()
    00170         { return signal_value_node_replaced_; }
    00171
    00173     sigc::signal<void>& signal_rend_desc_changed() { return signal_rend_desc_changed_; }
    00174
    00175     sigc::signal<void,synfig::Keyframe>& signal_keyframe_added() { return signal_keyframe_added_; }
    00176
    00177     sigc::signal<void,synfig::Keyframe>& signal_keyframe_removed() { return signal_keyframe_removed_; }
    00178
    00179     sigc::signal<void,synfig::Keyframe>& signal_keyframe_changed() { return signal_keyframe_changed_; }
    00180
    00181 public:
    00182
    00183     void auto_export(const ValueDesc& value_desc);
    00184
    00185     void auto_export(synfig::ValueNode::Handle value_node);
    00186
    00187     void set_meta_data(const synfig::String& key,const synfig::String& data);
    00188
    00190     void set_selection_manager(const etl::handle<SelectionManager> &sm) { selection_manager_=sm; }
    00191
    00193     void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
    00194
    00196     const etl::handle<SelectionManager> &get_selection_manager()const { return selection_manager_; }
    00197
    00199     void set_ui_interface(const etl::handle<UIInterface> &uim) { ui_interface_=uim; }
    00200
    00202     void unset_ui_interface() { ui_interface_=new DefaultUIInterface(); }
    00203
    00205     const etl::handle<UIInterface> &get_ui_interface() { return ui_interface_; }
    00206
    00208     etl::handle<synfig::Canvas> get_canvas()const { return canvas_; }
    00209
    00211     etl::loose_handle<Instance> get_instance()const { return instance_; }
    00212
    00214     void set_name(const synfig::String &x);
    00215
    00217     void set_description(const synfig::String &x);
    00218
    00220     void set_id(const synfig::String &x);
    00221
    00223     synfig::String get_name()const { return get_canvas()->get_name(); }
    00224
    00226     synfig::String get_description()const { return get_canvas()->get_description(); }
    00227
    00229     synfig::String get_id()const { return get_canvas()->get_id(); }
    00230
    00232     void set_time(synfig::Time x);
    00233
    00235     synfig::Time get_time()const;
    00236
    00238     void jump_to_next_keyframe();
    00239
    00241     void jump_to_prev_keyframe();
    00242
    00243     void seek_frame(int frames);
    00244
    00245     void seek_time(synfig::Time time);
    00246
    00248     void refresh_current_values();
    00249
    00251
    00252     void set_mode(Mode x);
    00253
    00255
    00256     Mode get_mode()const;
    00257
    00259     // synfig::Layer::Handle add_layer(synfig::String id) { return add_layer_to(id,get_canvas()); }
    00260
    00261     synfig::Layer::Handle add_layer_to(synfig::String id,synfig::Canvas::Handle canvas, int depth=0);
    00262
    00263     bool convert(ValueDesc value_desc, synfig::String type);
    00265     bool add_value_node(synfig::ValueNode::Handle value_node, synfig::String name);
    00266
    00267
    00268     Action::ParamList generate_param_list(const synfigapp::ValueDesc &);
    00269
    00270     Action::ParamList generate_param_list(const std::list<synfigapp::ValueDesc> &);
    00271
    00272     void set_rend_desc(const synfig::RendDesc &rend_desc);
    00273
    00274     bool import(const synfig::String &filename, synfig::String &errors, synfig::String &warnings, bool resize_image=false);
    00275
    00276
    00277     void waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
    00278     void waypoint_duplicate(synfig::ValueNode::Handle value_node,synfig::Waypoint waypoint);
    00279
    00280     void waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
    00281     void waypoint_remove(synfig::ValueNode::Handle value_node,synfig::Waypoint waypoint);
    00282
    00283     bool change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value);
    00284
    00285
    00286     int find_important_value_descs(std::vector<synfigapp::ValueDesc>& out);
    00287     static int find_important_value_descs(synfig::Canvas::Handle canvas,std::vector<synfigapp::ValueDesc>& out,synfig::GUIDSet& guid_set);
    00288
    00289     ~CanvasInterface();
    00290
    00291     static etl::handle<CanvasInterface> create(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas);
    00292 }; // END of class CanvasInterface
    00293
    00297 class PushMode
    00298 {
    00299     CanvasInterface* canvas_interface_;
    00300     CanvasInterface::Mode old_mode_;
    00301 public:
    00302     PushMode(etl::loose_handle<CanvasInterface> c, CanvasInterface::Mode mode):
    00303         canvas_interface_(c.get()), old_mode_(canvas_interface_->get_mode())
    00304     { canvas_interface_->set_mode(mode); }
    00305
    00306     ~PushMode() { canvas_interface_->set_mode(old_mode_); }
    00307 }; // END of class PushMode
    00308
    00309 }; // END of namespace studio
    00310
    00311 /* === E N D =============================================================== */
    00312
    00313 #endif