349dcd3cd99dcc27922d5f5e412c21255a4386cf
[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 #include <synfigapp/canvasinterface.h>
36
37
38 /* === M A C R O S ========================================================= */
39
40 /* === T Y P E D E F S ===================================================== */
41
42 /* === C L A S S E S & S T R U C T S ======================================= */
43
44 namespace studio {
45
46 class Widget_Keyframe_List : public Gtk::DrawingArea
47 {
48         //! The canvas interface being watched
49         etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
50
51         //! Time adjustment window
52         Gtk::Adjustment adj_default;
53         Gtk::Adjustment *adj_timescale;
54
55         //!The list of keyframes to be drawn on the widget and moved with mouse
56         synfig::KeyframeList default_kf_list_;
57         mutable synfig::KeyframeList* kf_list_;
58
59         //! The frames per second of the canvas
60         float fps;
61
62         //! Time radius to click a keyframe
63         synfig::Time time_ratio;
64
65         //!True if it is editable. Keyframes can be moved.
66         bool editable_;
67
68         //!True if a keyframe is being dragged.
69         bool dragging_;
70
71         //!True if a keyframe has been moved
72         bool changed_;
73
74         //!Holds the selected keyframe of the keyframe list
75         synfig::Keyframe selected_kf;
76         synfig::Keyframe selected_none;
77         bool selected_;
78
79         //!The time of the selected keyframe
80         synfig::Time selected_kf_time;
81
82         //!The time of the selected keyframe during draging
83         synfig::Time dragging_kf_time;
84
85         //!Connectors for handling the signals of the time adjustment
86         sigc::connection time_value_change;
87         sigc::connection time_other_change;
88
89 public:
90
91         //!Default constructor
92         Widget_Keyframe_List();
93
94         //!Destructror
95         ~Widget_Keyframe_List();
96
97         //!Loads a new keyframe list on the widget.
98         void set_kf_list(synfig::KeyframeList* x);
99
100         //!Member for private data.
101         synfig::KeyframeList* get_kf_list()const { return kf_list_; }
102
103         //!Member for private data
104         void set_editable(bool x=true) { editable_=x; }
105
106         //!Member for private data
107         bool get_editable()const { return editable_; }
108
109
110         //!Store the selected keyframe value
111         void set_selected_keyframe(const synfig::Keyframe &x);
112
113         //!Returns the selected keyframe
114         const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
115
116         //! Set the time adjustment and proper connects its change signals
117         void set_time_adjustment(Gtk::Adjustment *x);
118
119         //! Set the fps
120         void set_fps(float x);
121
122         //! Set the canvas interface
123         void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
124
125         //! Performs the keyframe movement. Returns true if it was sucessful
126         //! @return true: if success otherwise false
127         //! |delta=false: permorm normal move. true: perform delta movement
128         bool perform_move_kf(bool delta);
129
130
131
132 /* ======================= EVENTS HANDLERS ===========================*/
133         //!Redraw event. Should draw all the keyframes +  the selected + the dragged
134         bool redraw(GdkEventExpose*bleh=NULL);
135
136         //!Mouse event handler.
137         bool on_event(GdkEvent *event);
138 }; // END of class Keyframe_List
139
140 }; // END of namespace studio
141
142
143 /* === E N D =============================================================== */
144
145 #endif