synfig-studio  1.0.3
layergrouptreestore.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_LAYERGROUPTREESTORE_H
26 #define __SYNFIG_STUDIO_LAYERGROUPTREESTORE_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 LayerGroupTreeStore : public Gtk::TreeStore
45 {
46  /*
47  -- ** -- P U B L I C T Y P E S ---------------------------------------------
48  */
49 
50 public:
51  typedef std::list<synfig::Layer::Handle> LayerList;
52 
53  class Model : public Gtk::TreeModel::ColumnRecord
54  {
55  public:
56  Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
57  Gtk::TreeModelColumn<Glib::ustring> label;
58  Gtk::TreeModelColumn<Glib::ustring> tooltip;
59 
60  Gtk::TreeModelColumn<Glib::ustring> group_name;
61  Gtk::TreeModelColumn<Glib::ustring> parent_group_name;
62 
63  Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
64 
65  Gtk::TreeModelColumn<bool> active;
66  Gtk::TreeModelColumn<bool> is_layer;
67  Gtk::TreeModelColumn<bool> is_group;
68  Gtk::TreeModelColumn<synfig::Layer::Handle> layer;
69 
70  Gtk::TreeModelColumn<LayerList> all_layers;
71  Gtk::TreeModelColumn<LayerList> child_layers;
72 
74  {
75  add(icon);
76  add(label);
77  add(group_name);
78  add(parent_group_name);
79  add(canvas);
80  add(tooltip);
81  add(active);
82  add(layer);
83  add(is_layer);
84  add(is_group);
85  add(all_layers);
86  add(child_layers);
87  }
88  };
89 
90  /*
91  -- ** -- P U B L I C D A T A ------------------------------------------------
92  */
93 
94 public:
95 
97  const Model model;
98 
99  bool rebuilding;
100 
101  /*
102  -- ** -- P R I V A T E D A T A ---------------------------------------------
103  */
104 
105 private:
106 
107  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
108 
109  Glib::RefPtr<Gdk::Pixbuf> layer_icon;
110  Glib::RefPtr<Gdk::Pixbuf> group_icon;
111 
112  /*
113  -- ** -- P R I V A T E M E T H O D S ---------------------------------------
114  */
115 
116 private:
117 
118  /*
119  -- ** -- P R O T E C T E D M E T H O D S -----------------------------------
120  */
121 
122 private:
123 
124  virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
125  virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
126 
127  virtual bool row_draggable_vfunc (const TreeModel::Path& path)const;
128  virtual bool drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
129  virtual bool drag_data_delete_vfunc (const TreeModel::Path& path);
130  virtual bool drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
131  virtual bool row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
132 
133 
134  void on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer);
135  void on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer);
136 
137  void on_activity();
138 
139  /*
140  -- ** -- S I G N A L T E R M I N A L S -------------------------------------
141  */
142 
143 private:
144 
145  bool on_layer_tree_event(GdkEvent *event);
146 
147  void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
148 
149  void on_layer_status_changed(synfig::Layer::Handle handle,bool);
150 
151  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);
152 
153  bool find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
154 
155  bool on_group_removed(synfig::String group);
156  bool on_group_changed(synfig::String group);
157 
158  /*
159  -- ** -- P U B L I C M E T H O D S -----------------------------------------
160  */
161 
162 public:
163 
164  LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
166 
167  Gtk::TreeRow on_group_added(synfig::String group);
168  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
169  etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
170  etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
171 
172  bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
173 
174  bool find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter);
175 
176  bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
177 
178  void rebuild();
179 
180  void refresh();
181 
182  void refresh_row(Gtk::TreeModel::Row &row);
183 
184  void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
185 
186  static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
187 
188  /*
189  -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
190  */
191 
192 public:
193 
194  static Glib::RefPtr<LayerGroupTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
195 
196 }; // END of class LayerGroupTreeStore
197 
198 }; // END of namespace studio
199 
200 /* === E N D =============================================================== */
201 
202 #endif