Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / keyframetreestore.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file keyframetreestore.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2008 Chris Moore
10 **
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.
15 **
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.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
27 #define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include <gtkmm/liststore.h>
32 #include <synfigapp/canvasinterface.h>
33 #include <gdkmm/pixbuf.h>
34 #include <synfig/keyframe.h>
35 #include <map>
36
37 /* === M A C R O S ========================================================= */
38
39 /* === T Y P E D E F S ===================================================== */
40
41 /* === C L A S S E S & S T R U C T S ======================================= */
42
43 //class TreeRowReferenceHack;
44 //#define TreeRowReferenceHack Gtk::TreeRowReference
45
46 namespace studio {
47
48 class KeyframeTreeStore_Class;
49
50 class KeyframeTreeStore :
51         public Glib::Object,
52         public Gtk::TreeModel,
53         public Gtk::TreeDragSource,
54         public Gtk::TreeDragDest
55 {
56         /*
57  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
58         */
59
60 public:
61
62         class Model : public Gtk::TreeModel::ColumnRecord
63         {
64         public:
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;
69
70                 Model()
71                 {
72                         add(time);
73                         add(description);
74                         add(keyframe);
75                         add(time_delta);
76                 }
77         };
78
79         /*
80  -- ** -- P U B L I C  D A T A ------------------------------------------------
81         */
82
83 public:
84
85         const Model model;
86
87         /*
88  -- ** -- P R I V A T E   D A T A ---------------------------------------------
89         */
90
91 private:
92
93         etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
94
95         //! Unique stamp for this TreeModel.
96         int stamp_;
97
98         static KeyframeTreeStore_Class keyframe_tree_store_class_;
99
100         //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
101
102         synfig::KeyframeList old_keyframe_list;
103
104         /*
105  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
106         */
107
108 private:
109
110         void add_keyframe(synfig::Keyframe);
111
112         void remove_keyframe(synfig::Keyframe);
113
114         void change_keyframe(synfig::Keyframe);
115
116         static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
117
118         bool iterator_sane(const GtkTreeIter* iter)const;
119
120         bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
121
122         void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
123
124         void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
125
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. */
130         void reset_stamp();
131
132         //void reset_path_table();
133
134         /*
135  -- ** -- V I R T U A L   F U N C T I O N S -----------------------------------
136         */
137
138 protected:
139
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;
153
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);
159
160         /*
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 ();
166         */
167
168         /*
169  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
170         */
171
172 private:
173
174         /*
175  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
176         */
177
178 public:
179
180         KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
181         ~KeyframeTreeStore();
182
183         etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
184         etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
185
186         synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
187         synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
188
189         Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
190
191         /*
192  -- ** -- S T A T I C  M E T H O D S ------------------------------------------
193         */
194
195 public:
196
197         static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
198
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);
201
202 }; // END of class KeyframeTreeStore
203
204 //! \internal
205 class KeyframeTreeStore_Class : public Glib::Class
206 {
207 public:
208         struct KeyframeTreeStoreClass
209         {
210                 GObjectClass parent_class;
211         };
212
213         friend class KeyframeTreeStore;
214
215         const Glib::Class& init();
216
217         static void class_init_function(gpointer g_blass, gpointer class_data);
218 }; // END of CustomTreeStore_Class
219
220 }; // END of namespace studio
221
222 /* === E N D =============================================================== */
223
224 #endif