Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07_rc2 / src / gtkmm / widget_timeslider.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file widget_timeslider.h
3 **      \brief Time Slider Widget Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2004 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_WIDGET_TIMESLIDER_H
26 #define __SYNFIG_WIDGET_TIMESLIDER_H
27
28 /* === H E A D E R S ======================================================= */
29 #include <gtkmm/drawingarea.h>
30 #include <gtkmm/adjustment.h>
31
32 #include <synfig/time.h>
33 #include "canvasview.h"
34
35 /* === M A C R O S ========================================================= */
36
37 /* === T Y P E D E F S ===================================================== */
38
39 /* === C L A S S E S & S T R U C T S ======================================= */
40
41 namespace studio {
42
43 void render_time_point_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::TimePoint &tp,bool selected=false);
44
45
46 /* Design for the timeslider...
47
48         Concept: Scalable ruler
49                 Ticks are done every so often (30 s, 10 frames, 5 frames, etc.)
50                 Print out frame numbers next to the big ticks
51                 Show blue pills in separate area (above or below)
52 */
53
54 class Widget_Timeslider : public Gtk::DrawingArea
55 {
56 protected: //implementation that other interfaces can see
57         Glib::RefPtr<Pango::Layout> layout; //implementation awesomeness for text drawing
58
59         Gtk::Adjustment adj_default;
60         Gtk::Adjustment *adj_timescale;
61
62         //HACK - I should not have to see this...
63         Gtk::Adjustment *adj_bounds;
64
65         //Statistics used for drawing stuff (and making sure we don't if we don't need to)
66         /*double start,end;
67         double current;
68
69         bool invalidated;*/
70
71         guint32 last_event_time;
72
73         float fps;
74
75         sigc::connection time_value_change;
76         sigc::connection time_other_change;
77
78         //TODO: fill out blue pill stuff
79
80         //input functions
81
82         virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
83         virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
84         virtual bool on_button_press_event(GdkEventButton *event); //for clicking
85         virtual bool on_button_release_event(GdkEventButton *event); //for clicking
86
87         virtual bool on_expose_event(GdkEventExpose */*event*/) {redraw(); return true;}//for drawing
88
89         virtual bool redraw(bool doublebuffer = false);
90
91         //void update_times();
92
93         void zoom_in(bool centerontime = false);
94         void zoom_out(bool centerontime = false);
95
96         //Drag the Frame
97         bool dragscroll;
98
99         /*NOTE: if we can set the mouse position to the original position
100                         this would only have to be set once (and it would be good otherwise too)
101         */
102         double lastx; //last mouse position for dragging
103
104 public: //structors
105         Widget_Timeslider();
106         ~Widget_Timeslider();
107
108 public: //Normal Interface
109
110         void draw() {redraw();}
111         virtual void refresh(); //reget bluepills, time values and queue_draw if need be
112
113 public: //Time Interface
114
115         //Run FPS stuff through it to the MAX
116         double get_global_fps() const {return fps;}
117         void set_global_fps(float d);
118
119         //accessors for the time adjustment
120         Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
121         void set_time_adjustment(Gtk::Adjustment *x);
122
123         //HACK - I should not have to see these bounds (should be boundless)
124         Gtk::Adjustment &get_bounds_adjustment() const {return *adj_bounds;}
125         void set_bounds_adjustment(Gtk::Adjustment *x) {adj_bounds = x;}
126 };
127
128 }; // END of namespace studio
129
130 /* === E N D =============================================================== */
131
132 #endif