1 /* === S Y N F I G ========================================================= */ 2 /*! \file trees/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 47 namespace studio { 48 49 class KeyframeTreeStore_Class; 50 #if GLIB_CHECK_VERSION(2, 37, 5) 51 class KeyframeTreeStore : 52 public Gtk::TreeModel, 53 public Gtk::TreeDragSource, 54 public Gtk::TreeDragDest, 55 public Glib::Object 56 #else 57 class KeyframeTreeStore : 58 public Glib::Object, 59 public Gtk::TreeModel, 60 public Gtk::TreeDragSource, 61 public Gtk::TreeDragDest 62 #endif 63 { 64 /* 65 -- ** -- P U B L I C T Y P E S --------------------------------------------- 66 */ 67 68 public: 69 70 class Model : public Gtk::TreeModel::ColumnRecord 71 { 72 public: 73 Gtk::TreeModelColumn<synfig::Time> time; 74 Gtk::TreeModelColumn<Glib::ustring> description; 75 Gtk::TreeModelColumn<synfig::Keyframe> keyframe; 76 Gtk::TreeModelColumn<synfig::Time> time_delta; 77 Gtk::TreeModelColumn<bool> active; 78 Model()79 Model() 80 { 81 add(time); 82 add(description); 83 add(keyframe); 84 add(time_delta); 85 add(active); 86 } 87 }; 88 89 /* 90 -- ** -- P U B L I C D A T A ------------------------------------------------ 91 */ 92 93 public: 94 95 const Model model; 96 97 /* 98 -- ** -- P R I V A T E D A T A --------------------------------------------- 99 */ 100 101 private: 102 103 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_; 104 105 //! Unique stamp for this TreeModel. 106 int stamp_; 107 108 //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_; 109 110 synfig::KeyframeList old_keyframe_list; 111 112 /* 113 -- ** -- P R I V A T E M E T H O D S --------------------------------------- 114 */ 115 116 private: 117 118 void add_keyframe(synfig::Keyframe); 119 120 void remove_keyframe(synfig::Keyframe); 121 122 void change_keyframe(synfig::Keyframe); 123 124 static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &); 125 126 bool iterator_sane(const GtkTreeIter* iter)const; 127 128 bool iterator_sane(const Gtk::TreeModel::iterator& iter)const; 129 130 void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const; 131 132 void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const; 133 134 //! Resets the iterator stamp for this model. 135 /*! This should be called whenever the class is 136 ** constructed or when large numbers of 137 ** iterators become invalid. */ 138 void reset_stamp(); 139 140 //void reset_path_table(); 141 142 /* 143 -- ** -- V I R T U A L F U N C T I O N S ----------------------------------- 144 */ 145 146 protected: 147 148 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value); 149 using Gtk::TreeModel::get_flags_vfunc; 150 virtual Gtk::TreeModelFlags get_flags_vfunc (); 151 using Gtk::TreeModel::get_n_columns_vfunc; 152 virtual int get_n_columns_vfunc (); 153 using Gtk::TreeModel::get_column_type_vfunc; 154 virtual GType get_column_type_vfunc (int index); 155 virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const; 156 virtual bool get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const; 157 virtual bool iter_nth_root_child_vfunc (int n, iterator& iter)const; 158 virtual Gtk::TreeModel::Path get_path_vfunc (const iterator& iter)const; 159 using Gtk::TreeModel::ref_node_vfunc; 160 virtual void ref_node_vfunc (iterator& iter)const; 161 using Gtk::TreeModel::unref_node_vfunc; 162 virtual void unref_node_vfunc (iterator& iter)const; 163 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const; 164 virtual bool iter_is_valid (const iterator& iter) const; 165 virtual int iter_n_root_children_vfunc () const; 166 167 //virtual bool iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n); 168 //virtual bool iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent); 169 //virtual bool iter_has_child_vfunc (const GtkTreeIter* iter); 170 //virtual int iter_n_children_vfunc (const GtkTreeIter* iter); 171 //virtual bool iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child); 172 173 /* 174 virtual bool get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order); 175 virtual void set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order); 176 virtual void set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy); 177 virtual void set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy); 178 virtual bool has_default_sort_func_vfunc (); 179 */ 180 181 /* 182 -- ** -- S I G N A L T E R M I N A L S ------------------------------------- 183 */ 184 185 private: 186 187 /* 188 -- ** -- P U B L I C M E T H O D S ----------------------------------------- 189 */ 190 191 public: 192 193 KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_); 194 ~KeyframeTreeStore(); 195 canvas_interface()196 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; } canvas_interface()197 etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; } 198 get_canvas()199 synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); } get_canvas()200 synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); } 201 202 Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe); 203 204 bool find_keyframe_path(const synfig::Keyframe &keyframe, Gtk::TreeModel::Path &path); 205 /* 206 -- ** -- S T A T I C M E T H O D S ------------------------------------------ 207 */ 208 209 public: 210 211 static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_); 212 213 static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs); 214 static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs); 215 216 }; // END of class KeyframeTreeStore 217 218 219 }; // END of namespace studio 220 221 /* === E N D =============================================================== */ 222 223 #endif 224