1 /* === S Y N F I G ========================================================= */
2 /*! \file keyframetreestore.h
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 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_STUDIO_KEYFRAMETREESTORE_H
27 #define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
29 /* === H E A D E R S ======================================================= */
31 #include <gtkmm/liststore.h>
32 #include <synfigapp/canvasinterface.h>
33 #include <gdkmm/pixbuf.h>
34 #include <synfig/keyframe.h>
37 /* === M A C R O S ========================================================= */
39 /* === T Y P E D E F S ===================================================== */
41 /* === C L A S S E S & S T R U C T S ======================================= */
43 //class TreeRowReferenceHack;
44 //#define TreeRowReferenceHack Gtk::TreeRowReference
48 class KeyframeTreeStore_Class;
50 class KeyframeTreeStore :
52 public Gtk::TreeModel,
53 public Gtk::TreeDragSource,
54 public Gtk::TreeDragDest
57 -- ** -- P U B L I C T Y P E S ---------------------------------------------
62 class Model : public Gtk::TreeModel::ColumnRecord
65 Gtk::TreeModelColumn<synfig::Time> time;
66 Gtk::TreeModelColumn<Glib::ustring> description;
67 Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
68 Gtk::TreeModelColumn<synfig::Time> time_delta;
80 -- ** -- P U B L I C D A T A ------------------------------------------------
88 -- ** -- P R I V A T E D A T A ---------------------------------------------
93 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
95 //! Unique stamp for this TreeModel.
98 static KeyframeTreeStore_Class keyframe_tree_store_class_;
100 //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
102 synfig::KeyframeList old_keyframe_list;
105 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
110 void add_keyframe(synfig::Keyframe);
112 void remove_keyframe(synfig::Keyframe);
114 void change_keyframe(synfig::Keyframe);
116 static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
118 bool iterator_sane(const GtkTreeIter* iter)const;
120 bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
122 void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
124 void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
126 //! Resets the iterator stamp for this model.
127 /*! This should be called whenever the class is
128 ** constructed or when large numbers of
129 ** iterators become invalid. */
132 //void reset_path_table();
135 -- ** -- V I R T U A L F U N C T I O N S -----------------------------------
140 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
141 virtual Gtk::TreeModelFlags get_flags_vfunc ();
142 virtual int get_n_columns_vfunc ();
143 virtual GType get_column_type_vfunc (int index);
144 virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
145 virtual bool get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
146 virtual bool iter_nth_root_child_vfunc (int n, iterator& iter)const;
147 virtual Gtk::TreeModel::Path get_path_vfunc (const iterator& iter)const;
148 virtual void ref_node_vfunc (iterator& iter)const;
149 virtual void unref_node_vfunc (iterator& iter)const;
150 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
151 virtual bool iter_is_valid (const iterator& iter) const;
152 virtual int iter_n_root_children_vfunc () const;
154 //virtual bool iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n);
155 //virtual bool iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent);
156 //virtual bool iter_has_child_vfunc (const GtkTreeIter* iter);
157 //virtual int iter_n_children_vfunc (const GtkTreeIter* iter);
158 //virtual bool iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child);
161 virtual bool get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order);
162 virtual void set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order);
163 virtual void set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
164 virtual void set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
165 virtual bool has_default_sort_func_vfunc ();
169 -- ** -- S I G N A L T E R M I N A L S -------------------------------------
175 -- ** -- P U B L I C M E T H O D S -----------------------------------------
180 KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
181 ~KeyframeTreeStore();
183 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
184 etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
186 synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
187 synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
189 Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
192 -- ** -- S T A T I C M E T H O D S ------------------------------------------
197 static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
199 static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
200 static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
202 }; // END of class KeyframeTreeStore
205 class KeyframeTreeStore_Class : public Glib::Class
208 struct KeyframeTreeStoreClass
210 GObjectClass parent_class;
213 friend class KeyframeTreeStore;
215 const Glib::Class& init();
217 static void class_init_function(gpointer g_blass, gpointer class_data);
218 }; // END of CustomTreeStore_Class
220 }; // END of namespace studio
222 /* === E N D =============================================================== */