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