Enable tooltips and allow use the 'hint' descriptor for some types for the linkable...
[synfig.git] / synfig-studio / src / gui / trees / canvastreestore.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file trees/canvastreestore.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_CANVASTREESTORE_H
26 #define __SYNFIG_STUDIO_CANVASTREESTORE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <gtkmm/treestore.h>
31 #include <synfigapp/canvasinterface.h>
32 #include <gdkmm/pixbuf.h>
33 #include <synfigapp/value_desc.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 CellRenderer_TimeTrack;
45 class CellRenderer_ValueBase;
46
47         enum ColumnID
48         {
49                 COLUMNID_ID,
50                 COLUMNID_VALUE,
51                 COLUMNID_TIME_TRACK,
52                 COLUMNID_TYPE,
53
54                 COLUMNID_END                    //!< \internal
55         };
56 #define COLUMNID_NAME COLUMNID_ID
57
58 class CanvasTreeStore : virtual public Gtk::TreeStore
59 {
60         /*
61  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
62         */
63
64 public:
65
66         class Model : public Gtk::TreeModel::ColumnRecord
67         {
68         public:
69                 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
70                 Gtk::TreeModelColumn<Glib::ustring> label;
71                 Gtk::TreeModelColumn<Glib::ustring> name;
72                 Gtk::TreeModelColumn<Glib::ustring> id;
73
74                 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
75                 Gtk::TreeModelColumn<bool> is_canvas;
76
77                 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
78                 Gtk::TreeModelColumn<bool> is_value_node;
79                 Gtk::TreeModelColumn<synfig::ValueBase> value;
80                 Gtk::TreeModelColumn<Glib::ustring> type;
81                 Gtk::TreeModelColumn<int> link_id;
82                 Gtk::TreeModelColumn<int> link_count;
83
84                 Gtk::TreeModelColumn<bool> is_editable;
85
86                 Gtk::TreeModelColumn<bool> is_shared;
87                 Gtk::TreeModelColumn<bool> is_exported;
88
89                 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
90                 Gtk::TreeModelColumn<synfig::ParamDesc> child_param_desc;
91
92                 Gtk::TreeModelColumn<Glib::ustring> tooltip;
93
94                 Model()
95                 {
96                         add(value);
97                         add(name);
98                         add(label);
99                         add(icon);
100                         add(type);
101                         add(id);
102                         add(canvas);
103                         add(value_node);
104                         add(is_canvas);
105                         add(is_value_node);
106
107                         add(is_shared);
108                         add(is_exported);
109                         add(is_editable);
110                         add(value_desc);
111                         add(child_param_desc);
112                         add(link_count);
113                         add(link_id);
114
115                         add(tooltip);
116                 }
117         };
118
119         /*
120  -- ** -- P U B L I C  D A T A ------------------------------------------------
121         */
122
123 public:
124
125         const Model model;
126
127         //std::multimap<etl::handle<ValueNode>, sigc::connection> connection_map;
128
129         /*
130  -- ** -- P R I V A T E   D A T A ---------------------------------------------
131         */
132
133 private:
134
135         etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
136
137         /*
138  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
139         */
140
141 private:
142
143 protected:
144         virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
145
146         /*
147  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
148         */
149
150 private:
151
152         /*
153  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
154         */
155
156 public:
157
158         CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
159         ~CanvasTreeStore();
160
161         etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
162         etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
163
164         virtual void rebuild_row(Gtk::TreeModel::Row &row, bool do_children=true);
165
166         virtual void refresh_row(Gtk::TreeModel::Row &row, bool do_children=true);
167
168         virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children=true);
169
170         bool find_first_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
171         bool find_next_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
172
173         bool find_first_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
174         bool find_next_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
175
176
177         static CellRenderer_ValueBase* add_cell_renderer_value(Gtk::TreeView::Column* column);
178
179         static CellRenderer_TimeTrack* add_cell_renderer_value_node(Gtk::TreeView::Column* column);
180
181         etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
182
183         virtual void on_value_node_changed(synfig::ValueNode::Handle value_node)=0;
184
185         /*
186  -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
187         */
188
189 public:
190
191 }; // END of class CanvasTreeStore
192
193 }; // END of namespace studio
194
195 /* === E N D =============================================================== */
196
197 #endif