1 /* === S Y N F I G ========================================================= */
2 /*!	\file cellrenderer_timetrack.h
3 **	\brief Cell renderer for the timetrack. Render all time points (waypoints / keyframes and current time line ...)
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2007, 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_GTKMM_CELLRENDERER_TIMETRACK_H
27 #define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
28 
29 /* === H E A D E R S ======================================================= */
30 
31 #include <gtk/gtk.h>
32 #include <gtkmm/arrow.h>
33 #include <gtkmm/image.h>
34 #include <gdkmm/pixbufloader.h>
35 #include <gtkmm/viewport.h>
36 #include <gtkmm/adjustment.h>
37 #include <gtkmm/scrolledwindow.h>
38 #include <gtkmm/table.h>
39 #include <gtkmm/statusbar.h>
40 #include <gtkmm/button.h>
41 #include <gtkmm/progressbar.h>
42 #include <gtkmm/paned.h>
43 #include <gtkmm/treeview.h>
44 #include <gtkmm/treestore.h>
45 #include <gtkmm/box.h>
46 #include <gtkmm/scrollbar.h>
47 #include <gtkmm/cellrenderer.h>
48 
49 #include <gtkmm/dialog.h>
50 #include <gtkmm/menu.h>
51 
52 #include <glibmm/property.h>
53 
54 #include <synfigapp/canvasinterface.h>
55 #include <synfigapp/value_desc.h>
56 #include <synfig/valuenodes/valuenode_animated.h>
57 #include <synfig/valuenodes/valuenode_dynamiclist.h>
58 #include <synfig/string.h>
59 #include <synfig/time.h>
60 
61 /* === M A C R O S ========================================================= */
62 
63 /* === T Y P E D E F S ===================================================== */
64 
65 
66 /* === C L A S S E S & S T R U C T S ======================================= */
67 
68 namespace studio {
69 class Widget_ValueBase;
70 
71 /*! \class CellRenderer_TimeTrack
72 **	\brief A cell renderer that displays the waypoints for Animated ValueNodes.
73 */
74 class CellRenderer_TimeTrack :
75 	public Gtk::CellRenderer
76 {
77 
78 	/*
79  --	** -- P R I V A T E   D A T A ---------------------------------------------
80 	*/
81 
82 private:
83 	//! Time adjustment window
84 	Glib::RefPtr<Gtk::Adjustment> adjustment_;
85 
86 	//! Signal for when the user clicks on a waypoint
87 	sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, const synfig::Time&, int> signal_waypoint_clicked_cellrenderer_;
88 
89 	sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
90 
91 	//! Iterator for selected waypoint. (Should this be an UniqueID instead?)
92 	synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
93 
94 	synfig::UniqueID selected;
95 
96 	//! selected information for time... (will work for way points etc...)
97 	//TODO: make multiple... on both time and value select...
98 	std::set<synfig::Time>	sel_times;
99 	synfigapp::ValueDesc		sel_value;
100 	synfig::Time				actual_time;
101 	synfig::Time				actual_dragtime;
102 	int						mode;
103 
104 	//! ???
105 	synfig::Time selected_time;
106 
107 	//! The path to the current item in the tree model
108 	Glib::ustring path;
109 
110 	//! ???
111 	bool selection;
112 
113 	bool dragging;
114 
115 	synfig::Time drag_time;
116 
117 	etl::loose_handle<synfigapp::CanvasInterface>	canvas_interface_;
118 
119 	/*
120  --	** -- P R O P E R T I E S -------------------------------------------------
121 	*/
122 
123 private:
124 
125 	//! ValueBase Desc
126 	Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
127 
128 	//! Canvas
129 	Glib::Property<synfig::Canvas::Handle> property_canvas_;
130 
131 	//! ??? \see adjustment_
132 	Glib::Property< Glib::RefPtr<Gtk::Adjustment> > property_adjustment_;
133 
134 	//! \writeme
135 	Glib::Property<bool> property_enable_timing_info_;
136 
137 	/*
138  -- ** -- P R I V A T E   M E T H O D S --------------------------------------
139 	*/
140 
141 private:
142 	//! Render the inactive waypoint line ( active point off )
143 	void draw_activepoint_off(
144 			const ::Cairo::RefPtr< ::Cairo::Context>& cr,
145 			Gdk::Color inactive_color,
146 			int line_width,
147 			int from_x,
148 			int from_y,
149 			int to_x,
150 			int to_y);
151 
152 	/*
153  --	** -- P R O P E R T Y   I N T E R F A C E S -------------------------------
154 	*/
155 
156 public:
157 
158 	Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
159 
160 	Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
161 
162 	Glib::PropertyProxy< Glib::RefPtr<Gtk::Adjustment> > property_adjustment();
163 
164 	/*
165  --	** -- S I G N A L   I N T E R F A C E S -----------------------------------
166 	*/
167 
168 public:
169 
signal_waypoint_clicked_cellrenderer()170 	sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, const synfig::Time&, int> &signal_waypoint_clicked_cellrenderer()
171 	{return signal_waypoint_clicked_cellrenderer_; }
172 
signal_waypoint_changed()173 	sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
174 	{return signal_waypoint_changed_; }
175 
176 	/*
177  --	** -- P U B L I C   M E T H O D S -----------------------------------------
178 	*/
179 
180 public:
181 
182 	CellRenderer_TimeTrack();
183     ~CellRenderer_TimeTrack();
184 
185 	void set_adjustment(const Glib::RefPtr<Gtk::Adjustment> &x);
186 	Glib::RefPtr<Gtk::Adjustment> get_adjustment()const;
187 
canvas_interface()188 	etl::loose_handle<synfigapp::CanvasInterface>	canvas_interface()const {return canvas_interface_;}
189 	void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
190 
191 	synfig::Canvas::Handle get_canvas()const;
192 
193 	bool is_selected(const synfig::Waypoint& waypoint)const;
194 
195 	synfig::ValueNode_Animated::WaypointList::iterator find_editable_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
196 
197 	virtual void
198 	render_vfunc(
199 		const ::Cairo::RefPtr< ::Cairo::Context>& cr,
200 		Gtk::Widget& widget,
201 		const Gdk::Rectangle& background_area,
202 		const Gdk::Rectangle& cell_area,
203 		Gtk::CellRendererState flags);
204 
205 	virtual bool
206 	activate_vfunc(	GdkEvent* event,
207 					Gtk::Widget& widget,
208 					const Glib::ustring& path,
209 					const Gdk::Rectangle& background_area,
210 					const Gdk::Rectangle& cell_area,
211 					Gtk::CellRendererState flags);
212 
213 }; // END of class CellRenderer_TimeTrack
214 
215 }; // END of namespace studio
216 
217 /* === E N D =============================================================== */
218 
219 #endif
220