b42127d00021ca14b4980cb69bc02bbf0b996a50
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_keyframe_list.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file widget_keyframe_list.h
3 **      \brief A custom widget to manage keyframes in the timeline.
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2009 Carlos López
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_STUDIO_WIDGET_KEYFRAME_LIST_H
27 #define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include <gtkmm/drawingarea.h>
32 #include <gtkmm/adjustment.h>
33 #include <synfig/keyframe.h>
34 #include <sigc++/connection.h>
35
36
37 /* === M A C R O S ========================================================= */
38
39 /* === T Y P E D E F S ===================================================== */
40
41 /* === C L A S S E S & S T R U C T S ======================================= */
42
43 namespace studio {
44
45 class Widget_Keyframe_List : public Gtk::DrawingArea
46 {
47         //! Time adjustment window
48         Gtk::Adjustment adj_default;
49         Gtk::Adjustment *adj_timescale;
50
51         //!The list of keyframes to be drawn on the widget and moved with mouse
52         synfig::KeyframeList default_kf_list_;
53         mutable synfig::KeyframeList* kf_list_;
54
55         //! The frames per second of the canvas
56         float fps;
57
58         //! Time radius to click a keyframe
59         synfig::Time time_ratio;
60
61         //!True if it is editable. Keyframes can be moved.
62         bool editable_;
63
64         //!True if a keyframe is being dragged.
65         bool dragging_;
66
67         //!True if a keyframe has been moved
68         bool changed_;
69
70         //!Holds the selected keyframe of the keyframe list
71         synfig::Keyframe selected_kf;
72         synfig::Keyframe selected_none;
73
74         //!The time of the selected keyframe
75         synfig::Time selected_kf_time;
76
77         //!The time of the selected keyframe during draging
78         synfig::Time dragging_kf_time;
79
80         //!Connectors for handling the signals of the time adjustment
81         sigc::connection time_value_change;
82         sigc::connection time_other_change;
83
84 public:
85
86         //!Default constructor
87         Widget_Keyframe_List();
88
89         //!Destructror
90         ~Widget_Keyframe_List();
91
92         //!Loads a new keyframe list on the widget.
93         void set_kf_list(synfig::KeyframeList* x);
94
95         //!Member for private data.
96         synfig::KeyframeList* get_kf_list()const { return kf_list_; }
97
98         //!Member for private data
99         void set_editable(bool x=true) { editable_=x; }
100
101         //!Member for private data
102         bool get_editable()const { return editable_; }
103
104
105         //!Store the selected keyframe value
106         void set_selected_keyframe(const synfig::Keyframe &x);
107
108         //!Returns the selected keyframe
109         const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
110
111         //! Set the time adjustment and proper connects its change signals
112         void set_time_adjustment(Gtk::Adjustment *x);
113
114         //! Set the fps
115         void set_fps(float x);
116
117         //! Performs the keyframe movement. Returns true if it was sucessful
118         bool perform_move_kf();
119
120
121
122 /* ======================= EVENTS HANDLERS ===========================*/
123         //!Redraw event. Should draw all the keyframes +  the selected + the dragged
124         bool redraw(GdkEventExpose*bleh=NULL);
125
126         //!Mouse event handler.
127         bool on_event(GdkEvent *event);
128 }; // END of class Keyframe_List
129
130 }; // END of namespace studio
131
132 /* === E N D =============================================================== */
133
134 #endif