synfig-studio  1.0.3
layertree.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
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/tooltip.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 
41 #include <synfigapp/value_desc.h>
42 #include "layertreestore.h"
43 #include "layerparamtreestore.h"
44 #include <synfig/valuenodes/valuenode_animated.h>
45 
46 #include "widgets/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 
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 
95 
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::TreeView* layer_tree_view_;
106 
107  Gtk::TreeView* param_tree_view_;
108 
109  Gtk::HBox *hbox;
110 
111  Glib::RefPtr<Gtk::Adjustment> layer_amount_adjustment_;
112 
113  Gtk::HScale *layer_amount_hscale;
114 
115  synfig::Layer::Handle quick_layer;
116 
117  Glib::RefPtr<LayerTreeStore> layer_tree_store_;
118 
119  Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
120 
121  Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
122 
123 #ifdef TIMETRACK_IN_PARAMS_PANEL
124  CellRenderer_TimeTrack *cellrenderer_time_track;
125 #endif // TIMETRACK_IN_PARAMS_PANEL
126 
127  Gtk::TreeView::Column* column_time_track;
128 
129  Gtk::TreeView::Column* column_z_depth;
130 
131  CellRenderer_ValueBase *cellrenderer_value;
132 
133  sigc::signal<void,synfig::Layer::Handle> signal_layer_toggle_;
134 
135  sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
136 
137  sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_layer_user_click_;
138 
139  sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_param_user_click_;
140 
141  sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_layertree_;
142 
143  sigc::signal<void,int> signal_param_tree_header_height_changed_;
144 
145  bool disable_amount_changed_signal;
146 
147  Gtk::Button *button_raise;
148  Gtk::Button *button_lower;
149  Gtk::Button *button_duplicate;
150  Gtk::Button *button_encapsulate;
151  Gtk::Button *button_delete;
152 
153  Widget_ValueBase blend_method_widget;
154 
155  bool param_tree_style_changed;
156 
157  int param_tree_header_height;
158 
159  /*
160  -- ** -- P R I V A T E M E T H O D S ---------------------------------------
161  */
162 
163 private:
164 
165  Gtk::Widget* create_layer_tree();
166  Gtk::Widget* create_param_tree();
168 
170  bool update_param_tree_header_height();
171 
172  /*
173  -- ** -- S I G N A L T E R M I N A L S -------------------------------------
174  */
175 
176 private:
177 
178  void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
179 
180  void on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value);
181 
182  void on_layer_toggle(const Glib::ustring& path_string);
183 
184  void on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node, const synfig::Time&, const synfig::Time&, const synfig::Time&, int button);
185 
186  void on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node);
187 
188  bool on_layer_tree_event(GdkEvent *event);
189 
190  bool on_param_tree_event(GdkEvent *event);
191 
192  bool on_param_tree_view_query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
193 
194  bool on_layer_tree_view_query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
195 
196  void on_selection_changed();
197 
198  void on_dirty_preview();
199 
200  void on_amount_value_changed();
201 
202  void on_blend_method_changed();
203 
204  void on_param_column_label_tree_style_updated();
205  bool on_param_column_label_tree_draw(const ::Cairo::RefPtr< ::Cairo::Context>& cr);
206 
207 public:
208 
209  // void on_raise_pressed();
210 
211  // void on_lower_pressed();
212 
213  // void on_duplicate_pressed();
214 
215  // void on_encapsulate_pressed();
216 
217  // void on_delete_pressed();
218 
219  /*
220  -- ** -- P U B L I C M E T H O D S -----------------------------------------
221  */
222 
223 public:
224 
225  //Gtk::TreeView* get_param_tree_view() { return param_tree_view_; }
226  //Gtk::TreeView& param_tree_view() { return *param_tree_view_; }
227  Gtk::HBox& get_hbox() { return *hbox; }
228 
229  Gtk::TreeView& get_layer_tree_view() { return *layer_tree_view_; }
230  Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
231 
232  const Gtk::TreeView& get_layer_tree_view()const { return *layer_tree_view_; }
233  const Gtk::TreeView& get_param_tree_view()const { return *param_tree_view_; }
234 
235  Glib::RefPtr<Gtk::TreeSelection> get_selection() { return get_layer_tree_view().get_selection(); }
236  Glib::SignalProxy1< bool,GdkEvent* > signal_event () { return get_layer_tree_view().signal_event(); }
237 
238  LayerTree();
239  ~LayerTree();
240 
241  void set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store_);
242 
243  void set_time_adjustment(const Glib::RefPtr<Gtk::Adjustment> &adjustment);
244 
245  void set_show_timetrack(bool x=true);
246 
248  sigc::signal<void,synfig::Layer::Handle>& signal_layer_toggle() { return signal_layer_toggle_; }
249 
251  sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
252 
253  sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_layer_user_click() { return signal_layer_user_click_; }
254 
255  sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_param_user_click() { return signal_param_user_click_; }
256 
257  sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_layertree() { return signal_waypoint_clicked_layertree_; }
258 
260 
261  sigc::signal<void,int>& signal_param_tree_header_height_changed() { return signal_param_tree_header_height_changed_; }
262 
263  etl::handle<synfigapp::SelectionManager> get_selection_manager() { return layer_tree_store_->canvas_interface()->get_selection_manager(); }
264 
266  void select_layers(const LayerList& layer_list);
268  void select_all_children(Gtk::TreeModel::Children::iterator iter);
271  void clear_selected_layers();
272 
273 }; // END of LayerTree
274 
275 }; // END of namespace studio
276 
277 /* === E N D =============================================================== */
278 
279 #endif