1 /* === S Y N F I G ========================================================= */
2 /*! \file layergrouptreestore.h
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_STUDIO_LAYERGROUPTREESTORE_H
26 #define __SYNFIG_STUDIO_LAYERGROUPTREESTORE_H
28 /* === H E A D E R S ======================================================= */
30 #include <gtkmm/treestore.h>
31 #include <synfigapp/canvasinterface.h>
32 #include <synfig/value.h>
33 #include <synfig/valuenode.h>
34 #include <gtkmm/treeview.h>
36 /* === M A C R O S ========================================================= */
38 /* === T Y P E D E F S ===================================================== */
40 /* === C L A S S E S & S T R U C T S ======================================= */
44 class LayerGroupTreeStore : public Gtk::TreeStore
47 -- ** -- P U B L I C T Y P E S ---------------------------------------------
51 typedef std::list<synfig::Layer::Handle> LayerList;
53 class Model : public Gtk::TreeModel::ColumnRecord
56 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
57 Gtk::TreeModelColumn<Glib::ustring> label;
58 Gtk::TreeModelColumn<Glib::ustring> tooltip;
60 Gtk::TreeModelColumn<Glib::ustring> group_name;
61 Gtk::TreeModelColumn<Glib::ustring> parent_group_name;
63 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
65 Gtk::TreeModelColumn<bool> active;
66 Gtk::TreeModelColumn<bool> is_layer;
67 Gtk::TreeModelColumn<bool> is_group;
68 Gtk::TreeModelColumn<synfig::Layer::Handle> layer;
70 Gtk::TreeModelColumn<LayerList> all_layers;
71 Gtk::TreeModelColumn<LayerList> child_layers;
78 add(parent_group_name);
91 -- ** -- P U B L I C D A T A ------------------------------------------------
96 //! TreeModel for the layers
102 -- ** -- P R I V A T E D A T A ---------------------------------------------
107 etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
109 Glib::RefPtr<Gdk::Pixbuf> layer_icon;
110 Glib::RefPtr<Gdk::Pixbuf> group_icon;
113 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
119 -- ** -- P R O T E C T E D M E T H O D S -----------------------------------
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;
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;
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);
140 -- ** -- S I G N A L T E R M I N A L S -------------------------------------
145 bool on_layer_tree_event(GdkEvent *event);
147 void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
149 void on_layer_status_changed(synfig::Layer::Handle handle,bool);
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);
153 bool find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
155 bool on_group_removed(synfig::String group);
156 bool on_group_changed(synfig::String group);
159 -- ** -- P U B L I C M E T H O D S -----------------------------------------
164 LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
165 ~LayerGroupTreeStore();
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_; }
172 bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
174 bool find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter);
176 bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
182 void refresh_row(Gtk::TreeModel::Row &row);
184 void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
186 static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
189 -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
194 static Glib::RefPtr<LayerGroupTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
196 }; // END of class LayerGroupTreeStore
198 }; // END of namespace studio
200 /* === E N D =============================================================== */