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