synfig-studio  1.0.3
widget_timeslider.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
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 Cairo::RefPtr<Cairo::Context> &cr,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  Glib::RefPtr<Gtk::Adjustment> adj_default;
60  Glib::RefPtr<Gtk::Adjustment> adj_timescale;
61 
62  //HACK - I should not have to see this...
63  Glib::RefPtr<Gtk::Adjustment> adj_bounds;
65 
66  //Statistics used for drawing stuff (and making sure we don't if we don't need to)
67  /*double start,end;
68  double current;
69 
70  bool invalidated;*/
71 
72  guint32 last_event_time;
73 
74  float fps;
75 
76  sigc::connection time_value_change;
77  sigc::connection time_other_change;
78 
79  //TODO: fill out blue pill stuff
80 
81  //input functions
82 
83  virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
84  virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
85  virtual bool on_button_press_event(GdkEventButton *event); //for clicking
86  virtual bool on_button_release_event(GdkEventButton *event); //for clicking
87 
88  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
89 
90  //void update_times();
91 
92  void zoom_in(bool centerontime = false);
93  void zoom_out(bool centerontime = false);
94 
95  //Drag the Frame
96  bool dragscroll;
97 
98  /*NOTE: if we can set the mouse position to the original position
99  this would only have to be set once (and it would be good otherwise too)
100  */
101  double lastx; //last mouse position for dragging
102 
103 public: //structors
106 
107 public: //Normal Interface
108 
109  void draw() {queue_draw();}
110  virtual void refresh(); //reget bluepills, time values and queue_draw if need be
111 
112 public: //Time Interface
113 
114  //Run FPS stuff through it to the MAX
115  double get_global_fps() const {return fps;}
116  void set_global_fps(float d);
117 
118  //accessors for the time adjustment
119  Glib::RefPtr<Gtk::Adjustment> get_time_adjustment() const { return adj_timescale; }
120  void set_time_adjustment(const Glib::RefPtr<Gtk::Adjustment> &x);
121 
122  //HACK - I should not have to see these bounds (should be boundless)
123  Glib::RefPtr<Gtk::Adjustment> get_bounds_adjustment() const { return adj_bounds; }
124  void set_bounds_adjustment(const Glib::RefPtr<Gtk::Adjustment> &x) { adj_bounds = x; }
125 };
126 
127 }; // END of namespace studio
128 
129 /* === E N D =============================================================== */
130 
131 #endif