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
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
26 #define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
28 /* === H E A D E R S ======================================================= */
30 #include <gtkmm/liststore.h>
31 #include <synfigapp/canvasinterface.h>
32 #include <gdkmm/pixbuf.h>
33 #include <synfig/keyframe.h>
36 /* === M A C R O S ========================================================= */
38 /* === T Y P E D E F S ===================================================== */
40 /* === C L A S S E S & S T R U C T S ======================================= */
42 //class TreeRowReferenceHack;
43 //#define TreeRowReferenceHack Gtk::TreeRowReference
47 class KeyframeTreeStore_Class;
49 class KeyframeTreeStore :
51 public Gtk::TreeModel,
52 public Gtk::TreeDragSource,
53 public Gtk::TreeDragDest
56 -- ** -- P U B L I C T Y P E S ---------------------------------------------
61 class Model : public Gtk::TreeModel::ColumnRecord
64 Gtk::TreeModelColumn<synfig::Time> time;
65 Gtk::TreeModelColumn<Glib::ustring> description;
66 Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
67 Gtk::TreeModelColumn<synfig::Time> time_delta;
79 -- ** -- P U B L I C D A T A ------------------------------------------------
87 -- ** -- P R I V A T E D A T A ---------------------------------------------
92 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
94 //! Unique stamp for this TreeModel.
97 static KeyframeTreeStore_Class keyframe_tree_store_class_;
99 //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
101 synfig::KeyframeList old_keyframe_list;
104 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
109 void add_keyframe(synfig::Keyframe);
111 void remove_keyframe(synfig::Keyframe);
113 void change_keyframe(synfig::Keyframe);
115 static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
117 bool iterator_sane(const GtkTreeIter* iter)const;
119 bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
121 void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
123 void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
125 //! Resets the iterator stamp for this model.
126 /*! This should be called whenever the class is
127 ** constructed or when large numbers of
128 ** iterators become invalid. */
131 //void reset_path_table();
134 -- ** -- V I R T U A L F U N C T I O N S -----------------------------------
139 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
140 virtual Gtk::TreeModelFlags get_flags_vfunc ();
141 virtual int get_n_columns_vfunc ();
142 virtual GType get_column_type_vfunc (int index);
143 virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
144 virtual bool get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
145 virtual bool iter_nth_root_child_vfunc (int n, iterator& iter)const;
146 virtual Gtk::TreeModel::Path get_path_vfunc (const iterator& iter)const;
147 virtual void ref_node_vfunc (iterator& iter)const;
148 virtual void unref_node_vfunc (iterator& iter)const;
149 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
150 virtual bool iter_is_valid (const iterator& iter) const;
151 virtual int iter_n_root_children_vfunc () const;
153 //virtual bool iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n);
154 //virtual bool iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent);
155 //virtual bool iter_has_child_vfunc (const GtkTreeIter* iter);
156 //virtual int iter_n_children_vfunc (const GtkTreeIter* iter);
157 //virtual bool iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child);
160 virtual bool get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order);
161 virtual void set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order);
162 virtual void set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
163 virtual void set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
164 virtual bool has_default_sort_func_vfunc ();
168 -- ** -- S I G N A L T E R M I N A L S -------------------------------------
174 -- ** -- P U B L I C M E T H O D S -----------------------------------------
179 KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
180 ~KeyframeTreeStore();
182 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
183 etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
185 synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
186 synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
188 Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
191 -- ** -- S T A T I C M E T H O D S ------------------------------------------
196 static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
198 static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
199 static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
201 }; // END of class KeyframeTreeStore
204 class KeyframeTreeStore_Class : public Glib::Class
207 struct KeyframeTreeStoreClass
209 GObjectClass parent_class;
212 friend class KeyframeTreeStore;
214 const Glib::Class& init();
216 static void class_init_function(gpointer g_blass, gpointer class_data);
217 }; // END of CustomTreeStore_Class
219 }; // END of namespace studio
221 /* === E N D =============================================================== */