tweak knob drawing, add angular/radial control on button3
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / motionfeedback.h
1 /*
2     Copyright (C) 1998-99 Paul Barton-Davis 
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation; either version 2 of the License, or
6     (at your option) any later version.
7
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12
13     You should have received a copy of the GNU General Public License
14     along with this program; if not, write to the Free Software
15     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17     $Id: motionfeedback.h,v 1.1.1.1 2001/11/24 00:44:46 pbd Exp $
18 */
19
20 #ifndef __gtkmm2ext_motion_feedback_h__
21 #define __gtkmm2ext_motion_feedback_h__
22
23 #include <gdkmm/pixbuf.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/eventbox.h>
26
27 #include "gtkmm2ext/binding_proxy.h"
28 #include "gtkmm2ext/prolooks-helpers.h"
29
30 namespace Gtk {
31         class Adjustment;
32         class SpinButton;
33 }
34
35 namespace Gtkmm2ext {
36
37 class MotionFeedback : public Gtk::VBox
38 {
39  public:
40         enum Type {
41                 Rotary,
42                 CenterSpring,
43                 Endless
44         };
45
46         MotionFeedback (Glib::RefPtr<Gdk::Pixbuf>, 
47                         Type type,
48                         const char *widget_name = NULL,
49                         Gtk::Adjustment *adj = NULL, 
50                         bool with_numeric_display = true,
51                         int sub_image_width = 40,
52                         int sub_image_height = 40);
53         virtual ~MotionFeedback ();
54
55         void set_adjustment (Gtk::Adjustment *adj);
56         Gtk::Adjustment *get_adjustment () { return adjustment; }
57
58         Gtk::Widget&     eventwin () { return pixwin; }
59         Gtk::SpinButton& spinner() const { return *value; }
60
61         gfloat lower () { return _lower; }
62         gfloat upper () { return _upper; }
63         gfloat range () { return _range; }
64
65         void set_controllable (boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable (c); }
66         void set_lamp_color (const Gdk::Color&);
67
68  protected:
69         gfloat _range;
70         gfloat _lower;
71         gfloat _upper;
72
73         void pixwin_size_request (GtkRequisition *);
74
75         bool pixwin_button_press_event (GdkEventButton *);
76         bool pixwin_button_release_event (GdkEventButton *);
77         bool pixwin_motion_notify_event (GdkEventMotion *);
78         bool pixwin_key_press_event (GdkEventKey *);
79         bool pixwin_enter_notify_event (GdkEventCrossing *);
80         bool pixwin_leave_notify_event (GdkEventCrossing *);
81         bool pixwin_focus_in_event (GdkEventFocus*);
82         bool pixwin_focus_out_event (GdkEventFocus *);
83         bool pixwin_expose_event (GdkEventExpose*);
84         bool pixwin_scroll_event (GdkEventScroll*);
85         void pixwin_realized ();
86
87   private:
88         Type type;
89         Gtk::EventBox      pixwin;
90         Gtk::HBox*         value_packer;
91         Gtk::SpinButton*   value;
92         Gtk::Adjustment*   adjustment;
93         Glib::RefPtr<Gdk::Pixbuf> pixbuf;
94         BindingProxy       binding_proxy;
95
96         double default_value;
97         double  step_inc;
98         double page_inc;
99         bool   grab_is_fine;
100         double grabbed_y;
101         double grabbed_x;
102         bool i_own_my_adjustment;
103         int subwidth;
104         int subheight;
105         void adjustment_changed ();
106
107         ProlooksHSV* lamp_hsv;
108         Gdk::Color _lamp_color;
109         GdkColor lamp_bright;
110         GdkColor lamp_dark;
111
112         void core_draw (cairo_t*, int, double, double, double);
113 };
114
115 } /* namespace */
116         
117 #endif // __gtkmm2ext_motion_feedback_h__