00001
00021
00022
00023
00024
00025 #ifndef __SYNFIG_STUDIO_LAYERTREESTORE_H
00026 #define __SYNFIG_STUDIO_LAYERTREESTORE_H
00027
00028
00029
00030 #include <gtkmm/treestore.h>
00031 #include <synfigapp/canvasinterface.h>
00032 #include <synfig/value.h>
00033 #include <synfig/valuenode.h>
00034 #include <gtkmm/treeview.h>
00035
00036
00037
00038
00039
00040
00041
00042 namespace studio {
00043
00044 class LayerTreeStore : virtual public Gtk::TreeStore
00045 {
00046
00047
00048
00049
00050 public:
00051
00052 class Model : public Gtk::TreeModel::ColumnRecord
00053 {
00054 public:
00055 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
00056 Gtk::TreeModelColumn<Glib::ustring> label;
00057 Gtk::TreeModelColumn<Glib::ustring> name;
00058 Gtk::TreeModelColumn<Glib::ustring> id;
00059
00060 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
00061
00062 Gtk::TreeModelColumn<Glib::ustring> tooltip;
00063
00064
00065 Gtk::TreeModelColumn<bool> active;
00066 Gtk::TreeModelColumn<synfig::Layer::Handle> layer;
00067 Gtk::TreeModelColumn<synfig::Canvas::Handle> contained_canvas;
00068
00069 Gtk::TreeModelColumn<bool> children_lock;
00070
00071 Gtk::TreeModelColumn<float> z_depth;
00072 Gtk::TreeModelColumn<int> index;
00073
00074 Model()
00075 {
00076 add(icon);
00077 add(label);
00078 add(name);
00079 add(id);
00080 add(canvas);
00081 add(tooltip);
00082 add(active);
00083 add(layer);
00084 add(contained_canvas);
00085 add(z_depth);
00086 add(index);
00087 add(children_lock);
00088 }
00089 };
00090
00091
00092
00093
00094
00095 public:
00096
00098 const Model model;
00099
00100
00101
00102
00103
00104 private:
00105
00106 bool queued;
00107
00108 sigc::connection queue_connection;
00109
00110 std::map<synfig::Layer::Handle, sigc::connection> subcanvas_changed_connections;
00111
00112 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
00113
00114 Glib::RefPtr<Gdk::Pixbuf> layer_icon;
00115
00116
00117
00118
00119
00120 private:
00121
00122
00123
00124
00125
00126 private:
00127 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
00128 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
00129
00130 virtual bool row_draggable_vfunc (const TreeModel::Path& path)const;
00131 virtual bool drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
00132 virtual bool drag_data_delete_vfunc (const TreeModel::Path& path);
00133 virtual bool drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
00134 virtual bool row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
00135
00136
00137
00138
00139
00140 private:
00141
00142 bool on_layer_tree_event(GdkEvent *event);
00143
00144 void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
00145
00146 void on_layer_added(synfig::Layer::Handle handle);
00147
00148 void on_layer_removed(synfig::Layer::Handle handle);
00149
00150 void on_layer_inserted(synfig::Layer::Handle handle,int depth);
00151
00152 void on_layer_moved(synfig::Layer::Handle handle,int depth, synfig::Canvas::Handle canvas);
00153
00154 void on_layer_status_changed(synfig::Layer::Handle handle,bool);
00155
00156 void on_layer_lowered(synfig::Layer::Handle handle);
00157
00158 void on_layer_raised(synfig::Layer::Handle handle);
00159
00160 void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 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);
00171
00172 bool find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter);
00173
00174
00175
00176
00177
00178 public:
00179
00180 LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
00181 ~LayerTreeStore();
00182
00183 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
00184 etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
00185 etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
00186
00187 bool find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter);
00188
00189 bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
00190
00191 bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
00192
00193 void queue_rebuild();
00194
00195 void rebuild();
00196
00197 void refresh();
00198
00199 void refresh_row(Gtk::TreeModel::Row &row);
00200
00201 void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
00202
00203 static int z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
00204 static int index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
00205
00206
00207
00208
00209 static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
00210
00211
00212
00213
00214
00215 public:
00216
00217 static Glib::RefPtr<LayerTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
00218
00219
00220 };
00221
00222 };
00223
00224
00225
00226 #endif