remove frame from barcontroller
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / barcontroller.h
1 /*
2     Copyright (C) 2004 Paul 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 */
18
19 #ifndef __gtkmm2ext_bar_controller_h__
20 #define __gtkmm2ext_bar_controller_h__
21
22 #include <gtkmm/alignment.h>
23 #include <gtkmm/frame.h>
24 #include <gtkmm/drawingarea.h>
25 #include <cairo.h>
26
27 #include "gtkmm2ext/visibility.h"
28 #include "gtkmm2ext/binding_proxy.h"
29
30 namespace Gtkmm2ext {
31
32 class LIBGTKMM2EXT_API BarController : public Gtk::Alignment
33 {
34   public:
35         BarController (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable>);
36
37         virtual ~BarController ();
38
39         enum barStyle {
40                 LeftToRight,
41                 RightToLeft,
42                 Line,
43                 Blob,
44                 CenterOut,
45                 
46                 TopToBottom,
47                 BottomToTop
48         };
49
50         barStyle style() const { return _style; }
51         void set_style (barStyle);
52         void set_use_parent (bool yn);
53
54         void set_sensitive (bool yn);
55         
56         void set_logarithmic (bool yn) { logarithmic = yn; }
57
58         sigc::signal<void> StartGesture;
59         sigc::signal<void> StopGesture;
60
61         /* export this to allow direct connection to button events */
62
63         Gtk::Widget& event_widget() { return darea; }
64
65         boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
66         void set_controllable(boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable(c); }
67
68         /** Emitted when the adjustment spinner is activated or deactivated;
69          *  the parameter is true on activation, false on deactivation.
70          */
71         sigc::signal<void, bool> SpinnerActive;
72
73   protected:
74         Gtk::Adjustment&    adjustment;
75         BindingProxy        binding_proxy;
76         Gtk::DrawingArea    darea;
77         Glib::RefPtr<Pango::Layout> layout;
78         barStyle              _style;
79         bool                grabbed;
80         bool                switching;
81         bool                switch_on_release;
82         double              initial_value;
83         double              grab_x;
84         GdkWindow*          grab_window;
85         Gtk::SpinButton     spinner;
86         bool                use_parent;
87         bool                logarithmic;
88         sigc::slot<std::string> _label_slot;
89         bool                    _use_slot;
90
91         virtual std::string get_label (double& /*x*/) {
92                 return "";
93         }
94         
95         virtual bool button_press (GdkEventButton *);
96         virtual bool button_release (GdkEventButton *);
97         virtual bool motion (GdkEventMotion *);
98         virtual bool expose (GdkEventExpose *);
99         virtual bool scroll (GdkEventScroll *);
100         virtual bool entry_focus_out (GdkEventFocus*);
101         bool on_enter_notify_event (GdkEventCrossing* ev);
102         bool on_leave_notify_event (GdkEventCrossing* ev);
103
104         gint mouse_control (double x, GdkWindow* w, double scaling);
105
106         Gdk::Color get_parent_bg ();
107
108         gint switch_to_bar ();
109         gint switch_to_spinner ();
110
111         void entry_activated ();
112         void drop_grab ();
113         
114         int entry_input (double* new_value);
115         bool entry_output ();
116
117         bool _hovering;
118
119 };
120
121
122 }; /* namespace */
123
124 #endif // __gtkmm2ext_bar_controller_h__