Allow PasteCanvas layers with unset canvas parameters to be exported.
[synfig.git] / synfig-studio / trunk / src / gtkmm / layertree.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layertree.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_STUDIO_LAYERTREE_H
27 #define __SYNFIG_STUDIO_LAYERTREE_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include <gtkmm/treeview.h>
32 #include <gtkmm/treestore.h>
33 #include <gtkmm/tooltips.h>
34 #include <gtkmm/table.h>
35 #include <gtkmm/box.h>
36 #include <gtkmm/adjustment.h>
37 #include <gtkmm/scale.h>
38 #include <gtkmm/button.h>
39
40 #include <synfigapp/canvasinterface.h>
41 #include <synfigapp/value_desc.h>
42 #include "layertreestore.h"
43 #include "layerparamtreestore.h"
44 #include <synfig/valuenode_animated.h>
45
46 #include "widget_value.h"
47
48 /* === M A C R O S ========================================================= */
49
50 // comment this out if you don't want the params dialog to have a 'timetrack' column
51 // (alternatively, export SYNFIG_DISABLE_PARAMS_PANEL_TIMETRACK=1 in environment at runtime)
52 #define TIMETRACK_IN_PARAMS_PANEL
53
54 /* === T Y P E D E F S ===================================================== */
55
56 /* === C L A S S E S & S T R U C T S ======================================= */
57
58 namespace Gtk { class TreeModelSort; };
59
60 namespace studio {
61
62 class CellRenderer_TimeTrack;
63 class CellRenderer_ValueBase;
64
65 class LayerTree : public Gtk::Table
66 {
67         /*
68  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
69         */
70
71 public:
72
73         typedef studio::ColumnID ColumnID;
74 /*      enum ColumnID
75         {
76                 COLUMNID_NAME,
77                 COLUMNID_VALUE,
78                 COLUMNID_TIME_TRACK,
79
80                 COLUMNID_END                    //!< \internal
81         };
82 */
83         typedef std::list<synfig::Layer::Handle> LayerList;
84
85         /*
86  -- ** -- P U B L I C  D A T A ------------------------------------------------
87         */
88
89 public:
90
91         //LayerTreeStore::Model model;
92
93         LayerTreeStore::Model layer_model;
94         LayerParamTreeStore::Model param_model;
95
96         synfig::Layer::Handle last_top_selected_layer;
97         Gtk::TreePath last_top_selected_path;
98
99         /*
100  -- ** -- P R I V A T E   D A T A ---------------------------------------------
101         */
102
103 private:
104
105         Gtk::Tooltips tooltips_;
106         Gtk::TreePath last_tooltip_path;
107
108         Gtk::TreeView* layer_tree_view_;
109
110         Gtk::TreeView* param_tree_view_;
111
112         Gtk::HBox *hbox;
113
114         Gtk::Adjustment layer_amount_adjustment_;
115
116         Gtk::HScale *layer_amount_hscale;
117
118         synfig::Layer::Handle quick_layer;
119
120         Glib::RefPtr<LayerTreeStore> layer_tree_store_;
121
122         Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
123
124         Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
125
126 #ifdef TIMETRACK_IN_PARAMS_PANEL
127         CellRenderer_TimeTrack *cellrenderer_time_track;
128 #endif  // TIMETRACK_IN_PARAMS_PANEL
129
130         Gtk::TreeView::Column* column_time_track;
131
132         Gtk::TreeView::Column* column_z_depth;
133
134         CellRenderer_ValueBase *cellrenderer_value;
135
136         sigc::signal<void,synfig::Layer::Handle> signal_layer_toggle_;
137
138         sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
139
140         sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_layer_user_click_;
141
142         sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_param_user_click_;
143
144         sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_layertree_;
145
146         bool disable_amount_changed_signal;
147
148         Gtk::Button *button_raise;
149         Gtk::Button *button_lower;
150         Gtk::Button *button_duplicate;
151         Gtk::Button *button_encapsulate;
152         Gtk::Button *button_delete;
153
154         Widget_ValueBase blend_method_widget;
155
156         /*
157  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
158         */
159
160 private:
161
162         Gtk::Widget* create_layer_tree();
163         Gtk::Widget* create_param_tree();
164
165         /*
166  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
167         */
168
169 private:
170
171         void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
172
173         void on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value);
174
175         void on_layer_toggle(const Glib::ustring& path_string);
176
177         void on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node, const synfig::Time&, const synfig::Time&, int button);
178
179         void on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node);
180
181         bool on_layer_tree_event(GdkEvent *event);
182
183         bool on_param_tree_event(GdkEvent *event);
184
185         void on_selection_changed();
186
187         void on_dirty_preview();
188
189         void on_amount_value_changed();
190
191         void on_blend_method_changed();
192
193 public:
194
195         // void on_raise_pressed();
196
197         // void on_lower_pressed();
198
199         // void on_duplicate_pressed();
200
201         // void on_encapsulate_pressed();
202
203         // void on_delete_pressed();
204
205         /*
206  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
207         */
208
209 public:
210
211         //Gtk::TreeView* get_param_tree_view() { return param_tree_view_; }
212         //Gtk::TreeView& param_tree_view() { return *param_tree_view_; }
213         Gtk::HBox& get_hbox() { return *hbox; }
214
215         Gtk::TreeView& get_layer_tree_view() { return *layer_tree_view_; }
216         Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
217
218         const Gtk::TreeView& get_layer_tree_view()const { return *layer_tree_view_; }
219         const Gtk::TreeView& get_param_tree_view()const { return *param_tree_view_; }
220
221         Glib::RefPtr<Gtk::TreeSelection> get_selection() { return get_layer_tree_view().get_selection(); }
222         Glib::SignalProxy1< bool,GdkEvent* >  signal_event () { return get_layer_tree_view().signal_event(); }
223
224         LayerTree();
225         ~LayerTree();
226
227         void set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store_);
228
229         void set_time_adjustment(Gtk::Adjustment &adjustment);
230
231         void set_show_timetrack(bool x=true);
232
233         //! Signal called when layer is toggled.
234         sigc::signal<void,synfig::Layer::Handle>& signal_layer_toggle() { return signal_layer_toggle_; }
235
236         //! Signal called with a value has been edited.
237         sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
238
239         sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_layer_user_click() { return signal_layer_user_click_; }
240
241         sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_param_user_click() { return signal_param_user_click_; }
242
243         sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_layertree() { return signal_waypoint_clicked_layertree_; }
244
245         etl::handle<synfigapp::SelectionManager> get_selection_manager() { return layer_tree_store_->canvas_interface()->get_selection_manager(); }
246
247         void select_layer(synfig::Layer::Handle layer);
248         void select_layers(const LayerList& layer_list);
249         void select_all_children_layers(synfig::Layer::Handle layer);
250         void select_all_children(Gtk::TreeModel::Children::iterator iter);
251         LayerList get_selected_layers()const;
252         synfig::Layer::Handle get_selected_layer()const;
253         void clear_selected_layers();
254
255 }; // END of LayerTree
256
257 }; // END of namespace studio
258
259 /* === E N D =============================================================== */
260
261 #endif