39e3f3a8c3a0bff6c99d32d0598688cc0241da7c
[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 **
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 /*! \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         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&, int, synfig::Waypoint::Side> 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<Gtk::Adjustment* > property_adjustment_;
133
134         //! \writeme
135         Glib::Property<bool> property_enable_timing_info_;
136
137         /*
138  --     ** -- P R O P E R T Y   I N T E R F A C E S -------------------------------
139         */
140
141 public:
142
143         Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
144
145         Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
146
147         Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
148
149         /*
150  --     ** -- S I G N A L   I N T E R F A C E S -----------------------------------
151         */
152
153 public:
154
155         sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int, synfig::Waypoint::Side> &signal_waypoint_clicked_cellrenderer()
156         {return signal_waypoint_clicked_cellrenderer_; }
157
158         sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
159         {return signal_waypoint_changed_; }
160
161         /*
162  --     ** -- P U B L I C   M E T H O D S -----------------------------------------
163         */
164
165 public:
166
167         CellRenderer_TimeTrack();
168     ~CellRenderer_TimeTrack();
169
170         void show_timepoint_menu(const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, synfig::Waypoint::Side side=synfig::Waypoint::SIDE_RIGHT);
171
172         void set_adjustment(Gtk::Adjustment &x);
173         Gtk::Adjustment *get_adjustment();
174         const Gtk::Adjustment *get_adjustment()const;
175
176         etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface()const {return canvas_interface_;}
177         void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
178
179         synfig::Canvas::Handle get_canvas()const;
180
181         bool is_selected(const synfig::Waypoint& waypoint)const;
182
183         synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
184
185         virtual void
186         render_vfunc(
187                 const Glib::RefPtr<Gdk::Drawable>& window,
188                 Gtk::Widget& widget,
189                 const Gdk::Rectangle& background_area,
190                 const Gdk::Rectangle& ca,
191                 const Gdk::Rectangle& expose_area,
192                 Gtk::CellRendererState flags);
193
194         virtual bool
195         activate_vfunc( GdkEvent* event,
196                                         Gtk::Widget& widget,
197                                         const Glib::ustring& path,
198                                         const Gdk::Rectangle& background_area,
199                                         const Gdk::Rectangle& cell_area,
200                                         Gtk::CellRendererState flags);
201
202 }; // END of class CellRenderer_TimeTrack
203
204 }; // END of namespace studio
205
206 /* === E N D =============================================================== */
207
208 #endif