synfig-studio  1.0.3
layertreestore.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_STUDIO_LAYERTREESTORE_H
26 #define __SYNFIG_STUDIO_LAYERTREESTORE_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <gtkmm/treestore.h>
32 #include <synfig/value.h>
33 #include <synfig/valuenode.h>
34 #include <gtkmm/treeview.h>
35 
36 /* === M A C R O S ========================================================= */
37 
38 /* === T Y P E D E F S ===================================================== */
39 
40 /* === C L A S S E S & S T R U C T S ======================================= */
41 
42 namespace studio {
43 
44 class LayerTreeStore : virtual public Gtk::TreeStore
45 {
46  /*
47  -- ** -- P U B L I C T Y P E S ---------------------------------------------
48  */
49 
50 public:
51 
52  class Model : public Gtk::TreeModel::ColumnRecord
53  {
54  public:
55  Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
56  Gtk::TreeModelColumn<Glib::ustring> label;
57  Gtk::TreeModelColumn<Glib::ustring> name;
58  Gtk::TreeModelColumn<Glib::ustring> id;
59 
60  Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
61 
62  Gtk::TreeModelColumn<Glib::ustring> tooltip;
63 
64 
65  Gtk::TreeModelColumn<bool> active;
66  Gtk::TreeModelColumn<bool> exclude_from_rendering;
67  Gtk::TreeModelColumn<Pango::Style> style;
68  Gtk::TreeModelColumn<Pango::Weight> weight;
69  Gtk::TreeModelColumn<synfig::Layer::Handle> layer;
70  Gtk::TreeModelColumn<synfig::Canvas::Handle> contained_canvas;
71 
72  Gtk::TreeModelColumn<bool> children_lock;
73 
74  Gtk::TreeModelColumn<float> z_depth;
75  Gtk::TreeModelColumn<int> index;
76 
78  {
79  add(icon);
80  add(label);
81  add(name);
82  add(id);
83  add(canvas);
84  add(tooltip);
85  add(active);
87  add(style);
88  add(weight);
89  add(layer);
90  add(contained_canvas);
91  add(z_depth);
92  add(index);
93  add(children_lock);
94  }
95  };
96 
97  /*
98  -- ** -- P U B L I C D A T A ------------------------------------------------
99  */
100 
101 public:
102 
104  const Model model;
105 
106  /*
107  -- ** -- P R I V A T E D A T A ---------------------------------------------
108  */
109 
110 private:
111 
112  bool queued;
113 
114  sigc::connection queue_connection;
115 
116  std::map<synfig::Layer::Handle, sigc::connection> subcanvas_changed_connections;
117 
118  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
119 
120  Glib::RefPtr<Gdk::Pixbuf> layer_icon;
121 
122  /*
123  -- ** -- P R I V A T E M E T H O D S ---------------------------------------
124  */
125 
126 private:
127 
128  /*
129  -- ** -- P R O T E C T E D M E T H O D S -----------------------------------
130  */
131 
132 private:
133  virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
134  virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
135 
136  virtual bool row_draggable_vfunc (const TreeModel::Path& path)const;
137  virtual bool drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
138  virtual bool drag_data_delete_vfunc (const TreeModel::Path& path);
139  virtual bool drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
140  virtual bool row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
141 
142  /*
143  -- ** -- S I G N A L T E R M I N A L S -------------------------------------
144  */
145 
146 private:
147 
148  bool on_layer_tree_event(GdkEvent *event);
149 
150  void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
151 
152  void on_layer_added(synfig::Layer::Handle handle);
153 
154  void on_layer_removed(synfig::Layer::Handle handle);
155 
156  void on_layer_inserted(synfig::Layer::Handle handle,int depth);
157 
158  void on_layer_moved(synfig::Layer::Handle handle,int depth, synfig::Canvas::Handle canvas);
159 
160  void on_layer_status_changed(synfig::Layer::Handle handle,bool);
161 
162  void on_layer_exclude_from_rendering_changed(synfig::Layer::Handle handle,bool);
163 
164  void on_layer_z_range_changed(synfig::Layer::Handle handle,bool);
165 
166  void on_layer_lowered(synfig::Layer::Handle handle);
167 
168  void on_layer_raised(synfig::Layer::Handle handle);
169 
170  void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
171 
172  //void on_value_node_added(synfig::ValueNode::Handle value_node);
173 
174  //void on_value_node_deleted(synfig::ValueNode::Handle value_node);
175 
176  //void on_value_node_changed(synfig::ValueNode::Handle value_node);
177 
178  //void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
179 
180  bool find_layer_row_(const synfig::Layer::Handle &handle, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
181 
182  bool find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter);
183 
184  /*
185  -- ** -- P U B L I C M E T H O D S -----------------------------------------
186  */
187 
188 public:
189 
190  LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
191  ~LayerTreeStore();
192 
193  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
194  etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
195  etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
196 
197  bool find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter);
198 
199  bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
200 
201  bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
202 
203  void queue_rebuild();
204 
205  void rebuild();
206 
207  void refresh();
208 
209  void refresh_row(Gtk::TreeModel::Row &row);
210 
211  void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
212 
213  static int z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
214  static int index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
215 
216  //void set_row_param(Gtk::TreeRow &row,synfig::Layer::Handle &handle,const std::string& name, const std::string& local_name, const synfig::ValueBase &value, etl::handle<synfig::ValueNode> value_node,synfig::ParamDesc *param_desc);
217 
218  //virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc);
219  static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
220 
221  /*
222  -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
223  */
224 
225 public:
226 
227  static Glib::RefPtr<LayerTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
228 
229 
230 }; // END of class LayerTreeStore
231 
232 }; // END of namespace studio
233 
234 /* === E N D =============================================================== */
235 
236 #endif