|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 #ifndef GTKMM_EXAMPLE_CAIROSLIDER_H 00002 #define GTKMM_EXAMPLE_CAIROSLIDER_H 00003 00004 #include <gtkmm/eventbox.h> 00005 #include <gtkmm/drawingarea.h> 00006 00007 class CairoSlider : public Gtk::DrawingArea 00008 { 00009 public: 00010 CairoSlider(); 00011 ~CairoSlider(); 00012 00013 protected: 00014 00028 virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) = 0; 00029 00038 int get_border(); 00039 00045 double get_percentage(); 00046 00052 void set_percentage(double p); 00053 00057 virtual void on_percent_change() = 0; 00058 00062 virtual double get_update_timeout() { 00063 return 0.05; 00064 } 00065 00071 virtual Gdk::RGBA& get_active_color(); 00077 virtual Gdk::RGBA& get_inactive_color(); 00078 00079 private: 00080 00081 // Signals: 00082 00083 // These signals should not be overwritten, therefore private 00084 bool on_button_press_event(GdkEventButton * ev); 00085 bool on_scroll_event(GdkEventScroll * ev); 00086 bool on_motion_notify_event(GdkEventMotion * ev); 00087 bool on_button_release_event(GdkEventButton * ev); 00088 00089 // Vars: 00090 00091 // Position frome where black lines are drawn 00092 int m_volPos; 00093 00094 // Current percentage 00095 double currPerc; 00096 00097 // Calculate the input 00098 void recalculate(double x, int step); 00099 00100 // true when 'dragging' with the mousepointer 00101 bool isDragging; 00102 00103 // A timer to prevent 'oversetting' percentage 00104 Glib::Timer m_Timerguard; 00105 00106 bool col_active_set, col_inactive_set; 00107 Gdk::RGBA * col_active; 00108 Gdk::RGBA * col_inactive; 00109 }; 00110 00111 #endif // GTKMM_EXAMPLE_CAIROSLIDER_H
1.8.0