00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
00027 #define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
00028
00029
00030
00031 #include <gtkmm/liststore.h>
00032 #include <synfigapp/canvasinterface.h>
00033 #include <gdkmm/pixbuf.h>
00034 #include <synfig/keyframe.h>
00035 #include <map>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 namespace studio {
00047
00048 class KeyframeTreeStore_Class;
00049
00050 class KeyframeTreeStore :
00051 public Glib::Object,
00052 public Gtk::TreeModel,
00053 public Gtk::TreeDragSource,
00054 public Gtk::TreeDragDest
00055 {
00056
00057
00058
00059
00060 public:
00061
00062 class Model : public Gtk::TreeModel::ColumnRecord
00063 {
00064 public:
00065 Gtk::TreeModelColumn<synfig::Time> time;
00066 Gtk::TreeModelColumn<Glib::ustring> description;
00067 Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
00068 Gtk::TreeModelColumn<synfig::Time> time_delta;
00069
00070 Model()
00071 {
00072 add(time);
00073 add(description);
00074 add(keyframe);
00075 add(time_delta);
00076 }
00077 };
00078
00079
00080
00081
00082
00083 public:
00084
00085 const Model model;
00086
00087
00088
00089
00090
00091 private:
00092
00093 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
00094
00096 int stamp_;
00097
00098 static KeyframeTreeStore_Class keyframe_tree_store_class_;
00099
00100
00101
00102 synfig::KeyframeList old_keyframe_list;
00103
00104
00105
00106
00107
00108 private:
00109
00110 void add_keyframe(synfig::Keyframe);
00111
00112 void remove_keyframe(synfig::Keyframe);
00113
00114 void change_keyframe(synfig::Keyframe);
00115
00116 static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
00117
00118 bool iterator_sane(const GtkTreeIter* iter)const;
00119
00120 bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
00121
00122 void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
00123
00124 void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
00125
00127
00130 void reset_stamp();
00131
00132
00133
00134
00135
00136
00137
00138 protected:
00139
00140 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
00141 virtual Gtk::TreeModelFlags get_flags_vfunc ();
00142 virtual int get_n_columns_vfunc ();
00143 virtual GType get_column_type_vfunc (int index);
00144 virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
00145 virtual bool get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
00146 virtual bool iter_nth_root_child_vfunc (int n, iterator& iter)const;
00147 virtual Gtk::TreeModel::Path get_path_vfunc (const iterator& iter)const;
00148 virtual void ref_node_vfunc (iterator& iter)const;
00149 virtual void unref_node_vfunc (iterator& iter)const;
00150 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
00151 virtual bool iter_is_valid (const iterator& iter) const;
00152 virtual int iter_n_root_children_vfunc () const;
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 private:
00173
00174
00175
00176
00177
00178 public:
00179
00180 KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
00181 ~KeyframeTreeStore();
00182
00183 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
00184 etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
00185
00186 synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
00187 synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
00188
00189 Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
00190
00191
00192
00193
00194
00195 public:
00196
00197 static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
00198
00199 static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
00200 static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
00201
00202 };
00203
00205 class KeyframeTreeStore_Class : public Glib::Class
00206 {
00207 public:
00208 struct KeyframeTreeStoreClass
00209 {
00210 GObjectClass parent_class;
00211 };
00212
00213 friend class KeyframeTreeStore;
00214
00215 const Glib::Class& init();
00216
00217 static void class_init_function(gpointer g_blass, gpointer class_data);
00218 };
00219
00220 };
00221
00222
00223
00224 #endif