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