1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
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.
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.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_STUDIO_LAYERTREE_H
27 #define __SYNFIG_STUDIO_LAYERTREE_H
29 /* === H E A D E R S ======================================================= */
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>
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>
46 #include "widget_value.h"
48 /* === M A C R O S ========================================================= */
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
54 /* === T Y P E D E F S ===================================================== */
56 /* === C L A S S E S & S T R U C T S ======================================= */
58 namespace Gtk { class TreeModelSort; };
62 class CellRenderer_TimeTrack;
63 class CellRenderer_ValueBase;
65 class LayerTree : public Gtk::Table
68 -- ** -- P U B L I C T Y P E S ---------------------------------------------
73 typedef studio::ColumnID ColumnID;
80 COLUMNID_END //!< \internal
83 typedef std::list<synfig::Layer::Handle> LayerList;
86 -- ** -- P U B L I C D A T A ------------------------------------------------
91 //LayerTreeStore::Model model;
93 LayerTreeStore::Model layer_model;
94 LayerParamTreeStore::Model param_model;
96 synfig::Layer::Handle last_top_selected_layer;
97 Gtk::TreePath last_top_selected_path;
100 -- ** -- P R I V A T E D A T A ---------------------------------------------
105 Gtk::Tooltips tooltips_;
106 Gtk::TreePath last_tooltip_path;
108 Gtk::TreeView* layer_tree_view_;
110 Gtk::TreeView* param_tree_view_;
114 Gtk::Adjustment layer_amount_adjustment_;
116 Gtk::HScale *layer_amount_hscale;
118 synfig::Layer::Handle quick_layer;
120 Glib::RefPtr<LayerTreeStore> layer_tree_store_;
122 Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
124 Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
126 #ifdef TIMETRACK_IN_PARAMS_PANEL
127 CellRenderer_TimeTrack *cellrenderer_time_track;
128 #endif // TIMETRACK_IN_PARAMS_PANEL
130 Gtk::TreeView::Column* column_time_track;
132 Gtk::TreeView::Column* column_z_depth;
134 CellRenderer_ValueBase *cellrenderer_value;
136 sigc::signal<void,synfig::Layer::Handle> signal_layer_toggle_;
138 sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
140 sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_layer_user_click_;
142 sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_param_user_click_;
144 sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_layertree_;
146 bool disable_amount_changed_signal;
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;
154 Widget_ValueBase blend_method_widget;
157 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
162 Gtk::Widget* create_layer_tree();
163 Gtk::Widget* create_param_tree();
166 -- ** -- S I G N A L T E R M I N A L S -------------------------------------
171 void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
173 void on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value);
175 void on_layer_toggle(const Glib::ustring& path_string);
177 void on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node, const synfig::Time&, const synfig::Time&, int button);
179 void on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node);
181 bool on_layer_tree_event(GdkEvent *event);
183 bool on_param_tree_event(GdkEvent *event);
185 void on_selection_changed();
187 void on_dirty_preview();
189 void on_amount_value_changed();
191 void on_blend_method_changed();
195 // void on_raise_pressed();
197 // void on_lower_pressed();
199 // void on_duplicate_pressed();
201 // void on_encapsulate_pressed();
203 // void on_delete_pressed();
206 -- ** -- P U B L I C M E T H O D S -----------------------------------------
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; }
215 Gtk::TreeView& get_layer_tree_view() { return *layer_tree_view_; }
216 Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
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_; }
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(); }
227 void set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store_);
229 void set_time_adjustment(Gtk::Adjustment &adjustment);
231 void set_show_timetrack(bool x=true);
233 //! Signal called when layer is toggled.
234 sigc::signal<void,synfig::Layer::Handle>& signal_layer_toggle() { return signal_layer_toggle_; }
236 //! Signal called with a value has been edited.
237 sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
239 sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_layer_user_click() { return signal_layer_user_click_; }
241 sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_param_user_click() { return signal_param_user_click_; }
243 sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_layertree() { return signal_waypoint_clicked_layertree_; }
245 etl::handle<synfigapp::SelectionManager> get_selection_manager() { return layer_tree_store_->canvas_interface()->get_selection_manager(); }
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();
255 }; // END of LayerTree
257 }; // END of namespace studio
259 /* === E N D =============================================================== */