00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_STUDIO_INSTANCE_H
00027 #define __SYNFIG_STUDIO_INSTANCE_H
00028
00029
00030
00031 #include <ETL/handle>
00032 #include <gtkmm/treeview.h>
00033 #include <gtkmm/treestore.h>
00034 #include <synfigapp/instance.h>
00035 #include <sigc++/object.h>
00036 #include <synfigapp/value_desc.h>
00037 #include "historytreestore.h"
00038 #include <synfig/canvas.h>
00039
00040
00041 #define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
00042
00043
00044
00045
00046
00047 namespace Gtk { class Menu; class ActionGroup; };
00048
00049 namespace studio {
00050
00051 class CanvasView;
00052
00053
00054 class Instance : public synfigapp::Instance
00055 {
00056 public:
00057 typedef std::list< etl::handle<CanvasView> > CanvasViewList;
00058
00059 enum Status
00060 {
00061 STATUS_OK,
00062 STATUS_ERROR,
00063 STATUS_CANCEL
00064 };
00065
00066 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
00067 {
00068 public:
00069 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
00070 Gtk::TreeModelColumn<Glib::ustring> label;
00071 Gtk::TreeModelColumn<Glib::ustring> name;
00072 Gtk::TreeModelColumn<Glib::ustring> id;
00073
00074 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
00075 Gtk::TreeModelColumn<bool> is_canvas;
00076
00077 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
00078 Gtk::TreeModelColumn<bool> is_value_node;
00079 Gtk::TreeModelColumn<synfig::ValueBase> value;
00080 Gtk::TreeModelColumn<Glib::ustring> type;
00081 Gtk::TreeModelColumn<int> link_id;
00082 Gtk::TreeModelColumn<int> link_count;
00083
00084 Gtk::TreeModelColumn<bool> is_editable;
00085
00086 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
00087
00088 CanvasTreeModel()
00089 {
00090 add(value);
00091 add(name);
00092 add(label);
00093 add(icon);
00094 add(type);
00095 add(id);
00096 add(canvas);
00097 add(value_node);
00098 add(is_canvas);
00099 add(is_value_node);
00100
00101 add(is_editable);
00102 add(value_desc);
00103 add(link_count);
00104 add(link_id);
00105 }
00106 } canvas_tree_model;
00107
00108 private:
00109
00110 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
00111 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
00112
00113 sigc::signal<void> signal_undo_redo_status_changed_;
00114
00116 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
00117
00119 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
00120
00122 int id_;
00123
00125 static int instance_count_;
00126
00128 CanvasViewList canvas_view_list_;
00129
00130 bool undo_status_;
00131 bool redo_status_;
00132
00133 void set_undo_status(bool x);
00134 void set_redo_status(bool x);
00135
00136 static void _revert(Instance *);
00137
00138 protected:
00139
00140 Instance(synfig::Canvas::Handle);
00141
00142 public:
00143
00144 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
00145
00146 ~Instance();
00147
00148 sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
00149 sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
00150
00151 bool get_undo_status()const { return undo_status_; }
00152
00153 bool get_redo_status()const { return redo_status_; }
00154
00155 int get_visible_canvases()const;
00156
00157 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
00158
00159 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
00160
00161 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
00162
00163 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
00164
00166 static int get_count() { return instance_count_; }
00167
00168
00169
00170 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
00171
00173 void focus(etl::handle<synfig::Canvas> canvas);
00174
00175 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
00176
00177 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
00178
00179 bool save_as(const synfig::String &filename);
00180
00182 bool has_real_filename();
00183
00186 bool dialog_save_as();
00187
00188 void open();
00189
00190 Status save();
00191
00192 void dialog_cvs_commit();
00193
00194 void dialog_cvs_add();
00195
00196 void dialog_cvs_update();
00197
00198 void dialog_cvs_revert();
00199
00201 void close();
00202
00203 void revert();
00204
00205 void update_all_titles();
00206
00207 void refresh_canvas_tree();
00208
00209 bool safe_revert();
00210 bool safe_close();
00211
00212 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
00213 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list1,const synfigapp::Action::ParamList ¶m_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
00214
00215 void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
00216
00217 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
00218
00219 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
00220
00221 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
00222
00223
00224 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
00225
00226 private:
00227 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
00228
00229 public:
00230 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
00231 };
00232
00233 };
00234
00235
00236
00237 #endif