1 /* === S Y N F I G ========================================================= */
2 /*!	\file trees/keyframetree.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_KEYFRAMETREE_H
26 #define __SYNFIG_STUDIO_KEYFRAMETREE_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <gtkmm/treeview.h>
31 #include <gtkmm/treestore.h>
32 #include <synfigapp/canvasinterface.h>
33 #include <synfigapp/value_desc.h>
34 #include "trees/keyframetreestore.h"
35 #include <synfig/keyframe.h>
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 CellRenderer_Time;
46 
47 class KeyframeTree : public Gtk::TreeView
48 {
49 	/*
50  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
51 	*/
52 
53 public:
54 
55 	enum ColumnID
56 	{
57 		COLUMNID_TIME,
58 		COLUMNID_DESCRIPTION,
59 		COLUMNID_JUMP,
60 
61 		COLUMNID_END			//!< \internal
62 	};
63 
64 	/*
65  -- ** -- P U B L I C  D A T A ------------------------------------------------
66 	*/
67 
68 public:
69 
70 	KeyframeTreeStore::Model model;
71 	synfig::Keyframe selected_kf;
72 
73 
74 	/*
75  -- ** -- P R I V A T E   D A T A ---------------------------------------------
76 	*/
77 
78 private:
79 
80 	Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
81 
82 	CellRenderer_Time *cell_renderer_time;
83 
84 	CellRenderer_Time *cell_renderer_time_delta;
85 
86 	Gtk::CellRendererText *cell_renderer_description;
87 
88 	sigc::signal<void,synfig::Keyframe> signal_edited_;
89 
90 	sigc::signal<void,synfig::Keyframe,synfig::Time> signal_edited_time_;
91 
92 	sigc::signal<void,synfig::Keyframe,synfig::String> signal_edited_description_;
93 
94 	sigc::signal<void, int, Gtk::TreeRow, ColumnID> signal_user_click_;
95 
96 	bool editable_;
97 
98 	bool send_selection;
99 
100 	/*
101  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
102 	*/
103 
104 private:
105 
106 	/*
107  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
108 	*/
109 
110 private:
111 
112 	void on_keyframe_toggle(const Glib::ustring& path_string);
113 
114 	void on_edited_time(const Glib::ustring&path_string,synfig::Time time);
115 
116 	void on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time);
117 
118 	void on_edited_description(const Glib::ustring&path_string,const Glib::ustring &description);
119 
120 	bool on_event(GdkEvent *event);
121 
122 	void on_rend_desc_changed();
123 
124 	//! Action performed when a keyframe is selected in the widget
125 	//! This is where keyframe selected signal is fired
126 	void on_selection_changed();
127 
128 	//! Signal handler for select keyframe signal from canvas interface
129 	void on_keyframe_selected(synfig::Keyframe, void* emitter);
130 	sigc::connection	keyframeselected;
131 
132 	/*
133  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
134 	*/
135 
136 public:
137 
138 	KeyframeTree();
139 	~KeyframeTree();
140 	//! Assign the model and connect signals from the canvas interface
141 	void set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_);
142 
143 	void set_editable(bool x=true);
144 
get_editable()145 	bool get_editable()const { return editable_; }
146 
147 	//! Signal called when a keyframe has been edited in any way
signal_edited()148 	sigc::signal<void,synfig::Keyframe>& signal_edited() { return signal_edited_; }
149 
150 	//! Signal called when a time has been edited.
signal_edited_time()151 	sigc::signal<void,synfig::Keyframe,synfig::Time>& signal_edited_time() { return signal_edited_time_; }
152 
153 	//! Signal called when a description has been edited.
signal_edited_description()154 	sigc::signal<void,synfig::Keyframe,synfig::String>& signal_edited_description() { return signal_edited_description_; }
155 
signal_user_click()156 	sigc::signal<void,int, Gtk::TreeRow, ColumnID>& signal_user_click() { return signal_user_click_; }
157 
158 	/*
159  -- ** -- P R O T E C T E D   M E T H O D S ---------------------------------------
160 	*/
161 
162 	protected:
163 
164 }; // END of KeyframeTree
165 
166 }; // END of namespace studio
167 
168 /* === E N D =============================================================== */
169 
170 #endif
171