Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_05 / synfig-studio / src / gtkmm / cellrenderer_timetrack.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file cellrenderer_timetrack.h
3 **      \brief Template Header
4 **
5 **      $Id: cellrenderer_timetrack.h,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
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_GTKMM_CELLRENDERER_TIMETRACK_H
26 #define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <gtk/gtk.h>
31 #include <gtkmm/ruler.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 <atkmm/stateset.h>
43 #include <gtkmm/paned.h>
44 #include <gtkmm/treeview.h>
45 #include <gtkmm/treestore.h>
46 #include <gtkmm/adjustment.h>
47 #include <gtkmm/box.h>
48 #include <gtkmm/scrollbar.h>
49 #include <gtkmm/cellrenderer.h>
50
51 #include <gtkmm/dialog.h>
52 #include <gtkmm/menu.h>
53
54
55 #include <synfigapp/canvasinterface.h>
56 #include <synfigapp/value_desc.h>
57 #include <synfig/valuenode_animated.h>
58 #include <synfig/valuenode_dynamiclist.h>
59 #include <synfig/string.h>
60 #include <synfig/time.h>
61
62 /* === M A C R O S ========================================================= */
63
64 /* === T Y P E D E F S ===================================================== */
65
66
67 /* === C L A S S E S & S T R U C T S ======================================= */
68
69 namespace studio {
70 class Widget_ValueBase;
71
72 enum Side
73 {
74         SIDE_LEFT,
75         SIDE_RIGHT
76 };
77
78 /*! \class CellRenderer_TimeTrack
79 **      \brief A cell renderer that displays the waypoints for Animated ValueNodes.
80 */
81 class CellRenderer_TimeTrack :
82         public Gtk::CellRenderer
83 {
84
85         /*
86  --     ** -- P R I V A T E   D A T A ---------------------------------------------
87         */
88
89 private:
90         //! Time adjustment window
91         Gtk::Adjustment adjustment_;
92         
93         //! Signal for when the user clicks on a waypoint
94         sigc::signal<void, const Glib::ustring&,synfig::Waypoint, int> signal_waypoint_clicked_;
95
96         sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
97
98         //! Iterator for selected waypoint. (Should this be an UniqueID instead?)
99         synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
100         
101         synfig::UniqueID selected;
102
103         //! selected information for time... (will work for way points etc...)
104         //TODO: make multiple... on both time and value select...
105         std::set<synfig::Time>  sel_times;
106         synfigapp::ValueDesc            sel_value;
107         synfig::Time                            actual_time;
108         synfig::Time                            actual_dragtime;
109         int                                             mode;
110
111         //! ???
112         synfig::Time selected_time;
113     
114         //! The path to the current item in the tree model
115         Glib::ustring path;
116         
117         //! ???
118         bool selection;
119
120         bool dragging;
121
122         synfig::Time drag_time;
123         
124         etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface_;
125
126         /*
127  --     ** -- P R O P E R T I E S -------------------------------------------------
128         */
129
130 private:
131         
132         //! ValueBase Desc
133         Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
134
135         //! Canvas
136         Glib::Property<synfig::Canvas::Handle> property_canvas_;
137
138         //! ??? \see adjustment_
139         Glib::Property<Gtk::Adjustment* > property_adjustment_;
140
141         //! \writeme
142         Glib::Property<bool> property_enable_timing_info_;
143
144         /*
145  --     ** -- P R O P E R T Y   I N T E R F A C E S -------------------------------
146         */
147
148 public:
149
150         Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
151
152         Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
153
154         Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
155
156         /*
157  --     ** -- S I G N A L   I N T E R F A C E S -----------------------------------
158         */
159
160 public:
161
162         sigc::signal<void, const Glib::ustring&,synfig::Waypoint,int> &signal_waypoint_clicked()
163         {return signal_waypoint_clicked_; }
164
165         sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
166         {return signal_waypoint_changed_; }
167
168         /*
169  --     ** -- P U B L I C   M E T H O D S -----------------------------------------
170         */
171
172 public:
173
174         CellRenderer_TimeTrack();
175     ~CellRenderer_TimeTrack();
176         
177         void show_timepoint_menu(const etl::handle<synfig::Node>& node, const synfig::Time& time, Side side=SIDE_RIGHT);
178
179         void set_adjustment(Gtk::Adjustment &x);
180         Gtk::Adjustment *get_adjustment();
181         const Gtk::Adjustment *get_adjustment()const;
182
183         etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface()const {return canvas_interface_;}
184         void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
185         
186         synfig::Canvas::Handle get_canvas()const;
187         
188         bool is_selected(const synfig::Waypoint& waypoint)const;
189
190         synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
191
192         virtual void
193         render_vfunc(
194                 const Glib::RefPtr<Gdk::Drawable>& window,
195                 Gtk::Widget& widget,
196                 const Gdk::Rectangle& background_area,
197                 const Gdk::Rectangle& ca,
198                 const Gdk::Rectangle& expose_area,
199                 Gtk::CellRendererState flags);
200
201         virtual bool
202         activate_vfunc( GdkEvent* event,
203                                         Gtk::Widget& widget,
204                                         const Glib::ustring& path,
205                                         const Gdk::Rectangle& background_area,
206                                         const Gdk::Rectangle& cell_area,
207                                         Gtk::CellRendererState flags);
208
209 }; // END of class CellRenderer_TimeTrack
210
211 }; // END of namespace studio
212
213 /* === E N D =============================================================== */
214
215 #endif