287ad1b3709c0cfbb902911d55dedefc1bb9a255
[synfig.git] / synfig-studio / trunk / src / gtkmm / childrentreestore.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file childrentreestore.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_STUDIO_CHILDRENTREESTORE_H
26 #define __SYNFIG_STUDIO_CHILDRENTREESTORE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <gtkmm/treestore.h>
31 #include <synfigapp/canvasinterface.h>
32 #include "canvastreestore.h"
33 #include <synfig/value.h>
34 #include <synfig/valuenode.h>
35 #include <set>
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 namespace studio {
44
45 class ChildrenTreeStore : public CanvasTreeStore
46 {
47         /*
48  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
49         */
50
51 public:
52
53         /*
54  -- ** -- P U B L I C  D A T A ------------------------------------------------
55         */
56
57 public:
58
59         //! TreeModel for the layers
60         const Model model;
61
62         /*
63  -- ** -- P R I V A T E   D A T A ---------------------------------------------
64         */
65
66 private:
67
68         Gtk::TreeModel::Row value_node_row;
69         Gtk::TreeModel::Row canvas_row;
70
71         std::set<synfig::ValueNode::Handle> changed_set_;
72
73         std::set<synfig::ValueNode::Handle> replaced_set_;
74
75         /*
76  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
77         */
78
79 private:
80
81         sigc::connection changed_connection;
82         bool execute_changed_queued()const { return !changed_set_.empty() || !replaced_set_.empty(); }
83         bool execute_changed_value_nodes();
84         void clear_changed_queue() { changed_set_.clear(); replaced_set_.clear(); }
85
86         /*
87  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
88         */
89
90 private:
91
92         void on_value_node_added(synfig::ValueNode::Handle value_node);
93         void on_value_node_deleted(synfig::ValueNode::Handle value_node);
94         void on_value_node_changed(synfig::ValueNode::Handle value_node);
95         void on_value_node_renamed(synfig::ValueNode::Handle value_node);
96         void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
97         void on_canvas_added(synfig::Canvas::Handle canvas);
98         void on_canvas_removed(synfig::Canvas::Handle canvas);
99
100         void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
101
102         /*
103  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
104         */
105
106 public:
107
108         ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
109         ~ChildrenTreeStore();
110
111         void rebuild();
112
113         void refresh();
114
115         void rebuild_value_nodes();
116
117         void refresh_value_nodes();
118
119         void rebuild_canvases();
120
121         void refresh_canvases();
122
123         void refresh_row(Gtk::TreeModel::Row &row, bool do_children=false);
124
125         Gtk::TreeModel::Row get_canvas_row()const { return canvas_row; }
126
127         Gtk::TreeModel::Row get_value_node_row()const { return value_node_row; }
128
129         /*
130  -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
131         */
132
133 public:
134
135         static Glib::RefPtr<ChildrenTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
136 }; // END of class ChildrenTreeStore
137
138 }; // END of namespace studio
139
140 /* === E N D =============================================================== */
141
142 #endif